Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others


0 votes
in Technique[技术] by (71.8m points)

javascript - How to disable the warning 'define' is not defined using JSHint and RequireJS

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?

See Question&Answers more detail:os

Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 */

Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share