项目原始demo,不改动
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
Це архівний репозитарій. Ви можете переглядати і клонувати файли, але не можете робити пуш або відкривати питання/запити.
 
 
 
 

45 рядки
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. };