difference between globals and predef in .jshintrc

2019-02-16 04:54发布

What the difference and purpose of having both of them in the .jshintrc? When I want to add a variable to be ignored, which one is the best one I should use? Also I can't find 'predef' in http://www.jshint.com/docs/options/

2条回答
干净又极端
2楼-- · 2019-02-16 05:10

It seems like predef is deprecated and you should use globals instead.

More information here

查看更多
贼婆χ
3楼-- · 2019-02-16 05:20

At JSHint Doc page http://www.jshint.com/docs/ "predef" is mention for use inside .jshintrc file, wile word "globals" is used only once for inline directive (those that are inside .js files)

So examples would be :

  • inside .jshintrc file

    "predef" : [ // Extra globals
                 "angular",
    ]
    
  • inside .js files

    /* global app: false */
    

So it would be better to use different words when doing the same but in different places.

查看更多
登录 后发表回答