Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a JSLint warning concerning labels in Javascript

In my javascript I have this

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

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

Here's the notes from JSLint

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

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

like image 594
w4ik Avatar asked Dec 09 '22 22:12

w4ik


1 Answers

You are using the label correctly.

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

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

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

like image 133
Kenan Banks Avatar answered Dec 21 '22 23:12

Kenan Banks