WebStorm - "angular" is not defined WebStorm - "angular" is not defined angularjs angularjs

WebStorm - "angular" is not defined


In

Webstorm settings > JavaScript > Code Quality Tools > JSHint 

there is "Predefined" line. Click on "Set" next to it. Here you can add all your predefined variables.


The very first example in the documentation page of JSHint is the following:

Configuration file is a simple JSON file that specifies which JSHint options to turn on or off. For example, the following file will enable warnings about undefined and unused variables and tell JSHint about a global variable named MY_GLOBAL.

{  "undef": true,  "unused": true,  "globals": { "MY_GLOBAL": false }}

Replace MY_GLOBAL with angular, and you won't have this JSHint warning anymore.


In case it helps:

I used yeoman (yo angular) to scaffold a basic project and got the same 'angular is not defined' problem in WebStorm 8 (where I have the AngularJS plugin by default). However, I've seen others do this and not have the same issue.

The solution selected above is correct in the JSHint needs to be told about the global variable called "angular". However, if you use yeoman, the required configuration settings will already be defined in .jshintrc (a file in your scaffolded directory).

So all you need to do is have JSHint use these as the default settings for the project. To do this, I found the following SO thread useful to explicitly set the location of that config file.JSHint behave differently in Webstorm and Grunt

In WebStorm 8, you will see an option called "Use config files" -- checking that will automatically look for a .jshintrc file in your project hierarchy. Selecting this will make the 'angular is not defined' issue go away for good.