Eslint参考手册
规则 | Rules
no-label-var
规则细节
此规则旨在通过禁止创建与范围内的变量共享名称的标签的不良做法来创建更清晰的代码。
此规则的错误代码示例:
/*eslint no-label-var: "error"*/
var x = foo;
function bar() {
x:
for (;;) {
break x;
}
}
此规则的正确代码示例:
/*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;
}
}
何时不使用它
如果您不想收到有关标签使用情况的通知,那么禁用此规则是安全的。
相关规则
- no-extra-label
- no-labels
- no-unused-labels
版本
该规则在 ESLint 0.0.9 中引入。
资源
- Rule source
- Documentation source
规则 | Rules相关

ESLint 是一个代码规范和错误检查工具,有以下几个特性。所有东西都是可以插拔的。你可以调用任意的 rule api 或者 formatter api 去打包或者定义 rule or formatter。任意的 rule 都是独立的。没有特定的 coding style,你可以自己配置。
主页 | https://eslint.org/ |
源码 | https://github.com/eslint/eslint |
发布版本 | 4.12.0 |