How to tell JSLint / JSHint what global variables are already defined

后端 未结 3 921
醉酒成梦
醉酒成梦 2020-12-08 05:52

In my project we have some global variables that work as containers:

MyProject.MyFreature.someFunction = function() { ... }

So then I use t

相关标签:
3条回答
  • 2020-12-08 06:31

    This is only for globals

    /* global MyProject */
    

    In your case you need

    /* exported MyProject */
    
    0 讨论(0)
  • 2020-12-08 06:39

    For JSHint you can create .jshintrc to your project directory with

    {
      "globals": { "MyProject": true }
    }
    
    0 讨论(0)
  • 2020-12-08 06:43

    JSLint has a textarea below the options that says predefine global variables here in it. Just add the variable names in there before running the check.

    JSHint doesn't allow you to add global variables, but you can uncheck the When variable is undefined option to suppress that warning.

    The JSHint library also has parameters for globals, if you run it as a library . . . details in here: http://jshint.com/docs/

    0 讨论(0)
提交回复
热议问题