跳转到内容

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;
}
}