gruntjsjshintgrunt-contrib-jshint

Grunt JSHint - Not checking indentations


I have the indent set to 4. If I remove all the indentations in a source file, JSHint doesn't fail for it. It checks everything else but the indentations. How do I get it to check for indentations?

Additionally, I have installed the jshint-eclipse plugin, it too doesn't work!

Here is the excerpt of my 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']
  }
},

And my 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
   }
}

Solution

  • tl;dr: npm install grunt-contrib-jshint@0.9.2


    Turns out this is a dupe of How can I make jshint indent options work.

    No accepted answer, but the only answer present suggests it's an issue with the version of JSHint that's installed. 2.5.0 dropped support for the indent option and some other style things.

    When I just installed grunt-contrib-jshint normally, I got version 0.10.0 and had the same problem as OP (because 0.10.0 depends on JSHint 2.5.0); when I instead installed grunt-contrib-jshint@0.9.2 (the last release that used JSHint 2.4.0 instead), my results lit up with a bunch of indentation errors (as expected).