noConfusingLabels
Este conteúdo não está disponível em sua língua ainda.
Diagnostic Category: lint/suspicious/noConfusingLabels
Since: v1.0.0
Sources:
- Inspired from:
no-labels
Disallow labeled statements that are not loops.
Labeled statements in JavaScript are used in conjunction with break
and continue
to control flow around multiple loops.
Their use for other statements is suspicious and unfamiliar.
The rule ignores reactive Svelte statements in Svelte components.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:1:1 lint/suspicious/noConfusingLabels ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Unexpected label.
> 1 │ label: f();
│ ^^^^^
2 │
ℹ Only loops should be labeled.
The use of labels for other statements is suspicious and unfamiliar.
code-block.js:1:1 lint/suspicious/noConfusingLabels ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Unexpected label.
> 1 │ label: {
│ ^^^^^
2 │ f();
3 │ break label;
ℹ Only loops should be labeled.
The use of labels for other statements is suspicious and unfamiliar.
code-block.js:1:1 lint/suspicious/noConfusingLabels ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Unexpected label.
> 1 │ label: if (a) {
│ ^^^^^
2 │ f()
3 │ break label;
ℹ Only loops should be labeled.
The use of labels for other statements is suspicious and unfamiliar.
code-block.js:1:1 lint/suspicious/noConfusingLabels ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Unexpected label.
> 1 │ label: switch (a) {
│ ^^^^^
2 │ case 0:
3 │ break label;
ℹ Only loops should be labeled.
The use of labels for other statements is suspicious and unfamiliar.