获取有关Javascript中标签的JSLint警告 [英] Getting a JSLint warning concerning labels in Javascript

查看:60
本文介绍了获取有关Javascript中标签的JSLint警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的JavaScript中,我有这个

In my javascript I have this

    loopDeLoop:
        while (foo !== bar) {
            switch (fubar) {
                case reallyFubar:
                    if (anotherFoo == anotherBar) {
                        break loopDeLoop;
                    }
                    break;
                default:
                    break;
            }
        }

但是JSLint说...皮棉警告:使用标签

But JSLint says... lint warning: use of label

以下是 JSLint

标签
JavaScript允许任何语句具有标签,并且标签具有单独的名称空间. JSLint更加严格.

Labels
JavaScript allows any statement to have a label, and labels have a separate name space. JSLint is more strict.

JSLint期望标签仅在与break交互的语句上使用:switch,while,do和for. JSLint希望标签将不同于vars和参数.

JSLint expects labels only on statements that interact with break: switch, while, do, and for. JSLint expects that labels will be distinct from vars and parameters.

我该如何构造以上内容以消除警告?

How do I construct the above to get rid of the warning?

谢谢,
格雷格

Thanks,
Greg

推荐答案

您正在正确使用标签.

You are using the label correctly.

JSLint发出警告,因为Java语言中的标签样式非常糟糕,JSLint希望您知道这一点.

JSLint is throwing a warning because labels in Javascript are horribly bad style, and JSLint wants you to know that.

要重申一下,如果您完全使用标签,即使正确使用,JSLint也会发出警告.

To reiterate, if you use labels at all, even correctly, JSLint will give that warning.

看来您可以使用-use_of_label配置指令来禁用标签警告.

Looks like you might be able to disable the label warning with a -use_of_label configuration directive.

这篇关于获取有关Javascript中标签的JSLint警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆