项目原始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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

no-new-require.js 931 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * @fileoverview Rule to disallow use of new operator with the `require` function
  3. * @author Wil Moore III
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Rule Definition
  8. //------------------------------------------------------------------------------
  9. module.exports = {
  10. meta: {
  11. docs: {
  12. description: "disallow `new` operators with calls to `require`",
  13. category: "Node.js and CommonJS",
  14. recommended: false,
  15. url: "https://eslint.org/docs/rules/no-new-require"
  16. },
  17. schema: []
  18. },
  19. create(context) {
  20. return {
  21. NewExpression(node) {
  22. if (node.callee.type === "Identifier" && node.callee.name === "require") {
  23. context.report({ node, message: "Unexpected use of new with require." });
  24. }
  25. }
  26. };
  27. }
  28. };