简体   繁体   English

暂时禁用jshint选项W098不起作用

[英]Temporarily disabling jshint option W098 does not work

I have the following snippet of code: 我有以下代码片段:

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

However, I would like to re-enable option W098 afterwards. 但是,我想在之后重新启用选项W098。 So my snippet would look like this: 所以我的代码片段看起来像这样:

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

This triggers the error 这会触发错误

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

For option W106 everything works fine. 对于选项W106,一切正常。 Am I doing something wrong? 难道我做错了什么? Is it a bug? 这是一个错误吗?

This appears to be a bug in jshint. 这似乎是jshint中的一个错误。 It can be triggered with this input: 可以使用此输入触发:

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

jshint will report the following, despite W098 being turned off. 尽管W098被关闭,jshint仍将报告以下内容。

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 a little into the jshint source but couldn't find the exact source of the error. 我在jshint源中挖了一点但是找不到错误的确切来源。 It appears to be related to how doFunction in src/jshint.js restores the ignore array after processing a function. 它似乎与src / jshint.js中的doFunction如何在处理函数后恢复ignore数组有关。

There's an open issue for this bug ( 1140 ). 这个bug存在一个未解决的问题( 1140 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM