1

I have a jsbeautifer followed by a jshint task in my Gruntfile, but they seem to have different ideas about where my closing braces should be.

I agree with what jsbeautifer produces, but jshint complains. Here is a sample file I have and the error message below:

    0   $scope.awesomeThings = [                                                                       
    1       'HTML5 Boilerplate',                                                                       
    2       'AngularJS',                                                                               
    3       'Karma'                                                                                    
>>  4   ];         


Expected ']' to have an indentation at 5 instead at 3.

This is my .jshintc file:

{
  "node": true,
  "browser": true,
  "es5": true,
  "esnext": true,
  "bitwise": true,
  "curly": true,
  "eqeqeq": true,
  "immed": true,
  "indent": 2,
  "latedef": true,
  "newcap": true,
  "noarg": true,
  "quotmark": "single",
  "regexp": true,
  "undef": true,
  "unused": true,
  "strict": true,
  "trailing": true,
  "smarttabs": true,
  "globals": {
    "angular": false
  }
}
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
user1027169
  • 2,627
  • 3
  • 27
  • 50

1 Answers1

2

your jsbeautifier seems to indent 4 spaces, your jshintrc-file is set to check indentation for 2 spaces. just set it there to 4 spaces if you think 4 spaces is what you want:

"indent": 4,

edit:

if you use this grunt-beautifier-plugin there is an option called keep_array_indentation which by default is set default. i would expect that to fix your problem.

hereandnow78
  • 14,094
  • 8
  • 42
  • 48
  • Thanks, I made that change and most of the warning messages disappeared. However, there still seems to be a conflict regarding the indentation of square brackets in an array. I updated my example above. – user1027169 May 22 '13 at 13:42
  • edit my answer. generally spoken read the docs of your beautifier and jshint, and adapt the configs where they are different... – hereandnow78 May 22 '13 at 13:50