项目原始demo,不改动
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.
Deze repo is gearchiveerd. U kunt bestanden bekijken en het klonen, maar niet pushen of problemen/pull-requests openen.

no-new-object.js 894 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * @fileoverview A rule to disallow calls to the Object constructor
  3. * @author Matt DuVall <http://www.mattduvall.com/>
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Rule Definition
  8. //------------------------------------------------------------------------------
  9. module.exports = {
  10. meta: {
  11. docs: {
  12. description: "disallow `Object` constructors",
  13. category: "Stylistic Issues",
  14. recommended: false,
  15. url: "https://eslint.org/docs/rules/no-new-object"
  16. },
  17. schema: []
  18. },
  19. create(context) {
  20. return {
  21. NewExpression(node) {
  22. if (node.callee.name === "Object") {
  23. context.report({ node, message: "The object literal notation {} is preferrable." });
  24. }
  25. }
  26. };
  27. }
  28. };