Lint Rules

noUnusedLabels (since v12.0.0)

Disallow unused labels.

Labels that are declared and never used are most likely an error due to incomplete refactoring.

Source: https://eslint.org/docs/latest/rules/no-unused-labels

Examples

Invalid

LOOP: for (const x of xs) {
    if (x > 0) {
        break;
    }
    f(x);
}
nursery/noUnusedLabels.js:1:1 lint/nursery/noUnusedLabels  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Unused label.
  
  > 1 │ LOOP: for (const x of xs) {
   ^^^^
    2 │     if (x > 0) {
    3 │         break;
  
   Suggested fix: Remove the unused label.
  
    1 │ LOOP:·for·(const·x·of·xs)·{
  ------                     

Valid

LOOP: for (const x of xs) {
    if (x > 0) {
        break LOOP;
    }
    f(x);
}