Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 755 Bytes

no-process-exit.md

File metadata and controls

36 lines (26 loc) · 755 Bytes

Disallow process.exit()

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.

Fail

process.exit(0);

Pass

#!/usr/bin/env node
process.exit(0);
process.on('SIGINT', () => {
    console.log('Got SIGINT');
    process.exit(1);
});
import workerThreads from 'worker_threads';

try {
	// Do something…
	process.exit(0);
} catch (_) {
	process.exit(1);
}