no-negated-in-lhs.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. "use strict";
  7. //------------------------------------------------------------------------------
  8. // Rule Definition
  9. //------------------------------------------------------------------------------
  10. module.exports = {
  11. meta: {
  12. type: "problem",
  13. docs: {
  14. description: "disallow negating the left operand in `in` expressions",
  15. category: "Possible Errors",
  16. recommended: false,
  17. url: "https://eslint.org/docs/rules/no-negated-in-lhs"
  18. },
  19. replacedBy: ["no-unsafe-negation"],
  20. deprecated: true,
  21. schema: [],
  22. messages: {
  23. negatedLHS: "The 'in' expression's left operand is negated."
  24. }
  25. },
  26. create(context) {
  27. return {
  28. BinaryExpression(node) {
  29. if (node.operator === "in" && node.left.type === "UnaryExpression" && node.left.operator === "!") {
  30. context.report({ node, messageId: "negatedLHS" });
  31. }
  32. }
  33. };
  34. }
  35. };