UNPKG

877 BJavaScriptView Raw
1/**
2 * Avoid mistakes when naming methods defined on the scope object
3 *
4 * For example, you want to use $scope.$watch instead of $scope.watch
5 *
6 * @version 2.3.0
7 * @category possibleError
8 * @sinceAngularVersion 1.x
9 */
10'use strict';
11
12const bad = ['new', 'watch', 'watchGroup', 'watchCollection',
13 'digest', 'destroy', 'eval', 'evalAsync', 'apply',
14 'applyAsync', 'on', 'emit', 'broadcast'];
15
16module.exports = {
17 meta: {
18 schema: [ ]
19 },
20 create: function(context) {
21 function check(node, name) {
22 if (bad.indexOf(name) >= 0) {
23 context.report(node, `The ${name} method should be replaced by $${name}, or you should rename it in order to avoid confusions`, {});
24 }
25 }
26 return {
27
28 Identifier: function(node) {
29 check(node, node.name);
30 }
31 };
32 }
33};