close

no-process-exit

Unreleased

Configuration

rslint.config.ts
import { defineConfig } from '@rslint/core';

export default defineConfig([
  {
    plugins: ['node'],
    rules: {
      'node/no-process-exit': 'error',
    },
  },
]);

Rule Details

Disallows the use of process.exit().

The process.exit() method in Node.js is used to force the process to exit as quickly as possible even if there are still asynchronous operations pending that have not yet completed fully, including I/O operations to process.stdout and process.stderr.

In most cases, it is not necessary to explicitly call process.exit(). The Node.js process will exit on its own if there is no additional work pending in the event loop. Calling process.exit() will force the process to exit as quickly as possible even if there are still asynchronous operations pending.

Examples of incorrect code for this rule:

process.exit(1);
process.exit(0);

Examples of correct code for this rule:

throw new Error("an error occurred");

Original Documentation