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

前端 未结 8 1625
温柔的废话
温柔的废话 2020-11-29 19:21

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.
<
相关标签:
8条回答
  • 2020-11-29 19:39

    Read the docs and search for /*global

    0 讨论(0)
  • 2020-11-29 19:43

    Add this in your .jshintrc

    "predef" : ["define"]   // Custom globals for requirejs
    
    0 讨论(0)
  • 2020-11-29 19:43

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

    "dojo": true
    

    and thou shall rest peacefully without red warnings...

    0 讨论(0)
  • 2020-11-29 19:45

    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 */
    
    0 讨论(0)
  • 2020-11-29 19:45

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

    /*global describe:true*/
    

    Options

    0 讨论(0)
  • 2020-11-29 19:53

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

    /*jslint node: true */
    "use strict";
    
    0 讨论(0)
提交回复
热议问题