forked from EmmanuelDemey/eslint-plugin-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
no-service-method.js
32 lines (29 loc) · 885 Bytes
/
no-service-method.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* use `factory()` instead of `service()`
*
* You should prefer the factory() method instead of service()
*
* @styleguideReference {johnpapa} `y040` Services - Singletons
* @version 0.1.0
* @category conventions
* @sinceAngularVersion 1.x
*/
'use strict';
var utils = require('./utils/utils');
module.exports = {
meta: {
docs: {
url: 'https://github.com/Gillespie59/eslint-plugin-angular/blob/master/docs/rules/no-service-method.md'
},
schema: []
},
create: function(context) {
return {
CallExpression: function(node) {
if (utils.isAngularComponent(node) && node.callee.property && node.callee.property.name === 'service') {
context.report(node, 'You should prefer the factory() method instead of service()', {});
}
}
};
}
};