no-service-method - use factory() instead of service()

February 26, 2018 ยท View on GitHub

You should prefer the factory() method instead of service()

Rule based on Angular 1.x

Styleguide Reference

Examples

The following patterns are considered problems;

/*eslint angular/no-service-method: 2*/

// invalid
angular.module('myModule').service('myService', function() {
    // ...
}); // error: You should prefer the factory() method instead of service()

The following patterns are not considered problems;

/*eslint angular/no-service-method: 2*/

// valid
angular.module('myModule').factory('myService', function () {
    // ...
});

// valid
angular.module('myModule').value('someValue', {
    // ...
});

Version

This rule was introduced in eslint-plugin-angular 0.1.0