1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | "use strict";
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | module.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 | };
|