📝 Disallow process.exit().
💼 This rule is enabled in the following configs: ✅ recommended, ☑️ unopinionated.
This rule is an extension to ESLint's no-process-exit rule. Calling process.exit() abruptly terminates the process and can bypass normal error propagation and cleanup, so this rule restricts it to files with a hashbang, process event handlers, and files that statically load worker_threads.
This rule replaces ESLint's built-in no-process-exit rule, which Unicorn presets disable when this rule is enabled.
// ❌
process.exit(0);
// ✅
#!/usr/bin/env node
process.exit(0);// ✅
process.on('SIGINT', () => {
console.log('Got SIGINT');
process.exit(1);
});// ✅
import workerThreads from 'node:worker_threads';
try {
// Do something…
process.exit(0);
} catch (_) {
process.exit(1);
}