diff options
Diffstat (limited to 'tools/eslint/lib/rules/no-negated-in-lhs.js')
-rw-r--r-- | tools/eslint/lib/rules/no-negated-in-lhs.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/eslint/lib/rules/no-negated-in-lhs.js b/tools/eslint/lib/rules/no-negated-in-lhs.js new file mode 100644 index 0000000000..75bdf73192 --- /dev/null +++ b/tools/eslint/lib/rules/no-negated-in-lhs.js @@ -0,0 +1,23 @@ +/** + * @fileoverview A rule to disallow negated left operands of the `in` operator + * @author Michael Ficarra + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = function(context) { + + return { + + "BinaryExpression": function(node) { + if (node.operator === "in" && node.left.type === "UnaryExpression" && node.left.operator === "!") { + context.report(node, "The `in` expression's left operand is negated"); + } + } + }; + +}; |