UNPKG

1.08 kBJavaScriptView Raw
1/**
2 * @fileoverview A rule to disallow negated left operands of the `in` operator
3 * @author Michael Ficarra
4 * @deprecated in ESLint v3.3.0
5 */
6
7"use strict";
8
9//------------------------------------------------------------------------------
10// Rule Definition
11//------------------------------------------------------------------------------
12
13module.exports = {
14 meta: {
15 docs: {
16 description: "disallow negating the left operand in `in` expressions",
17 category: "Possible Errors",
18 recommended: false,
19 replacedBy: ["no-unsafe-negation"],
20 url: "https://eslint.org/docs/rules/no-negated-in-lhs"
21 },
22 deprecated: true,
23
24 schema: []
25 },
26
27 create(context) {
28
29 return {
30
31 BinaryExpression(node) {
32 if (node.operator === "in" && node.left.type === "UnaryExpression" && node.left.operator === "!") {
33 context.report({ node, message: "The 'in' expression's left operand is negated." });
34 }
35 }
36 };
37
38 }
39};