Skip to content

noUselessLabel

诊断类别:lint/complexity/noUselessLabel

¥Diagnostic Category: lint/complexity/noUselessLabel

自从:v1.0.0

¥Since: v1.0.0

来源:

¥Sources:

禁止不必要的标签。

¥Disallow unnecessary labels.

如果循环不包含嵌套循环或开关,则无需标记循环。

¥If a loop contains no nested loops or switches, labeling the loop is unnecessary.

¥Examples

¥Invalid

loop: 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

outer: while(a) {
while(b) {
break outer;
}
}

¥Related links