oxc-project/oxc · error · OxcDiagnostic
Unexpected braces in empty case clause.
Error message
Unexpected braces in empty case clause.
What it means
Emitted by the unicorn/switch-case-braces rule at an empty `case` (or `default`) clause wrapped in braces, e.g. `case 'a': {} break;`. Braces around an empty clause are pointless noise, so the rule asks for their removal.
Source
Thrown at crates/oxc_linter/src/rules/unicorn/switch_case_braces.rs:16
use oxc_ast::{AstKind, ast::Statement};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::{
AstNode,
ast_util::get_preceding_indent_str,
context::LintContext,
rule::{DefaultRuleConfig, Rule},
};
fn switch_case_braces_diagnostic_empty_clause(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unexpected braces in empty case clause.")
.with_help("Remove braces in empty case clause.")
.with_label(span)
}
fn switch_case_braces_diagnostic_missing_braces(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Missing braces in case clause.")
.with_help("Add Braces for case clause.")
.with_label(span)
}
fn switch_case_braces_diagnostic_unnecessary_braces(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Unnecessary braces in case clause.")
.with_help("Remove Braces for case clause.")
.with_label(span)
}
#[derive(Debug, Clone, Deserialize)]
pub struct SwitchCaseBraces(Box<SwitchCaseBracesConfig>);View on GitHub (pinned to e1e7af627c)
Solutions
- Delete the braces from the empty case clause
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/switch_case_braces.rs:16 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/aaec897548d1641e.
Report an issue: GitHub.