no-process-exit.js 956 B

1234567891011121314151617181920212223242526272829303132333435
  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: "https://github.com/weiran-zsd/eslint-plugin-node/blob/HEAD/docs/rules/no-process-exit.md",
  14. },
  15. fixable: null,
  16. schema: [],
  17. messages: {
  18. noProcessExit: "Don't use process.exit(); throw an error instead.",
  19. },
  20. },
  21. create(context) {
  22. return {
  23. "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']"(
  24. node
  25. ) {
  26. context.report({
  27. node: node.parent,
  28. messageId: "noProcessExit",
  29. })
  30. },
  31. }
  32. },
  33. }