1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 | var utils = require('./utils/utils');
|
13 |
|
14 | module.exports = {
|
15 | meta: {
|
16 | schema: []
|
17 | },
|
18 | create: function(context) {
|
19 | function recordError(node, origin) {
|
20 | if (node.type === 'Literal' && node.value === '[object Array]') {
|
21 | context.report(origin, 'You should use the angular.isArray method', {});
|
22 | }
|
23 | }
|
24 |
|
25 | return {
|
26 | MemberExpression: function(node) {
|
27 | if (node.object.name === 'Array' && node.property.name === 'isArray') {
|
28 | context.report(node, 'You should use the angular.isArray method', {});
|
29 | }
|
30 | },
|
31 | BinaryExpression: function(node) {
|
32 | if (node.operator === '===' || node.operator === '!==') {
|
33 | if (utils.isTypeOfStatement(node.left) || utils.isToStringStatement(node.left)) {
|
34 | recordError(node.right, node);
|
35 | } else if (utils.isTypeOfStatement(node.right) || utils.isToStringStatement(node.right)) {
|
36 | recordError(node.left, node);
|
37 | }
|
38 | }
|
39 | }
|
40 | };
|
41 | }
|
42 | };
|