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, ...?
This question is tagged with
~ Asked on 2012-10-19 15:34:52
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
~ Answered on 2013-10-28 12:52:51
The "evil" answer did not work for me. Instead, I used what was recommended on the JSHints docs page. If you know the warning that is thrown, you can turn it off for a block of code. For example, I am using some third party code that does not use camel case functions, yet my JSHint rules require it, which led to a warning. To silence it, I wrote:
/*jshint -W106 */ save_state(id); /*jshint +W106 */
~ Answered on 2013-10-22 06:00:10