-
Notifications
You must be signed in to change notification settings - Fork 131
/
no-private-call.js
50 lines (47 loc) · 1.38 KB
/
no-private-call.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
39
40
41
42
43
44
45
46
47
48
49
50
/**
* disallow use of internal angular properties prefixed with $$
*
* All scope's properties/methods starting with $$ are used internally by AngularJS.
* You should not use them directly.
* Exception can be allowed with this option: {allow:['$$watchers']}
*
* @version 0.1.0
* @category possibleError
* @sinceAngularVersion 1.x
*/
'use strict';
module.exports = {
meta: {
docs: {
url: 'https://github.com/Gillespie59/eslint-plugin-angular/blob/master/docs/rules/no-private-call.md'
},
schema: [
{
type: 'object',
properties: {
allow: {
type: 'array',
items: {
type: 'string'
}
}
},
additionalProperties: false
}
]
},
create: function(context) {
var options = context.options[0] || {};
var allowed = options.allow || [];
function check(node, name) {
if (name.slice(0, 2) === '$$' && allowed.indexOf(name) < 0) {
context.report(node, 'Using $$-prefixed Angular objects/methods are not recommended', {});
}
}
return {
Identifier: function(node) {
check(node, node.name);
}
};
}
};