forked from EmmanuelDemey/eslint-plugin-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interval-service.js
38 lines (34 loc) · 1.12 KB
/
interval-service.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
33
34
35
36
37
38
/**
* use `$interval` instead of `setInterval`
*
* Instead of the default setInterval function, you should use the AngularJS wrapper service $interval
*
* @styleguideReference {johnpapa} `y181` Angular $ Wrapper Services - $timeout and $interval
* @version 0.1.0
* @category angularWrapper
* @sinceAngularVersion 1.x
*/
'use strict';
module.exports = {
meta: {
docs: {
url: 'https://github.com/Gillespie59/eslint-plugin-angular/blob/master/docs/rules/interval-service.md'
},
schema: []
},
create: function(context) {
var message = 'You should use the $interval service instead of the default window.setInterval method';
return {
MemberExpression: function(node) {
if (node.object.name === 'window' && node.property.name === 'setInterval') {
context.report(node, message, {});
}
},
CallExpression: function(node) {
if (node.callee.name === 'setInterval') {
context.report(node, message, {});
}
}
};
}
};