JSLint: control comments (selective ignore) JSLint: control comments (selective ignore) javascript javascript

JSLint: control comments (selective ignore)


Put

/*ignore jslint start*/

before and

/*ignore jslint end*/ 

after the code to be ignored. Ex:

function ignore(){    /*ignore jslint start*/    var x; var y;    /*ignore jslint end*/}

Or export JsLint settings, define your IgnoreErrorStart/ IgnoreErrorEnd symbols and import.


Edit
Some folks may confuse this answer with JSHint. In that case, use these:

/*jshint ignore:start*/  <!-- code in here -->/*jshint ignore:end*/

Taken from https://stackoverflow.com/a/26012357/313501


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.


Here is a code example to supplement Matthew Crumley's excellent answer:

(function ($) {  $.isValidEmail = function(email){    /*jslint maxlen: 1000*/    var EMAIL_REGEXP = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;    /*jslint maxlen: 200*/    return EMAIL_REGEXP.test(email);  };}(jQuery));