redline
LowError handlingexit-in-library

Exits the process

Exits the process. process.exit kills the whole process from library code.

This is how the comment reads inline, under the flagged line.

Why it matters

Exiting deep in a call stack skips cleanup, loses buffered logs and makes the code impossible to reuse or test.

What to do

Throw an error and let the entry point decide the exit code.

Examples

Flagged
if (!cfg) process.exit(1);
Better
if (!cfg) throw new Error("missing config");

What it catches

It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript, Python. Scope: Shipped code only. These cases are the rule's own tests: the first set must be flagged and the second must not.

Flagged

process.exit(1);

Left alone

src/cli.ts
process.exit(1);
src/app.py
sys.exit(main(sys.argv[1:]))

Research

`process.exit` or `sys.exit` in library code. It skips cleanup, loses buffered logs and makes the code hard to reuse or test.

  • no outside source yet

Turn it off or change it

In a config file for the CLI, or in the API's rules field:

{
  "rules": {
    "disable": [
      "exit-in-library"
    ],
    "severity": {
      "exit-in-library": "medium"
    }
  }
}

Read the source or report a false positive.