UNPKG

997 BJavaScriptView 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: true,
19 replacedBy: ["no-unsafe-negation"]
20 },
21 deprecated: true,
22
23 schema: []
24 },
25
26 create(context) {
27
28 return {
29
30 BinaryExpression(node) {
31 if (node.operator === "in" && node.left.type === "UnaryExpression" && node.left.operator === "!") {
32 context.report(node, "The 'in' expression's left operand is negated.");
33 }
34 }
35 };
36
37 }
38};