Skip to content

Latest commit

 

History

History
41 lines (31 loc) · 1.05 KB

File metadata and controls

41 lines (31 loc) · 1.05 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, that allows process.exit() to be called in files that start with a hashbang#!/usr/bin/env node. It also allows process.exit() to be called in process.on('<event>', func) event handlers and in files that imports worker_threads.

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