Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Add tab option to set tabwidth without turning on indent error checking. #1198

wants to merge 1 commit into from

4 participants


This commit fixes issue #1196


What's the purpose of this option?
Please provide an example.


And why do we need an option for it?
Shouldn't tabs always be counted as 1 character (for error reports)?

I may miss the point, but I think this is a greater issue. jshint just can't count tabs easily because they are replaced with n space characters while lexing a source line (inherited from jslint).

Please provide test cases with your pull requests.


Shouldn't tabs always be counted as 1 character (for error reports)?

@WolfgangKluge I believe they should. But in fact, they are counted as 4 characters if "indent": false. Try:


Replace \t with a literal tab and JSHint will report a missing semicolon at character 6 when it should be character 3 (after the "1").

Now if we set "indent": 1 option, it correctly reports the missing semi-colon at character 3. However, this also outputs an indentation error.

I'm making a Sublime Text plugin and this is a performance killer. It is possible to use "indent": 1 with a custom reporter to filter out indent errors, but obviously, this will output an warning for EVERY indented line - a terrible unnecessarily overhead generated which I have to workaround with even more overhead (having to iterate over the errors array to filter out the indentation errors).

edit: Another workaround, use "indent": 1 and temporarily add //jshint -W015\n at the top of the file before running it through JSHint. Obviously all errors/warnings' line reports will be offset'ed by +1 in comparison to the original file in this case. This will suffice for my use-case for the time being, but obviously this completely disables indentation warnings so it is not a solution for every use case.


This will be irrelevant soon since we're moving from style checking. indent won't generate style warnings.

@valueof valueof closed this

@antonkovalyov Is the indent option being removed then, since it will no longer produce warnings? Or will it still have any use?


@UltCombo indent will be used to set indentation level for correct character locations and such.

@jugglinmike jugglinmike referenced this pull request in fb55/domhandler

Introduce JSHint #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +2 −0  src/stable/jshint.js
  2. +1 −1  src/stable/lex.js
2  src/stable/jshint.js
@@ -159,6 +159,7 @@ var JSHINT = (function () {
valOptions = {
maxlen : false,
indent : false,
+ tab : false,
maxerr : false,
predef : false,
quotmark : false, //'single'|'double'|true
@@ -4399,6 +4400,7 @@ var JSHINT = (function () {
state.option = newOptionObj;
state.ignored = newIgnoredObj;
+ = || 4;
state.option.indent = state.option.indent || 4;
state.option.maxerr = state.option.maxerr || 50;
2  src/stable/lex.js
@@ -227,7 +227,7 @@ function Lexer(source) {
this.from = 1;
this.input = "";
- for (var i = 0; i < state.option.indent; i += 1) {
+ for (var i = 0; i <; i += 1) { += " ";
Something went wrong with that request. Please try again.