no-process-exit.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * @fileoverview Disallow the use of process.exit()
  3. * @author Nicholas C. Zakas
  4. * @deprecated in ESLint v7.0.0
  5. */
  6. "use strict";
  7. //------------------------------------------------------------------------------
  8. // Rule Definition
  9. //------------------------------------------------------------------------------
  10. /** @type {import('../shared/types').Rule} */
  11. module.exports = {
  12. meta: {
  13. deprecated: true,
  14. replacedBy: [],
  15. type: "suggestion",
  16. docs: {
  17. description: "Disallow the use of `process.exit()`",
  18. recommended: false,
  19. url: "https://eslint.org/docs/rules/no-process-exit"
  20. },
  21. schema: [],
  22. messages: {
  23. noProcessExit: "Don't use process.exit(); throw an error instead."
  24. }
  25. },
  26. create(context) {
  27. //--------------------------------------------------------------------------
  28. // Public
  29. //--------------------------------------------------------------------------
  30. return {
  31. "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']"(node) {
  32. context.report({ node: node.parent, messageId: "noProcessExit" });
  33. }
  34. };
  35. }
  36. };