11

jslint can check indent by run 'jslint --indent 4 test.js', but I don't get it work in jshint. I do it as the follow steps.

  1. install jshint through "npm install -g jshint"
  2. edit ~/.jshintrc, my jshintrc looks like
    {..., "indent":4, "white":false, ...}
  3. edit js file test.js
    /jshint indent:4/
    var condition, doSth;
    if (condition)
    doSth(); // expected to be invalid
    
  4. run jshint test.js, but the indent checking is not working. The 2 spaces started line can pass the check.
smilingwang
  • 321
  • 2
  • 13

1 Answers1

15

It's a version problem. I use 2.5.0 while 2.4 works.

Take a look at https://github.com/jshint/jshint/releases/tag/2.5.0:

We decided to label it 2.5.0 because—while it's backwards compatible—there are a few major changes.

The following options were removed: nomen, onevar, passfail, white, gcl, smarttabs, trailing. In addition to that, indent no longer provides warnings about indentation levels. You can still use it to set your tab-width but it will be used only for character locations in other warnings. JSHint won't error if you have these options in your config or your files; it will simply ignore them.

Thanks to our contributors, we fixed a lot of bugs in our parser. We also improved our ES6 support by adding basic support for template literals.

absynce
  • 1,399
  • 16
  • 29
smilingwang
  • 321
  • 2
  • 13
  • 4
    Does anyone happen to know the justification for removing those options? They were very useful for keeping styles in check. – leedm777 Jun 06 '14 at 21:48
  • 6
    @dave see [JSHint issue #1358](https://github.com/jshint/jshint/issues/1358#issuecomment-39587645) and [JSHint 3 plans](http://www.jshint.com/blog/jshint-3-plans/). In short, the creator of JSHint, Anton Kovalyov, plans to focus on other aspects of code analysis and feels that style checking should be part of another tool/add-on. I understand the need to have a succinct focus. Now my question is just what will that tool be. Some comments in the JSHint issue suggest [JSCS](https://github.com/mdevils/node-jscs). I plan to start there. – absynce Jul 09 '14 at 15:41