2 * @fileoverview Rule to flag comparison where left part is the same as the right
9 //------------------------------------------------------------------------------
11 //------------------------------------------------------------------------------
13 module.exports = function(context) {
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.");