【问题标题】:Grunt JSHint - Not checking indentationsGrunt JSHint - 不检查缩进
【发布时间】:2014-10-08 15:26:04
【问题描述】:

我将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
   }
}

【问题讨论】:

  • 您能否发布您的 Gruntfile(或尽可能少地复制问题)以便我们帮助解决问题?
  • 是的...让我更新...

标签: gruntjs jshint grunt-contrib-jshint


【解决方案1】:

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


原来这是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);当我改为安装 grunt-contrib-jshint@0.9.2(最后一个使用 JSHint 2.4.0 的版本)时,我的结果出现了一堆缩进错误(如预期的那样)。

【讨论】:

  • 是的,确实如此。我的同事向我指出了同一个帖子!不幸的是,我们不得不依靠我们的编辑器来处理缩进和制表符/空格问题。感谢朋友的帮助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多