linter-jshint icon indicating copy to clipboard operation
linter-jshint copied to clipboard

Invalid position given by 'W033'

Open minimaxi-co opened this issue 8 years ago • 18 comments
trafficstars

JSHint returned a point that did not exist in the document being edited. Rule: W033 Requested start point: 2025:15

Debug information:

Atom version: 1.19.0-beta1
linter-jshint version: v3.1.4
JSHint version: jshint v2.9.5
Hours since last Atom restart: 0
Platform: darwin
Current file's scopes: [
  "source.js",
  "string.quoted.double.js",
  "punctuation.definition.string.begin.js"
]
linter-jshint configuration: {
  "lintInlineJavaScript": true,
  "executablePath": "",
  "disableWhenNoJshintrcFileInPath": false,
  "scopes": [
    "source.js",
    "source.js-semantic"
  ],
  "jshintFileName": ".jshintrc",
  "jshintignoreFilename": ".jshintignore"
}

minimaxi-co avatar Jun 25 '17 14:06 minimaxi-co

Is your file indented using tabs?

Arcanemagus avatar Jun 26 '17 06:06 Arcanemagus

Yup. This came out of nowhere yesterday when I updated.

minimaxi-co avatar Jun 26 '17 07:06 minimaxi-co

Please follow https://github.com/jshint/jshint/issues/3151 then, this is a known issue with JSHint being broken with almost all files indented using tabs.

Arcanemagus avatar Jun 26 '17 15:06 Arcanemagus

Reopening this as a tracking issue so future users that update to v3.1.5 will get directed here and see the related JSHint issue.

If anyone is directed here and isn't using tabs to indent your file please file a new issue with a file to reproduce it on the JSHint repo, or file one here and I'll try to help you in getting one filed there where it can be fixed.

Arcanemagus avatar Jun 29 '17 23:06 Arcanemagus

I'm also suffering from the same error. error is reported in the FIRST line of a javascript file. None of the presented solutions worked. This is so disappointing.

seme1 avatar Jul 29 '17 16:07 seme1

@ETGgames I've removed your comment as it contributed nothing to the discussion and was simply a cuss filled rant.

In case you don't understand, this problem has nothing to do with the package here, the issue is a bug on JSHint's part.

Arcanemagus avatar Jul 29 '17 20:07 Arcanemagus

@seme1 The problem is that JSHint has a major bug with any file that is indented with tabs. You can work around this by indenting your files with spaces or switching to a different linter. I would highly recommend ESLint as it is by far the best linter of the dozens that I have worked with.

error is reported in the FIRST line of a javascript file

The entire problem is that JSHint is reporting points that don't exist in the file. Since the points don't exist in the file a range is generated for the entire first line of the file so you can still see that there is a problem.

If you want to help fix the problem please see the linked JSHint issue and help them solve it there so this can get fixed for everyone.

Arcanemagus avatar Jul 29 '17 20:07 Arcanemagus

Ok, well i'm calmer now because i have switched over to sublime and jshint works well there. Also sublime is a much less buggy ide and is more pleasant to use despite having fewer features. ESlint doesn't work as I want either, in fact, there are no atom packages that lint JS properly. I wasted a full 8 hours yesterday trying.

EthanSK avatar Jul 29 '17 20:07 EthanSK

@ETGgames I really don't think you understand this issue at all.

JSHint doesn't work anywhere. If you are indenting with tabs, it is giving you incorrect results, no matter where you are using it. The fact that it's "working" in Sublime just means the author of the integration there isn't telling you that JSHint is giving them invalid results.

If that solution works for you though, I'm glad you have something that works for you!

Arcanemagus avatar Jul 29 '17 20:07 Arcanemagus

Just thought this was worth noting for others: at first I thought the tabs were giving an invalid warning - the warning is valid, just the position isn't.

For me it was just a matter of passing the validation once - since jshint works realtime I can look at the lines I'm writing at that moment when a warning pops up. This way jshint is still a usable tool for me.

MaxVMH avatar Aug 15 '17 13:08 MaxVMH

There are reports that if you set your indent property of your JSHint configuration to 1 this issue can be worked around. If you don't have a .jshintrc file the following should work:

{
  "indent": 1
}

Arcanemagus avatar Sep 13 '17 17:09 Arcanemagus

Agree with @MaxVMH , jsHint is a good usable tool.! and the workaround provided by @Arcanemagus helped me to resolve this.. Thank you!

kasuladevivijay avatar Sep 17 '17 14:09 kasuladevivijay

Invalid position given by "W069"

dlefcoe avatar Oct 31 '17 21:10 dlefcoe

@dlefcoe The "catch-all" issue for that here is #460, however the root cause is the same issue with JSHint as everywhere else (https://github.com/jshint/jshint/issues/3151), as such the workarounds above apply equally to that error code 😉.

Arcanemagus avatar Nov 01 '17 16:11 Arcanemagus

I got this error while editing a file I downloaded from a project. I unindented the entire file, saved, and quit Atom. Started Atom again, indented the file to my liking and saved. This fixed the issue.

NetOpWibby avatar Dec 07 '17 17:12 NetOpWibby

@NetOperatorWibby There is no fix for this other than using spaces for indentation. jshint is simply broken for any file that is indented with tabs currently until https://github.com/jshint/jshint/issues/3151 is fixed. The above workaround forces jshint to consider tabs to be one character working around the bug with character counts.

Arcanemagus avatar Dec 07 '17 18:12 Arcanemagus

@Arcanemagus I forgot to mention I prefer spaces to tabs so that explains why my issue was fixed. Welp.

NetOpWibby avatar Dec 07 '17 18:12 NetOpWibby

I don't know if this is still bugging anyone else but after 3 years I finally couldn't stand it anymore.

There's been a PR open here for 2 years that fixes https://github.com/jshint/jshint/issues/3151 but hasn't been merged into jshint: https://github.com/jshint/jshint/pull/3274

I cloned that fork to my local machine, pulled in the changes from upstream, merged the conflicts (they were all fine), and rebuilt the binary:

git clone https://github.com/tzvipm/jshint
git remote add upstream [email protected]:jshint/jshint.git
git fetch upstream
git stash
git merge upstream/master
git mergetool --tool=opendiff
npm run build

Then in linter-jshint's settings I set the Executable Path of jshint to the newly built binary which resides at /path/you/cloned/to/jshint/bin/jshint.

image

And that fixed the issue.

yeldarby avatar Nov 07 '20 15:11 yeldarby