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