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-caller.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * @fileoverview Rule to flag use of arguments.callee and arguments.caller.
  3. * @author Nicholas C. Zakas
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Rule Definition
  8. //------------------------------------------------------------------------------
  9. module.exports = {
  10. meta: {
  11. type: "suggestion",
  12. docs: {
  13. description: "disallow the use of `arguments.caller` or `arguments.callee`",
  14. category: "Best Practices",
  15. recommended: false,
  16. url: "https://eslint.org/docs/rules/no-caller"
  17. },
  18. schema: [],
  19. messages: {
  20. unexpected: "Avoid arguments.{{prop}}."
  21. }
  22. },
  23. create(context) {
  24. return {
  25. MemberExpression(node) {
  26. const objectName = node.object.name,
  27. propertyName = node.property.name;
  28. if (objectName === "arguments" && !node.computed && propertyName && propertyName.match(/^calle[er]$/)) {
  29. context.report({ node, messageId: "unexpected", data: { prop: propertyName } });
  30. }
  31. }
  32. };
  33. }
  34. };