Skip to main content

avoid-labels

effort: 6m
pro+

Warns when a labeled statement is used.

While convenient in some cases, labels tend to be used only rarely and are frowned upon by some as a remedial form of flow control that is more error prone and harder to understand.

Example

❌ Bad:

// LINT: Avoid labels. Try rewriting the code without them.
label:
while (true) {
break label;
}

✅ Good:

while (true) {
break;
}