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

Solution 1:

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

Solution 2:

jshint: {
  options: {
    mocha: true,
  }
}

is what you want

Solution 3:

To avoid the not defined warning in jshint for the javascript add comments like:

/*global describe:true*/

Options

Solution 4:

Add this in your .jshintrc

"predef" : ["define"]   // Custom globals for requirejs

Solution 5:

late to the party, but use this option in your jshintrc:

"dojo": true

and thou shall rest peacefully without red warnings...