--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.js --- # Input ```jsx /*before*/ A /*inner*/: /*after*/ while(true) {}; A: for (let i = 0; i < 10; ++i) { foo(); } A: { foo(); } A: { foo(); bar(); } A: for (var i = 0; i < 10; ++i) { foo(); if (a) break; bar(); } A: for (var i = 0; i < 10; ++i) { foo(); if (a) continue; bar(); } A: for (var i = 0; i < 10; ++i) { H: break A; } A: { var I = 0; console.log(I); } A: { function f() { A: { break A; } } } A: { class X { static { B: { break B; } } method() { B: { break B; } } } } /* * Below is fatal errors. * "A: break B", * "A: function foo() { break A; }", * "A: class Foo { foo() { break A; } }", * "A: { A: { break A; } }" */ ``` # Diagnostics ``` invalid.js:1:12 lint/correctness/noUnusedLabels FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Unused label. > 1 │ /*before*/ A /*inner*/: /*after*/ while(true) {}; │ ^ 2 │ 3 │ A: for (let i = 0; i < 10; ++i) { i The label is not used by any break statement and continue statement. i Safe fix: Remove the unused label. 1 │ /*before*/·A·/*inner*/:·/*after*/·while(true)·{}; │ ----------------------- ``` ``` invalid.js:3:1 lint/correctness/noUnusedLabels FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Unused label. 1 │ /*before*/ A /*inner*/: /*after*/ while(true) {}; 2 │ > 3 │ A: for (let i = 0; i < 10; ++i) { │ ^ 4 │ foo(); 5 │ } i The label is not used by any break statement and continue statement. i Safe fix: Remove the unused label. 3 │ A:·for·(let·i·=·0;·i·<·10;·++i)·{ │ --- ``` ``` invalid.js:7:1 lint/correctness/noUnusedLabels FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Unused label. 5 │ } 6 │ > 7 │ A: { │ ^ 8 │ foo(); 9 │ } i The label is not used by any break statement and continue statement. i Safe fix: Remove the unused label. 7 │ A:·{ │ --- ``` ``` invalid.js:11:1 lint/correctness/noUnusedLabels FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Unused label. 9 │ } 10 │ > 11 │ A: { │ ^ 12 │ foo(); 13 │ bar(); i The label is not used by any break statement and continue statement. i Safe fix: Remove the unused label. 11 │ A:·{ │ --- ``` ``` invalid.js:16:1 lint/correctness/noUnusedLabels FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Unused label. 14 │ } 15 │ > 16 │ A: for (var i = 0; i < 10; ++i) { │ ^ 17 │ foo(); 18 │ if (a) break; i The label is not used by any break statement and continue statement. i Safe fix: Remove the unused label. 16 │ A:·for·(var·i·=·0;·i·<·10;·++i)·{ │ --- ``` ``` invalid.js:22:1 lint/correctness/noUnusedLabels FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Unused label. 20 │ } 21 │ > 22 │ A: for (var i = 0; i < 10; ++i) { │ ^ 23 │ foo(); 24 │ if (a) continue; i The label is not used by any break statement and continue statement. i Safe fix: Remove the unused label. 22 │ A:·for·(var·i·=·0;·i·<·10;·++i)·{ │ --- ``` ``` invalid.js:32:1 lint/correctness/noUnusedLabels FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Unused label. 30 │ } 31 │ > 32 │ A: { │ ^ 33 │ var I = 0; 34 │ console.log(I); i The label is not used by any break statement and continue statement. i Safe fix: Remove the unused label. 32 │ A:·{ │ --- ``` ``` invalid.js:37:1 lint/correctness/noUnusedLabels FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Unused label. 35 │ } 36 │ > 37 │ A: { │ ^ 38 │ function f() { 39 │ A: { i The label is not used by any break statement and continue statement. i Safe fix: Remove the unused label. 37 │ A:·{ │ --- ``` ``` invalid.js:45:1 lint/correctness/noUnusedLabels FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Unused label. 43 │ } 44 │ > 45 │ A: { │ ^ 46 │ class X { 47 │ static { i The label is not used by any break statement and continue statement. i Safe fix: Remove the unused label. 45 │ A:·{ │ --- ```