如何禁用警告“定义"未使用 JSHint 和 RequireJS 定义 [英] How to disable the warning 'define' is not defined using JSHint and RequireJS
本文介绍了如何禁用警告“定义"未使用 JSHint 和 RequireJS 定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的项目中使用了 RequireJS AMD.当我在我的项目上运行 jshint 时,它会抛出像
I uses RequireJS AMD in my project. When i run jshint on my project, it throws error like
在 AMD 脚本中
'define' is not defined.
在 Mocha 测试用例中
In Mocha test cases
'describe' is not defined.
'it' is not defined.
如何在 jshint 中删除此警告?
How to remove this warning in jshint?
推荐答案
为了扩展一点,这里是 Mocha 的 .jshintrc
设置:
Just to expand a bit, here's a .jshintrc
setup for Mocha:
{
....
"globals" : {
/* MOCHA */
"describe" : false,
"it" : false,
"before" : false,
"beforeEach" : false,
"after" : false,
"afterEach" : false
}
}
来自 JSHint Docs - false(默认值)表示变量是只读的.
From the JSHint Docs - the false (the default) means the variable is read-only.
如果您只为特定文件定义全局变量,您可以这样做:
If you are defining globals only for a specific file, you can do this:
/*global describe, it, before, beforeEach, after, afterEach */
这篇关于如何禁用警告“定义"未使用 JSHint 和 RequireJS 定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文