Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 1.27 KB

process-exit-as-throw.md

File metadata and controls

38 lines (26 loc) · 1.27 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: ☑️ flat/recommended, 🟢 flat/recommended-module, ✅ flat/recommended-script, ☑️ recommended, 🟢 recommended-module, ✅ recommended-script.

📖 Rule Details

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

ESLint does not address process.exit() as stop in code path analysis, then consistent-return rule will warn the above code.

If you turn this rule on, ESLint comes to address process.exit() as throw in code path analysis. So, above code will get expected code path.

This rule itself never warn code.

📚 Related Rules

🔎 Implementation