jslint配置|传递全局 [英] jslint configuration | passing globals

查看:103
本文介绍了jslint配置|传递全局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何警告jshint我有全局变量,即命名它们。我知道你可以做到这一点,但我不记得语法。

How do I alert jshint that I have globals, i.e. name them. I know you can do this, but I don't recall the syntax.

我在这里定义了一个全局

I defined a global here like this

(function(){window.glob1 = local_var;})()

然后像这样使用:(一个不同的IIFE)

and use later like this: ( a different IIFE )

(function(){glob1 // does something})()

jshint说它是在定义之前使用的。

jshint is saying it was used before it was defined.

这不是一个标志,实际上有一种方法可以按名称列出全局变量。

It's not a flag, there is actually a way to list global variables by name.

推荐答案

你的意思是语法

 /* global window, console, jQuery */

...在每个JS文件的开头?

... at the beginning of the each JS file?

这篇关于jslint配置|传递全局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆