跳转到内容

noUnusedLabels

此内容尚不支持你的语言。

Disallow unused labels.

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

The rule ignores reactive Svelte statements in Svelte components.

LOOP: for (const x of xs) {
if (x > 0) {
break;
}
f(x);
}
code-block.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)·{
------
LOOP: for (const x of xs) {
if (x > 0) {
break LOOP;
}
f(x);
}
function nonNegative(n) {
DEV: assert(n >= 0);
return n;
}
<script>
$: { /* reactive block */ }
</script>
biome.json
{
"linter": {
"rules": {
"correctness": {
"noUnusedLabels": "error"
}
}
}
}