{"record":{"id":"55efb8df13bc601c","repo":"oxc-project/oxc","slug":"don-t-use-process-exit","errorCode":null,"errorMessage":"Don't use `process.exit()`","messagePattern":"Don't use `process\\.exit\\(\\)`","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_process_exit.rs","lineNumber":9,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, ast_util::is_method_call, context::LintContext, rule::Rule};\n\nfn no_process_exit_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Don't use `process.exit()`\")\n        .with_help(\"Throw an error instead.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoProcessExit;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow all usage of `process.exit()`.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// `process.exit()` should generally only be used in command-line utilities. In all other\n    /// types of applications, the code should throw an error instead.\n    ///\n    /// ### Examples","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_process_exit.rs#L1-L27","documentation":"Lint diagnostic from unicorn/no-process-exit: process.exit() was called. It terminates immediately without unwinding, skipping pending async work, stdout flushes, and cleanup handlers, which corrupts long-running programs and CLI pipes.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_process_exit.rs:9 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Throw an error and let the top-level handler decide the exit code","Set process.exitCode and return/resolve normally so pending I/O can flush","Restructure control flow to reach the end of main instead of exiting mid-flight"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}