Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 982
Fizer Khan Avatar asked Apr 28 '13 07:04

Fizer Khan


3 Answers

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 */
like image 81
bendytree Avatar answered Nov 04 '22 18:11

bendytree


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

is what you want

like image 17
Grant Fong Avatar answered Nov 04 '22 17:11

Grant Fong


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

/*global describe:true*/

Options

like image 12
Roland Puntaier Avatar answered Nov 04 '22 16:11

Roland Puntaier