no-negated-in-lhs.js 1.2 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. /** @type {import('../shared/types').Rule} */
  11. module.exports = {
  12. meta: {
  13. type: "problem",
  14. docs: {
  15. description: "Disallow negating the left operand in `in` expressions",
  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. };