Debugger Statement In Source

ID

javascript.no_debugger

Severity

info

Remediation Complexity

medium

Remediation Risk

low

Remediation Effort

medium

Resource

Code Smell

Language

JavaScript

Tags

best-practice, code-style

Description

Reports debugger; statements left in JavaScript / TypeScript source. The debugger statement is a runtime breakpoint: when a JavaScript engine encounters it and developer tools are attached, execution halts. It is intended for ad-hoc local debugging only.

Rationale

A committed debugger; statement is a code smell:

  • It pauses execution unexpectedly for any developer who happens to have devtools open — including during QA, demos, or production triage from a workstation.

  • Many editor / IDE auto-formatters preserve it; lint configurations sometimes don’t catch it before commit.

  • Its presence usually indicates that a developer’s debugging session was checked in by accident.

function processOrder(orderId) {
  debugger; // bad - pauses execution if devtools are open
  return fetchOrder(orderId);
}

Remediation

Remove the debugger; statement before committing. If you need a persistent inspection point in development builds, gate it behind an environment check or use your editor’s breakpoint tooling instead.

function processOrder(orderId) {
  return fetchOrder(orderId);
}