简体   繁体   English

如何永久停止jshint'只读'警告/错误?

[英]how to permanently stop jshint 'read only' warning/error?

I tried to find a solution but it seems I can't use any flag for this. 我试图找到一个解决方案,但似乎我不能使用任何标志。 If I declare a global variable initially null like this: 如果我声明一个全局变量最初为null,如下所示:

close = null;

I then get an error of 'read only'. 然后我得到'只读'的错误。 It's useless in my case. 在我的情况下它没用。 How can I stop it? 我怎么能阻止它?

When you define globals for jshint, you have to also declare whether you allow re-assigning them or not. 为jshint定义全局变量时,还必须声明是否允许重新分配它们。

/* global close:false */

or the equivalent of 或相当于

"globals": { "close": false }

in your .jshintrc file will allow the close global to be used, but not to be reassigned. 在.jshintrc文件中将允许使用close global,但不能重新分配。

/* global close:true */

will allow redefining, and close = null will not throw a jshint warning anymore. 将允许重新定义,并且close = null将不再抛出jshint警告。

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

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