Skip to content

Latest commit

 

History

History
64 lines (41 loc) · 2.36 KB

service-name.md

File metadata and controls

64 lines (41 loc) · 2.36 KB

service-name - require and specify a prefix for all service names

All your services should have a name starting with the parameter you can define in your config object. The second parameter can be a Regexp wrapped in quotes. You can not prefix your services by "$" (reserved keyword for AngularJS services) ("service-name": [2, "ng"])

If the oldBehavior is true (default value), this rule will check the name of all services defined with the different methods provided by the framework : provider, service, factory, ... If this parameter is false, only services defined with the service method will be checked.

Rule based on Angular 1.x

Styleguide Reference

Examples

The following patterns are not considered problems when configured "prefix" and {"oldBehavior":false}:

/*eslint angular/service-name: [2,"prefix",{"oldBehavior":false}]*/

// valid
angular.module('myModule').service('prefixService', function () {
    // ...
});

The following patterns are considered problems when configured "/^xyz/" and {"oldBehavior":false}:

/*eslint angular/service-name: [2,"/^xyz/",{"oldBehavior":false}]*/

// invalid
angular.module('myModule').service('otherService', function () {
    // ...
}); // error: The otherService service should follow this pattern: /^xyz/

The following patterns are not considered problems when configured "/^xyz/" and {"oldBehavior":false}:

/*eslint angular/service-name: [2,"/^xyz/",{"oldBehavior":false}]*/

// valid
angular.module('myModule').service('xyzService', function () {
    // ...
});

The following patterns are considered problems when configured "xyz" and {"oldBehavior":false}:

/*eslint angular/service-name: [2,"xyz",{"oldBehavior":false}]*/

// invalid
angular.module('myModule').service('myService', function () {
    // ...
}); // error: The myService service should be prefixed by xyz

Version

This rule was introduced in eslint-plugin-angular 0.1.0

Links