difference between globals and predef in .jshintrc?

强颜欢笑 提交于 2019-12-03 23:19:25

问题


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/


回答1:


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

More information here




回答2:


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.



来源:https://stackoverflow.com/questions/22551402/difference-between-globals-and-predef-in-jshintrc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!