2

I have created a new service with Grunt using the angular-generator and then reformatted the code with WebStorm Ctrl+ALT+L as the tabs / spaces seem to be different.

Then when using Grunt and the task JShint complains I get the following errors:

app/scripts/services/poteservice.js
  line 11  col 13  Expected '}' to have an indentation at 15 instead at 13.
  line 14  col 13  Expected '}' to have an indentation at 15 instead at 13.

Another strange issue is that I found that I can enabled JSHint inside WebStorm but then I get issues like

 JSHINT: angular not defined
 
    and

 Use the function form of use strict

How can I make everything play together nicely i.e. WebStorm and Grunt etc.?

I have the WebStorm plugin for Angular installed.

halfer
  • 19,824
  • 17
  • 99
  • 186
Martin
  • 23,844
  • 55
  • 201
  • 327

1 Answers1

7

First, you should configure WebStorm to use the same JSHint file as Grunt.

Go to Project Settings -> Javascript -> Code Quality Tools -> JSHint click Enable and reference to the .jshintrc in your Project.

Second, you should add this two lines of code at the top of all your JavaScript files:

/* global angular */
'use strict';
Tome Pejoski
  • 1,582
  • 2
  • 10
  • 34
  • 1
    Great, thanks. I also had to change the indent from 2 to 4 in jshint file and all works... thanks for that.. It seems to be working – Martin Feb 25 '14 at 09:17
  • 1
    You can also use globals property for defining angular in .jshintrc file like `"globals" : { "angular": false}` – bhantol Aug 27 '14 at 20:25