noUnusedLabels (since v1.0.0)
Diagnostic Category: lint/correctness/noUnusedLabels
Source: no-unused-labels
Disallow unused labels.
Labels that are declared and never used are most likely an error due to incomplete refactoring.
Examples
Section titled ExamplesInvalid
Section titled InvalidLOOP: for (const x of xs) { if (x > 0) { break; } f(x);}
correctness/noUnusedLabels.js:1:1 lint/correctness/noUnusedLabels FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━
✖ Unused label.
> 1 │ LOOP: for (const x of xs) {
│ ^^^^
2 │ if (x > 0) {
3 │ break;
ℹ The label is not used by any break statement and continue statement.
ℹ Safe fix: Remove the unused label.
1 │ LOOP:·for·(const·x·of·xs)·{
│ ------
Valid
Section titled ValidLOOP: for (const x of xs) { if (x > 0) { break LOOP; } f(x);}
function nonNegative(n) { DEV: assert(n >= 0); return n;}