UNPKG

1.27 kBJavaScriptView Raw
1/**
2 * disallow use of internal angular properties prefixed with $$
3 *
4 * All scope's properties/methods starting with $$ are used internally by AngularJS.
5 * You should not use them directly.
6 * Exception can be allowed with this option: {allow:['$$watchers']}
7 *
8 * @version 0.1.0
9 * @category possibleError
10 * @sinceAngularVersion 1.x
11 */
12'use strict';
13
14module.exports = {
15 meta: {
16 schema: [
17 {
18 type: 'object',
19 properties: {
20 allow: {
21 type: 'array',
22 items: {
23 type: 'string'
24 }
25 }
26 },
27 additionalProperties: false
28 }
29 ]
30 },
31 create: function(context) {
32 var options = context.options[0] || {};
33 var allowed = options.allow || [];
34
35 function check(node, name) {
36 if (name.slice(0, 2) === '$$' && allowed.indexOf(name) < 0) {
37 context.report(node, 'Using $$-prefixed Angular objects/methods are not recommended', {});
38 }
39 }
40 return {
41
42 Identifier: function(node) {
43 check(node, node.name);
44 }
45 };
46 }
47};