{"record":{"id":"2afa99a8acd4821a","repo":"oxc-project/oxc","slug":"found-a-comment-that-would-permit-fallthrough-but","errorCode":null,"errorMessage":"Found a comment that would permit fallthrough, but case cannot fall through.","messagePattern":"Found a comment that would permit fallthrough, but case cannot fall through\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/no_fallthrough.rs","lineNumber":44,"sourceCode":"    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.\n    #[serde(default, deserialize_with = \"deserialize_comment_pattern\")]\n    comment_pattern: Option<Regex>,\n    /// Whether to allow empty case clauses to fall through.\n    allow_empty_case: bool,\n    /// Whether to report unused fallthrough comments.\n    report_unused_fallthrough_comment: bool,","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_fallthrough.rs#L26-L62","documentation":"The inverse diagnostic of oxlint's no-fallthrough rule: a case contains a comment that matches the fallthrough pattern (e.g. '// falls through'), but the case cannot actually fall through because it ends with break/return/throw or is the last clause. The comment is dead and misleading, so the rule reports it and asks you to remove it or make the fallthrough real.","triggerScenarios":"case 2: flush(); // falls through followed by break; on the next line; a last case or default: ending with a fallthrough comment; a return added above an old fallthrough comment during a bugfix, leaving the marker behind.","commonSituations":"A bugfix adds a return/break but keeps the old marker; cases are reordered so a marked case becomes terminal; fallthrough comments are copy-pasted across cases during merges.","solutions":["Delete the stale // falls through comment.","If fallthrough was intended, remove the break/return that prevents it.","Reword the comment so it no longer matches commentPattern when it describes something else."],"exampleFix":"// before\ncase 2:\n  flush();\n  // falls through\n  break;\n\n// after\ncase 2:\n  flush();\n  break;","handlingStrategy":"validation","validationCode":"npx oxlint -A all -D no-fallthrough src/  # catches unused fallthrough comments too","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding a terminator to a case, delete its fallthrough comment in the same commit.","Never write 'falls through' next to code that already ends in return/throw/break.","Treat this diagnostic as a doc-rot signal during code review."],"tags":["eslint","oxlint","lint","switch","comments"],"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-14T05:17:10.506Z"}