Skip to content

Latest commit

Β 

History

History
40 lines (27 loc) Β· 1.26 KB

File metadata and controls

40 lines (27 loc) Β· 1.26 KB

n/process-exit-as-throw

πŸ“ Require that process.exit() expressions use the same code path as throw.

πŸ’Ό This rule is enabled in the following configs: 🟒 recommended-module, βœ… recommended-script.

πŸ“– Rule Details

function foo(a) {
    if (a) {
        return new Bar();
    } else {
        process.exit(1);
    }
}

ESLint does not mark code after process.exit() calls as unreachable like it does with throw and return expressions, meaning rules like consistent-return will still warn.

This rule overrides the default code path analyzer so that code after process.exit() calls are marked as unreachable, meaning code like the above will not trigger warnings.

This rule itself never warn code.

πŸ“š Related Rules

πŸ”Ž Implementation