no-process-exit.js 975 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * @author Nicholas C. Zakas
  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 the use of `process.exit()`",
  11. category: "Possible Errors",
  12. recommended: false,
  13. url:
  14. "https://github.com/mysticatea/eslint-plugin-node/blob/v11.1.0/docs/rules/no-process-exit.md",
  15. },
  16. fixable: null,
  17. schema: [],
  18. messages: {
  19. noProcessExit: "Don't use process.exit(); throw an error instead.",
  20. },
  21. },
  22. create(context) {
  23. return {
  24. "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']"(
  25. node
  26. ) {
  27. context.report({
  28. node: node.parent,
  29. messageId: "noProcessExit",
  30. })
  31. },
  32. }
  33. },
  34. }