Lint Rules

noUnusedLabels (since vnext)

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);
}