How to set scope for specific variables in another file for JSHint in WebStrom?

I was wondering how I can set the scope of certain variables for JSHint for my entire project in WebStorm.

So, if I have several files and import, for example jquery or Backbone , I do not need to see the JSHint: 'Backbone' is not defined.(W117) error JSHint: 'Backbone' is not defined.(W117) . These are not only my imported libraries, but also my own external files.

Some suggestions are that I should disable undefined errors. But this is the functionality that I want to use.

those. In my main.js , I have this:

 function Main(){ // Some epic code } Main.prototype.theBestFunctionEver = function(awesome, stuff){ return awesome + stuff; } 

and in foo.js I have this:

 function init(){ var main = new Main(); // Shows that Main is undefined var wrongVar = 6 + unInited // This should always give me an error // Rest of init } 
+5
source share
1 answer

JSHint works on a per-file basis and does not see "variables" defined in other files unless they are added to the "global" list. This can be done by adding the appropriate comments ('/ * global MY_LIB * / - see http://www.jshint.com/docs/ ) in the code or by adding the variables / functions that you want to use globally in the "Predefined" list in settings -> Javascript -> Code Quality Tool -> JSHint -> Predefined (separated).

+1
source

Source: https://habr.com/ru/post/1201217/


All Articles