Does JSLint have anything like JavaScript Lint's control comments (e.g. /*jsl:fallthru*/) to make it ignore certain passages?
Does JSLint have anything like JavaScript Lint's control comments (e.g. /*jsl:fallthru*/) to make it ignore certain passages?
Yes. From the documentation [note that this is from an older version of the docs, but it still applies]:
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, vars: 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.
The documentation doesn't specifically mention it, but you can enable and disable different checks throughout the code with multiple jslint comments (thanks Dominic Mitchell).
There is a complete list of options in the documentation.
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.
This seems to work for me. (using the jslint embedded in zedapp - zedapp.org)
/*jslint ignore:start*/
require([],function(require, exports, module) {
/*jslint ignore:end*/
var api = {
life: {
universe: {
everything: function() {
this.everything = {answer : 42};
}
}
}
};
api.life.universe.everything.bind(api.life.universe)();
console.log(JSON.stringify(api));
/*jslint ignore:start*/
return api;
});
/*jslint ignore:end*/
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.js"></script>