no-proto.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @fileoverview Rule to flag usage of __proto__ property
  3. * @author Ilya Volodin
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Requirements
  8. //------------------------------------------------------------------------------
  9. const { getStaticPropertyName } = require("./utils/ast-utils");
  10. //------------------------------------------------------------------------------
  11. // Rule Definition
  12. //------------------------------------------------------------------------------
  13. module.exports = {
  14. meta: {
  15. type: "suggestion",
  16. docs: {
  17. description: "disallow the use of the `__proto__` property",
  18. category: "Best Practices",
  19. recommended: false,
  20. url: "https://eslint.org/docs/rules/no-proto"
  21. },
  22. schema: [],
  23. messages: {
  24. unexpectedProto: "The '__proto__' property is deprecated."
  25. }
  26. },
  27. create(context) {
  28. return {
  29. MemberExpression(node) {
  30. if (getStaticPropertyName(node) === "__proto__") {
  31. context.report({ node, messageId: "unexpectedProto" });
  32. }
  33. }
  34. };
  35. }
  36. };