🔧 fixable
Disallows continue label;
and break label;
where the label is not necessary.
Jump labels are typically used to jump to or out of a control flow statement other than the enclosing one. It may cause confusion ff the target of the jump is the same with and without the label. Often times this is a leftover from refactoring.
👎 Examples of incorrect code
foo: bar: while (true) {
if (condition)
continue foo;
break bar;
}
👍 Examples of correct code
while (true) {
if (condition)
continue;
break;
}
outer: while (true) {
switch (v) {
case true:
break outer;
}
}
blockLabel: {
if (condition)
break blockLabel;
}
- MDN: Labeled Statement
- MDN: Destructuring assignment