views:

455

answers:

3

Does JSLint have anything like JavaScript Lint's control comments (e.g. /*jsl:fallthru*/) to make it ignore certain passages?

+1  A: 

It doesn't seem so. Some Googling finds several posts by others, and responses from JSLint people along the lines of "Fix your code instead of labeling it intentionally defective." Doesn't seem entirely friendly. Of course, maybe in this case you should just fix the code, but I leave that for you to answer.

ironfroggy
Well, there was an intentional fallthrough - it really made sense.I ended up creating a sort of dummy function, which was a bit annoying.
AnC
+1  A: 

Yes. You can specify options for the whole file, but not individual sections of code. From the documentation at http://www.jslint.com/lint.html:

The implementation of JSLint accepts an option object that allows you to determine the subset of JavaScript that is acceptable to you. It is also possible to set those options within the source of a script.

An option specification can look like this:

/*jslint nomen: true, debug: true,
  evil: false, onevar: true */

An option specification starts with /*jslint. Notice that there is no space before the j. The specification contains a sequence of name value pairs, where the names are JSLint options, and the values are true or false. An option specification takes precedence over the option object.

There is a complete list of options in the documentation (scroll down to the bottom of the page).

Matthew Crumley
Actually, you can add these jslint comments in to your code at any point, enabling and disabling as you see fit. But it's probably wiser to rewrite and avoid the need to.
Dominic Mitchell
Thanks, I didn't know you could do that. I guess I assumed it was the same as passing the options argument.
Matthew Crumley
+1  A: 

Put /jsl:ignore/ and /jsl:end/ around the code.

BengalTigger
Not pretty, but a viable workaround - thanks!
AnC
this is for JavascriptLint, not JSLint
Brandon Thomson