项目原始demo,不改动
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Repozitorijs ir arhivēts. Tam var aplūkot failus un to var klonēt, bet nevar iesūtīt jaunas izmaiņas, kā arī atvērt jaunas problēmas/izmaiņu pieprasījumus.
 
 
 
 

45 rindas
1.2 KiB

  1. /**
  2. * @fileoverview Rule to disallow use of the new operator with the `Symbol` object
  3. * @author Alberto Rodríguez
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Rule Definition
  8. //------------------------------------------------------------------------------
  9. module.exports = {
  10. meta: {
  11. docs: {
  12. description: "disallow `new` operators with the `Symbol` object",
  13. category: "ECMAScript 6",
  14. recommended: true,
  15. url: "https://eslint.org/docs/rules/no-new-symbol"
  16. },
  17. schema: []
  18. },
  19. create(context) {
  20. return {
  21. "Program:exit"() {
  22. const globalScope = context.getScope();
  23. const variable = globalScope.set.get("Symbol");
  24. if (variable && variable.defs.length === 0) {
  25. variable.references.forEach(ref => {
  26. const node = ref.identifier;
  27. if (node.parent && node.parent.type === "NewExpression") {
  28. context.report({ node, message: "`Symbol` cannot be called as a constructor." });
  29. }
  30. });
  31. }
  32. }
  33. };
  34. }
  35. };