noUselessLabel
このコンテンツはまだ日本語訳がありません。
Diagnostic Category: lint/complexity/noUselessLabel
Since: v1.0.0
Sources:
- Same as:
no-extra-label
Description
Section titled DescriptionDisallow unnecessary labels.
If a loop contains no nested loops or switches, labeling the loop is unnecessary.
Examples
Section titled ExamplesInvalid
Section titled Invalidloop: while(a) { break loop;}
code-block.js:2:11 lint/complexity/noUselessLabel FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Unnecessary label.
1 │ loop: while(a) {
> 2 │ break loop;
│ ^^^^
3 │ }
4 │
ℹ Safe fix: Remove the unnecessary label.
You can achieve the same result without the label.
2 │ ····break·loop;
│ -----
Valid
Section titled Validouter: while(a) { while(b) { break outer; }}
How to configure
Section titled How to configure{ "linter": { "rules": { "complexity": { "noUselessLabel": "error" } } }}