Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.21 KB

no-process-exit.md

File metadata and controls

45 lines (33 loc) · 1.21 KB

no-process-exit

📝 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.

Replacement for ESLint no-process-exit

This rule replaces ESLint's built-in no-process-exit rule, which Unicorn presets disable when this rule is enabled.

Examples

// ❌
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);
}