oxc-project/oxc · warning
`debugger` statement is not allowed
Error message
`debugger` statement is not allowed
What it means
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.
Source
Thrown at crates/oxc_linter/src/rules/eslint/no_debugger.rs:9
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use crate::{AstNode, ast_util::outermost_paren_parent, context::LintContext, rule::Rule};
fn no_debugger_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("`debugger` statement is not allowed").with_label(span)
}
const REMOVE_DEBUGGER: &str = "Remove the debugger statement";
#[derive(Debug, Default, Clone)]
pub struct NoDebugger;
declare_oxc_lint!(
/// ### What it does
///
/// Checks for usage of the `debugger` statement.
///
/// ### Why is this bad?
///
/// `debugger` statements do not affect functionality when a debugger isn't attached.
/// They're most commonly an accidental debugging leftover.
///
/// ### ExamplesView on GitHub (pinned to e1e7af627c)
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.
Example fix
// before
function calc(x) {
debugger;
return x * 2;
}
// after
function calc(x) {
return x * 2;
} Defensive patterns
Strategy: validation
Validate before calling
// run before oxlint in CI: fail on any debugger statement
const src = require('node:fs').readFileSync(file, 'utf8');
if (/^[ \t]*debugger\b/m.test(src)) throw new Error('debugger statement found'); Prevention
- 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.
When it happens
Trigger: 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; }`.
Common situations: 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.
Related errors
- Variables should not be deleted
- A regular expression literal can be confused with '/='.
- Duplicate class member: {member_name:?}
- Duplicate conditions in if-else-if chain
- Duplicate key '{key}'
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/cbcd739b95c7c931.
Report an issue: GitHub.