no-new-require.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * @author Wil Moore III
  3. * See LICENSE file in root directory for full license.
  4. */
  5. "use strict"
  6. module.exports = {
  7. meta: {
  8. type: "suggestion",
  9. docs: {
  10. description: "disallow `new` operators with calls to `require`",
  11. category: "Possible Errors",
  12. recommended: false,
  13. url:
  14. "https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/no-new-require.md",
  15. },
  16. fixable: null,
  17. schema: [],
  18. messages: {
  19. noNewRequire: "Unexpected use of new with require.",
  20. },
  21. },
  22. create(context) {
  23. return {
  24. NewExpression(node) {
  25. if (
  26. node.callee.type === "Identifier" &&
  27. node.callee.name === "require"
  28. ) {
  29. context.report({
  30. node,
  31. messageId: "noNewRequire",
  32. })
  33. }
  34. },
  35. }
  36. },
  37. }