Is there a way to suppress JSHint warning for one given line?

Mike Aski picture Mike Aski · Oct 19, 2012 · Viewed 100.5k times · Source

I have a (single) case in my app were eval is used, and I would like to suppress JSHint warning only for this case.

Is there a way to achieve that? Configuration, magic comment, ...?

Answer

Jason Punyon picture Jason Punyon · Oct 28, 2013

Yes, there is a way. Two in fact. In October 2013 jshint added a way to ignore blocks of code like this:

// Code here will be linted with JSHint.
/* jshint ignore:start */
// Code here will be ignored by JSHint.
/* jshint ignore:end */
// Code here will be linted with JSHint.

You can also ignore a single line with a trailing comment like this:

ignoreThis(); // jshint ignore:line