简体   繁体   中英

How can I make jshint indent options work

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
    \n/ jshint indent:4 / \nvar condition, doSth; \nif (condition) \ndoSth();  // expected to be invalid \n
  4. run jshint test.js, but the indent checking is not working. The 2 spaces started line can pass the check.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM