Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 1.24 KB

process-exit-as-throw.md

File metadata and controls

38 lines (26 loc) · 1.24 KB

Require that process.exit() expressions use the same code path as throw (n/process-exit-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