Since AngularJS 1.5, we can use a new API when creating directives. This new API should be use when creating directive without DOM manipulation.
Rule based on Angular 1.5
The following patterns are considered problems;
/*eslint angular/prefer-component: 2*/
// invalid
angular.module('myModule').directive('helloWorld', function() {
return {
}
}); // error: Directive should be implemented with the component method.
The following patterns are not considered problems;
/*eslint angular/prefer-component: 2*/
// valid
angular.module('myModule').component('helloWorld', {
template: '<h2>Hello World!</h2>'
});
// valid
angular.module('myModule').directive('helloWorld', function() {
return {
template: '<h2>Hello World!</h2>',
link: function(){
}
};
});
This rule was introduced in eslint-plugin-angular 0.16.0