noUnusedLabels
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
诊断类别:
lint/correctness/noUnusedLabels¥Diagnostic Category:
lint/correctness/noUnusedLabels -
此规则为推荐规则,默认启用。
¥This rule is recommended, which means is enabled by default.
-
此规则包含 safe 修复程序。
¥This rule has a safe fix.
-
此规则的默认严重级别为 warning。
¥The default severity of this rule is warning.
-
来源:
¥Sources:
-
与
no-unused-labels相同¥Same as
no-unused-labels
-
¥How to configure
{ "linter": { "rules": { "correctness": { "noUnusedLabels": "error" } } }}¥Description
禁止未使用的标签。
¥Disallow unused labels.
声明但从未使用的标签很可能是由于重构不完整而导致的错误。
¥Labels that are declared and never used are most likely an error due to incomplete refactoring.
该规则忽略 Svelte 组件中的反应式 Svelte 语句。
¥The rule ignores reactive Svelte statements in Svelte components.
¥Examples
¥Invalid
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)·{
│ ------
¥Valid
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>¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号