1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | "use strict";
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | module.exports = function(context) {
|
14 |
|
15 | return {
|
16 |
|
17 | "BinaryExpression": function(node) {
|
18 | var operators = ["===", "==", "!==", "!=", ">", "<", ">=", "<="];
|
19 | if (operators.indexOf(node.operator) > -1 &&
|
20 | (node.left.type === "Identifier" && node.right.type === "Identifier" && node.left.name === node.right.name ||
|
21 | node.left.type === "Literal" && node.right.type === "Literal" && node.left.value === node.right.value)) {
|
22 | context.report(node, "Comparing to itself is potentially pointless.");
|
23 | }
|
24 | }
|
25 | };
|
26 |
|
27 | };
|
28 |
|
29 | module.exports.schema = [];
|