jshint: Tab indentation breaks multiple rules
It seems that indentation using tabs breaks the position reported by at least 3 rules, likely more.
All of the following was linted using this .jshintrc
file:
{
"strict": "global",
"unused": true
}
The JSHint version tested is v2.9.5.
If you want me to refile these as separate issues I can do that as well.
W032
If you lint this code:
'use strict';
function foo() {
};
foo();
There is an error reported on line 4, col 6, but line 4 only has 4 characters in it.
W098
If you lint this code:
'use strict';
function foobar(
$foo
) {
return 'foo';
}
foobar();
There is an error reported on line 4, col 9, but line 4 only has 7 characters in it.
W117
If you lint this code:
'use strict';
function foobar() {
if (true) {
fun1();
}
}
foobar();
There is an error reported on line 5, col 13, but line 4 only has 11 characters in it.
The character position reported seems to go further and further out the more tabs there are at the beginning of the line in question.
Raw files can be found here: linter-jshint_GH416.zip
Originally discovered while investigating https://github.com/AtomLinter/linter-jshint/issues/416.
Rules known to be affected:
W009
W014
E015
W024
W027
W030
W032
W033
W040
W043
W069
W075
W098
W116
W119
W140
E041
- Many others…
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 7
- Comments: 29 (7 by maintainers)
Commits related to this issue
- [[FIX]] Improve handling of tab indentation. By tracking the column number both with and without soft tabs, we enable better messages for errors and warnings. This is especially useful for editor lin... — committed to TzviPM/jshint by TzviPM 6 years ago
- [[FIX]] Improve handling of tab indentation. By tracking the column number both with and without soft tabs, we enable better messages for errors and warnings. This is especially useful for editor lin... — committed to TzviPM/jshint by TzviPM 6 years ago
- [[FIX]] Improve handling of tab indentation. By tracking the column number both with and without soft tabs, we enable better messages for errors and warnings. This is especially useful for editor lin... — committed to TzviPM/jshint by TzviPM 6 years ago
- [[FIX]] Improve handling of tab indentation. By tracking the column number both with and without soft tabs, we enable better messages for errors and warnings. This is especially useful for editor lin... — committed to TzviPM/jshint by TzviPM 6 years ago
- [[FIX]] Improve handling of tab indentation. By tracking the column number both with and without soft tabs, we enable better messages for errors and warnings. This is especially useful for editor lin... — committed to jugglinmike/jshint by TzviPM 6 years ago
PLEASE ALL YOUR SOLUTIONS SUCK IVE SPENT THE PAST FUCKING 5 HOURS TRYING TO LINT A FUCKING JAVASCRIPT FILE ITS FUCKING 2017 WHY AM I HAVING THIS PROBLEM ATOM IS THE FUCKING BANE OF MY FUCKING LIFE FIX YOURSELF YOU STUPID IDE
AND WHO THE FUCK DOESN’T USE TABS TO INDENT LITERALLY WTF WHY WOULD YOU RELEASE A BROKEN PACKAGE TO THE MILLIONS THAT LINT JS???
Well, I guess the solution will be deactivating this for the time being… Who needs linters anyway?
Hi @xcrap! I just checked the comment thread, and it doesn’t look like anyone has posted any updates. The good news is that JSHint is an open source project, so you can help fix the problem if it’s causing you stress! Would you like to lend a hand? I’d be happy to advise you.
Update: I’m still working to shore up the JSHint test suite to avoid regressions. The latest in that effort is gh-3176.
@jaredatch Back in https://github.com/AtomLinter/linter-jshint/pull/386 (released in v3.1.0 of
linter-jshint
) all of the workarounds for JSHint’s buggy point reporting were removed. The entire point of that check is to find bugs like this were the linter is reporting invalid points so it can get reported and fixed for everyone using the linter. (After all, if you can’t trust the linter to give you accurate data, why use it?)There may be a “sweet spot” before this tab bug was introduced and after the major parser bugs that caused those workarounds to be put in place in the first place.
Does anyone know what version this was introduced in? 2.9.5?
At least then we could downgrade for the moment as a temp. fix.