noLabelVar
诊断类别:lint/suspicious/noLabelVar
¥Diagnostic Category: lint/suspicious/noLabelVar
自从:v1.0.0
¥Since: v1.0.0
来源:
¥Sources:
-
与以下相同:
no-label-var
¥Same as:
no-label-var
禁止与变量共享名称的标签
¥Disallow labels that share a name with a variable
¥Examples
¥Invalid
code-block.js:2:1 lint/suspicious/noLabelVar ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Do not use the x1 variable name as a label
1 │ const x1 = “test”;
> 2 │ x1: expr;
│ ^^
3 │
ℹ The variable is declared here
> 1 │ const x1 = “test”;
│ ^^
2 │ x1: expr;
3 │
ℹ Creating a label with the same name as an in-scope variable leads to confusion.
¥Valid
¥Related links