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 === 'string' || node.value === '[object String]')) {
|
21 | context.report(origin, 'You should use the angular.isString method', {});
|
22 | }
|
23 | }
|
24 |
|
25 | return {
|
26 |
|
27 | BinaryExpression: function(node) {
|
28 | if (node.operator === '===' || node.operator === '!==') {
|
29 | if (utils.isTypeOfStatement(node.left) || utils.isToStringStatement(node.left)) {
|
30 | recordError(node.right, node);
|
31 | } else if (utils.isTypeOfStatement(node.right) || utils.isToStringStatement(node.right)) {
|
32 | recordError(node.left, node);
|
33 | }
|
34 | }
|
35 | }
|
36 | };
|
37 | }
|
38 | };
|