Skip to content
You are currently reading docs for v1.x. Go to the latest docs if you are using newer version.

useSingleCaseStatement

Diagnostic Category: lint/style/useSingleCaseStatement

Since: v1.0.0

Enforces switch clauses have a single statement, emits a quick fix wrapping the statements in a block.

switch (foo) {
case true:
case false:
let foo = '';
foo;
}
code-block.js:4:9 lint/style/useSingleCaseStatement  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ A switch clause should only have a single statement.

2 │ case true:
3 │ case false:
> 4 │ let foo = ”;
│ ^^^^^^^^^^^^^
> 5 │ foo;
│ ^^^^
6 │ }
7 │

ℹ Unsafe fix: Wrap the statements in a block.

1 1 │ switch (foo) {
2 2 │ case true:
3 │ - ····case·false:
3 │ + ····case·false:·{
4 4 │ let foo = ”;
5 │ - ········foo;
5 │ + ········foo;
6 │ + ····}
6 7 │ }
7 8 │

switch (foo) {
case true:
case false: {
let foo = '';
foo;
}
}
biome.json
{
"linter": {
"rules": {
"style": {
"useSingleCaseStatement": "error"
}
}
}
}