no-empty-label
不允许使用除循环和开关之外的任何标签。
¥Disallows labels for anything other than loops and switches.
带标签的语句仅与带标签的 break 和 continue 语句一起使用。ECMAScript 没有 goto 语句。
¥Labeled statements are only used in conjunction with labeled break and continue statements. ECMAScript has no goto statement.
规则详情
¥Rule Details
当标签用于标记不是迭代或切换的语句时会发生此错误
¥This error occurs when a label is used to mark a statement that is not an iteration or switch
此规则的错误代码示例:
¥Example of incorrect code for this rule:
/*eslint no-empty-label: "error"*/
labeled:
var x = 10;
此规则的正确代码示例:
¥Example of correct code for this rule:
/*eslint no-empty-label: "error"*/
labeled:
for (var i=10; i; i--) {
// ...
}
何时不使用
¥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.
相关规则
版本
此规则是在 ESLint v0.0.9 中引入,并在 v2.0.0-rc.0 中删除。