Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

no-obj-calls.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * @fileoverview Rule to flag use of an object property of the global object (Math and JSON) as a function
  3. * @author James Allardice
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Rule Definition
  8. //------------------------------------------------------------------------------
  9. module.exports = {
  10. meta: {
  11. type: "problem",
  12. docs: {
  13. description: "disallow calling global object properties as functions",
  14. category: "Possible Errors",
  15. recommended: true,
  16. url: "https://eslint.org/docs/rules/no-obj-calls"
  17. },
  18. schema: []
  19. },
  20. create(context) {
  21. return {
  22. CallExpression(node) {
  23. if (node.callee.type === "Identifier") {
  24. const name = node.callee.name;
  25. if (name === "Math" || name === "JSON" || name === "Reflect") {
  26. context.report({ node, message: "'{{name}}' is not a function.", data: { name } });
  27. }
  28. }
  29. }
  30. };
  31. }
  32. };