mirror of
https://git.proxmox.com/git/pve-eslint
synced 2025-10-05 11:05:16 +00:00

includes a (minimal) working wrapper Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
49 lines
870 B
Markdown
49 lines
870 B
Markdown
# Disallow Labels That Are Variables Names (no-label-var)
|
|
|
|
## Rule Details
|
|
|
|
This rule aims to create clearer code by disallowing the bad practice of creating a label that shares a name with a variable that is in scope.
|
|
|
|
Examples of **incorrect** code for this rule:
|
|
|
|
```js
|
|
/*eslint no-label-var: "error"*/
|
|
|
|
var x = foo;
|
|
function bar() {
|
|
x:
|
|
for (;;) {
|
|
break x;
|
|
}
|
|
}
|
|
```
|
|
|
|
Examples of **correct** code for this rule:
|
|
|
|
```js
|
|
/*eslint no-label-var: "error"*/
|
|
|
|
// The variable that has the same name as the label is not in scope.
|
|
|
|
function foo() {
|
|
var q = t;
|
|
}
|
|
|
|
function bar() {
|
|
q:
|
|
for(;;) {
|
|
break q;
|
|
}
|
|
}
|
|
```
|
|
|
|
## When Not To Use It
|
|
|
|
If you don't want to be notified about usage of labels, then it's safe to disable this rule.
|
|
|
|
## Related Rules
|
|
|
|
* [no-extra-label](./no-extra-label.md)
|
|
* [no-labels](./no-labels.md)
|
|
* [no-unused-labels](./no-unused-labels.md)
|