{"record":{"id":"cbcd739b95c7c931","repo":"oxc-project/oxc","slug":"debugger-statement-is-not-allowed","errorCode":null,"errorMessage":"`debugger` statement is not allowed","messagePattern":"`debugger` statement is not allowed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/no_debugger.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::outermost_paren_parent, context::LintContext, rule::Rule};\n\nfn no_debugger_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"`debugger` statement is not allowed\").with_label(span)\n}\n\nconst REMOVE_DEBUGGER: &str = \"Remove the debugger statement\";\n\n#[derive(Debug, Default, Clone)]\npub struct NoDebugger;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Checks for usage of the `debugger` statement.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// `debugger` statements do not affect functionality when a debugger isn't attached.\n    /// They're most commonly an accidental debugging leftover.\n    ///\n    /// ### Examples","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_debugger.rs#L1-L27","documentation":"This diagnostic comes from the `no_debugger` rule in oxlint, the Oxc linter. It is a port of the ESLint rule with the same name. The rule reports every `debugger` statement it finds during the AST walk. A `debugger` statement halts execution only when a debugger is attached, and it must not ship in production code. The report is a warning with a label on the statement span.","triggerScenarios":"Any `debugger;` statement in a linted JavaScript or TypeScript file. The rule matches the `Debugger` node during statement traversal. Typical input: `function f() { debugger; return 1; }`.","commonSituations":"A developer sets a breakpoint while debugging in an IDE, then commits without removing it. CI runs oxlint with the recommended rule set, where `no_debugger` is active, so the report fails the build. Old files with leftover `debugger` lines trigger the same report after a project adopts oxlint.","solutions":["Delete the `debugger;` statement.","Replace it with `breakpoint()` from the `debug` npm package, which stays inert in production.","If you must keep it, add `// oxlint-disable-next-line no-debugger` on the line above.","Turn the rule off in .oxlintrc.json under `rules` for files where it is expected."],"exampleFix":"// before\nfunction calc(x) {\n  debugger;\n  return x * 2;\n}\n\n// after\nfunction calc(x) {\n  return x * 2;\n}","handlingStrategy":"validation","validationCode":"// run before oxlint in CI: fail on any debugger statement\nconst src = require('node:fs').readFileSync(file, 'utf8');\nif (/^[ \\t]*debugger\\b/m.test(src)) throw new Error('debugger statement found');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clear all breakpoints before you stage a commit.","Run oxlint in a pre-commit hook (lint-staged) so a leftover debugger blocks the commit.","Run `oxlint --deny-warnings` in CI to make warnings blocking."],"tags":["javascript","eslint","lint","debugging"],"backgroundTag":"lint-debugger-statement","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}