useSingleCaseStatement
Ce contenu n’est pas encore disponible dans votre langue.
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.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-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 │