How to change indentation in JSLint edition 2015-06-22

730 views Asked by At

I write most of my JavaScript code with an indentation of 2 spaces. I'm using http://www.jslint.com for quality control. In the new version anything else but 4 space indentation is considered wrong?

In the old version http://old.jslint.com there was a indent box where the number of whitespace could be set or an directive: /*jslint indent: 2 */ could placed at the top of the script.

I would like to avoid "messy white space" and keep a 2 space indentation.

Please advise :)

1

There are 1 answers

0
Ed Ballot On

Some suggestions:

  • use jshint.com instead of jslint.com. The 'indent' option is deprecated from both jshint and jslint. However, jshint doesn't care how many spaces your code is indented (so no warning)
  • if you want to continue using jslint, you can use /*jslint white:true */ which allows any amount of indentation (however, it also ignores extraneous spaces and tabs anywhere so the following won't produce any warning function anony () {)
  • use eslint, which is newer and more modular (allows custom plugins) than jslint and jsint. Note that eslint doesn't seem to have a simple website where you can paste in code for linting, like the other two have (someone please correct me if a site does exist)