简体   繁体   English

忽略JSHint中的全局变量

[英]Ignoring a global variable in JSHint

I have a global variable called Filters that is loaded before anything else, but JSHint tells me it's undefined in all files that use Filters . 我有一个名为Filters的全局变量,该变量首先加载,但是JSHint告诉我在使用Filters所有文件中它都是未定义的。 Of course, JSHint does not know the loading order (and yes, the order is enforced), so how would it know? 当然,JSHint不知道加载顺序(是的,该顺序是强制执行的),那么它怎么知道?

I tried adding it to the globals: 我尝试将其添加到全局变量:

"globals": {
  "Filters": false
}

And that had no effect, so I tried: 那没有效果,所以我尝试了:

"predef": [ "Filters" ]

Again, no effect. 同样,没有效果。

These are also present: 这些也存在:

"undef"         : true,
"latedef"       : false,

What am I missing here? 我在这里想念什么?

In this example, I would normally just put the following at the top of my files: 在此示例中,通常将以下内容放在文件顶部:

/* globals Filters */

I prefer to specify globals on a per file basis. 我更喜欢在每个文件的基础上指定全局变量。

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

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