{"record":{"id":"426ddd3e313d1a31","repo":"oxc-project/oxc","slug":"missing-braces-in-case-clause","errorCode":null,"errorMessage":"Missing braces in case clause.","messagePattern":"Missing braces in case clause\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/switch_case_braces.rs","lineNumber":22,"sourceCode":"use oxc_span::{GetSpan, Span};\nuse schemars::JsonSchema;\nuse serde::{Deserialize, Serialize};\n\nuse crate::{\n    AstNode,\n    ast_util::get_preceding_indent_str,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn switch_case_braces_diagnostic_empty_clause(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unexpected braces in empty case clause.\")\n        .with_help(\"Remove braces in empty case clause.\")\n        .with_label(span)\n}\n\nfn switch_case_braces_diagnostic_missing_braces(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Missing braces in case clause.\")\n        .with_help(\"Add Braces for case clause.\")\n        .with_label(span)\n}\n\nfn switch_case_braces_diagnostic_unnecessary_braces(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unnecessary braces in case clause.\")\n        .with_help(\"Remove Braces for case clause.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Clone, Deserialize)]\npub struct SwitchCaseBraces(Box<SwitchCaseBracesConfig>);\n\nimpl Default for SwitchCaseBraces {\n    fn default() -> Self {\n        Self(Box::new(SwitchCaseBracesConfig::Always))\n    }\n}","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/switch_case_braces.rs#L4-L40","documentation":"Emitted by the unicorn/switch-case-braces rule when a `case` clause contains lexical declarations (`let`/`const`/`class`) but has no surrounding braces. Braces are required there so the declarations get their own block scope and cannot leak into the shared switch-block scope.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/switch_case_braces.rs:22 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wrap the case clause body in braces: `case 'a': { ... break; }`"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}