{"record":{"id":"c8ba90fabb6acbb6","repo":"oxc-project/oxc","slug":"expected-a-break-statement-before-default","errorCode":null,"errorMessage":"Expected a `break` statement before `default`.","messagePattern":"Expected a `break` statement before `default`\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/eslint/no_fallthrough.rs","lineNumber":38,"sourceCode":"};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn no_fallthrough_case_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Expected a `break` statement before `case`.\")\n        .with_help(\"Use a `break` statement to prevent fallthrough, or add a comment to indicate intentional fallthrough.\")\n        .with_label(span)\n}\n\nfn no_fallthrough_default_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Expected a `break` statement before `default`.\")\n        .with_help(\"Use a `break` statement to prevent fallthrough, or add a comment to indicate intentional fallthrough.\")\n        .with_label(span)\n}\n\nfn no_unused_fallthrough_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\n        \"Found a comment that would permit fallthrough, but case cannot fall through.\",\n    )\n    .with_help(\n        \"Remove the fallthrough comment or add code that allows fallthrough (e.g. remove `break`).\",\n    )\n    .with_label(span)\n}\n\n#[derive(Default, Debug, Clone, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\nstruct NoFallthroughConfig {\n    /// Custom regex pattern to match fallthrough comments.","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_fallthrough.rs#L20-L56","documentation":"The same oxlint no-fallthrough rule, but the clause being fallen into is default: instead of another case:. JavaScript lets the case above default: omit a terminator and execute the default body, which readers rarely expect, so the rule flags it identically. A matching fallthrough comment suppresses the report just like case-to-case fallthrough.","triggerScenarios":"case 'sm': with no terminator directly above default:; a case falling into default: where the default also performs cleanup; a new case inserted above default: without a break during a feature branch.","commonSituations":"Cases reordered so default: ends up below a terminator-less case; if/else chains converted to switches during refactors; default moved to the middle of the switch without auditing terminators.","solutions":["Add break; at the end of the case above default:.","Move default: to the last position and make the preceding case terminate.","Add // falls through if falling into default is intentional."],"exampleFix":"// before\nswitch (size) {\n  case 'sm':\n    scale = 0.5;\n  default:\n    scale = 1;\n}\n\n// after\nswitch (size) {\n  case 'sm':\n    scale = 0.5;\n    break;\n  default:\n    scale = 1;\n}","handlingStrategy":"validation","validationCode":"npx oxlint -A all -D no-fallthrough src/  # fail the build on fallthrough only","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat default: like any case when auditing terminators.","Put default: last and make sure the case above it terminates.","Use fallthrough comments only when fallthrough is real."],"tags":["eslint","oxlint","lint","switch","control-flow"],"backgroundTag":"switch-case-fallthrough","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"}