I set up Jasmine integration in Webstorm 8.0.4 using File > Settings > JavaScript > Libraries. I added a karma-jasmine
library with the lib/ folder of my karma-jasmine node module.
This works fine in a way that syntax highlighting works, I can jump to the declaration and the documentation is displayed correctly. So the connection seem to be fine. However, JSHint still complains for each keyword about it not being defined, e.g.
JSHint: 'describe' is not defined. (117)
See also the following screenshot. As you can see, the syntax highlighting is fine, but I still get an error.
Considering what I have from yeoman's build of my .jshintrc, yes you need to add these names to that file.
Annoying yes, unless you used something to scaffold with like, well, yeoman!
Here is the .jshintrc that yeoman creates for us - plus the addition of lodash/underscore and jQuery.
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 4,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"multistr": true,
"globals": {
"after": false,
"afterEach": false,
"angular": false,
"before": false,
"beforeEach": false,
"browser": false,
"describe": false,
"expect": false,
"inject": false,
"it": false,
"jasmine": false,
"spyOn": false,
"$": false,
"_": false
}
}
It's a JSHint 'feature'. JSHint works on per-file basis and knows nothing about global variables and functions defined in other files unless they are added to 'global' list. This can be done by either adding the corresponding comments (/* global MY_LIB*/
- see http://www.jshint.com/docs/) in code, or by adding variables/functions you'd like to use globally to the 'Predefined' list in Preferences -> Javascript -> Code Quality Tool -> JSHint -> Predefined (,separated)
. It's the last item in the list of JSHint options
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With