我在我的项目中使用 RequireJS AMD。当我在我的项目上运行 jshint 时,它会抛出类似的错误
在 AMD 脚本中
 'define' is not defined.
在摩卡测试用例中
 'describe' is not defined.
 'it' is not defined.
如何在 jshint 中删除此警告?
我在我的项目中使用 RequireJS AMD。当我在我的项目上运行 jshint 时,它会抛出类似的错误
在 AMD 脚本中
 'define' is not defined.
在摩卡测试用例中
 'describe' is not defined.
 'it' is not defined.
如何在 jshint 中删除此警告?
稍微扩展一下,这是.jshintrcMocha的设置:
{
  ....
  "globals"   : {
    /* MOCHA */
    "describe"   : false,
    "it"         : false,
    "before"     : false,
    "beforeEach" : false,
    "after"      : false,
    "afterEach"  : false
  }
}
来自JSHint Docs - false(默认值)表示该变量是只读的。
如果您只为特定文件定义全局变量,您可以这样做:
/*global describe, it, before, beforeEach, after, afterEach */
jshint: {
  options: {
    mocha: true,
  }
}
是你想要的
将此添加到您的 .jshintrc
"predef" : ["define"]   // Custom globals for requirejs
聚会迟到,但在您的jshintrc:
"dojo": true
你将安息,没有红色警告......