2013-05-21 39 views
1

我在我的Gruntfile中有jsbeautifer后跟jshint任务,但他们似乎对我的右括号应该在哪里有不同的想法。jshint与jsbeautifier冲突,并抱怨排列在方阵中的方括号

我同意jsbeautifer产生什么,但jshint抱怨。下面是一个示例文件,我有以下错误信息:

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


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

这是我.jshintc文件:

{ 
    "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 
    } 
} 

回答

2

您jsbeautifier似乎缩进4个空格,你jshintrc文件设置为检查压痕为2个空间。只是在此设置为4个空格,如果你认为4位是你想要什么:

"indent": 4, 

编辑:

如果你使用this grunt-beautifier-plugin有一个名为keep_array_indentation其默认设置默认的选项。我希望能解决你的问题。

+0

谢谢,我做了这个改变,大部分警告信息都消失了。但是,在数组中,方括号的缩进似乎仍然存在冲突。我更新了上面的示例。 – user1027169

+0

编辑我的答案。一般说来阅读你的美化和jshint的文档,并调整配置他们是不同的地方... – hereandnow78