2014-10-08 69 views
0

我將indent設置爲4.如果我刪除源文件中的所有縮進,JSHint不會失敗。它檢查除縮進之外的所有其他內容。我如何得到它來檢查縮進?Grunt JSHint - 不檢查縮進

此外,我已經安裝了jshint-eclipse插件,它也行不通!

這裏是我的GruntFile的摘錄:

// Make sure code styles are up to par and there are no obvious mistakes 
jshint: { 
    options: { 
    jshintrc: '.jshintrc', 
    reporter: require('jshint-stylish') 
    }, 
    all: { 
    src: [ 
     'Gruntfile.js', 
     '<%= yeoman.app %>/scripts/{,*/}*.js' 
    ] 
    }, 
    test: { 
    options: { 
     jshintrc: 'test/.jshintrc' 
    }, 
    src: ['test/spec/{,*/}*.js'] 
    } 
}, 

而且我jshint:

{ 
    "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", 
    "regexp": true, 
    "undef": true, 
    "unused": true, 
    "strict": true, 
    "trailing": true, 
    "smarttabs": false, 
    "globals": { 
     "angular": false 
    } 
} 
+0

您可以發佈您的Gruntfile(或儘可能少地重現問題),以便我們幫助排除故障嗎? – myersjustinc 2014-10-09 21:42:28

+0

是...讓我更新... – 2014-10-10 14:35:08

回答

1

TL;博士:npm install [email protected]


原來這是How can I make jshint indent options work愚弄的人。

沒有接受的答案,但the only answer present表明這是安裝的JSHint版本的問題。 2.5.0下降了對indent選項和其他一些風格的支持。

當我剛剛安裝grunt-contrib-jshint正常,我得到0.10.0版本,並具有相同的問題OP(因爲0.10.0取決於JSHint 2.5.0);當我改爲安裝了[email protected](最後一個使用JSHint 2.4.0的版本)時,我的結果照亮了一堆縮進錯誤(如預期的那樣)。

+0

是的,沒錯。我被同事指向了同一篇文章!不幸的是,我們不得不依靠我們的編輯器來處理縮進和製表符/空格問題。感謝幫助隊友! – 2014-10-11 05:59:39