How to disable the warning 'define' is not

2019-01-07 05:28发布

I uses RequireJS AMD in my project. When i run jshint on my project, it throws error like

In AMD Scripts

 'define' is not defined.

In Mocha test cases

 'describe' is not defined.
 'it' is not defined.

How to remove this warning in jshint?

8条回答
闹够了就滚
2楼-- · 2019-01-07 05:58

If you are working on node js. Add these two lines in the beginning of your file

/*jslint node: true */
"use strict";
查看更多
Explosion°爆炸
3楼-- · 2019-01-07 06:00

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
  }
}

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 */
查看更多
登录 后发表回答