Temporarily disabling the jshint W098 option does not work

I have the following code snippet:

/* jshint -W098 */
/* jshint -W106 */
var pro6pp_auth_key = 'some key';
/* jshint +W106 */

However, I would like to re-enable option W098. So my fragment will look like this:

/* jshint -W098 */
/* jshint -W106 */
var pro6pp_auth_key = 'some key';
/* jshint +W106 */
/* jshint +W098 */

It causes an error

[L6:C20] W098: 'pro6pp_auth_key' is defined but never used.

For option W106, everything works fine. Am I doing something wrong? This is mistake?

+4
source share
1 answer

This seems like a bug in jshint. It can be activated using this input:

/* jshint -W098 */
var main = function (x) {
}
/* jshint +W098 */

jshint will report the following, even though W098 is disabled.

test.js: line 2, col 9, 'main' is defined but never used. (W098)
test.js: line 2, col 23, 'x' is defined but never used. (W098)

I dug up the jshint source a bit, but could not find the exact source of the error. This seems to be due to the way the doFunction in src / jshint.js restores the ignore array after processing the function.

(1140).

+3

Source: https://habr.com/ru/post/1526720/


All Articles