0

indent设置为 4。如果我删除源文件中的所有缩进,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
   }
}
4

1 回答 1

1

tl;博士:npm install grunt-contrib-jshint@0.9.2


原来这是一个骗子 How can I make jshint indent options work

没有接受的答案,但目前唯一的答案表明这是安装的 JSHint 版本的问题。2.5.0 放弃了对indent选项和其他一些样式的支持。

grunt-contrib-jshint正常安装的时候,拿到的是0.10.0版本,和OP一样的问题(因为0.10.0依赖JSHint 2.5.0);当我改为安装grunt-contrib-jshint@0.9.2(最后一个使用 JSHint 2.4.0 的版本)时,我的结果出现了一堆缩进错误(如预期的那样)。

于 2014-10-10T18:00:33.813 回答