项目原始demo,不改动
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
Dieses Repo ist archiviert. Du kannst Dateien sehen und es klonen, kannst aber nicht pushen oder Issues/Pull-Requests öffnen.
 
 
 
 

45 Zeilen
1.1 KiB

  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. docs: {
  12. description: "disallow the use of `arguments.caller` or `arguments.callee`",
  13. category: "Best Practices",
  14. recommended: false,
  15. url: "https://eslint.org/docs/rules/no-caller"
  16. },
  17. schema: [],
  18. messages: {
  19. unexpected: "Avoid arguments.{{prop}}."
  20. }
  21. },
  22. create(context) {
  23. return {
  24. MemberExpression(node) {
  25. const objectName = node.object.name,
  26. propertyName = node.property.name;
  27. if (objectName === "arguments" && !node.computed && propertyName && propertyName.match(/^calle[er]$/)) {
  28. context.report({ node, messageId: "unexpected", data: { prop: propertyName } });
  29. }
  30. }
  31. };
  32. }
  33. };