New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newer jslint editions has a 0 index for lines and columns #5
Comments
Thanks for reporting. Indeed the new JSLint seems to use zero-based indexing for columns and lines. It does include a new option ("fudge", see http://www.jslint.com/help.html) that seems to provide a way to revert to the usual 1-based indexing used by most text editors. However, this option does not seem to be supported by node-jslint yet. I tried using fudge as an inline setting (by including I would argue that this feature should really be implemented in node-jslint rather than SublimeLinter-jslint (node-jslint is the immediate wrapper for jslint, which already seems to support 1-based line/column numbering through the fudge option), so I don't think I will officially release a new version of SublimeLinter-jslint at this stage (I did create an issue at reid/node-jslint#135). That said, I did try the following modifications locally, which seemed to work with node-jslint's "latest" edition, so if you want to manually install SublimeLinter-jslint you could do these modifications locally: In def split_match(self, match):
"""
We override this method because new versions of jslint report line/col
numbers starting with 0 instead of 1, necessiating use of a setting to
allow transforming the numbers into matching line/col numbers in
Sublime Text
"""
startFromZero = self.get_view_settings().get('startFromZero', False)
match, line, col, error, warning, message, near = super().split_match(match)
if startFromZero:
line = line + 1
col = col + 1
return match, line, col, error, warning, message, near Then, in "jslint": {
"@disable": false,
"args": [
"--edition=latest"
],
"startFromZero": true,
"excludes": []
}, The |
You'll find that jslint.com is fudging the reported line/col numbers from the report.js script. node-jslint would need to adjust their own reporter.js script to make use of the data.option.fudge value. |
node-jslint now (as of version 0.10.0) supports fudging thanks to a recently merged PR (reid/node-jslint#150) by @pmw57, which means you can edit the jslint section in you "jslint": {
"@disable": false,
"args": [
"--edition=latest",
"--fudge"
],
"excludes": []
}, Kudos to @pmw57 for expediting fudge support! |
If you switch to edition "latest", "2015-05-08" or "es6" in the current node-jslint, the indexes for line and column in error reporting is now 0.
The default edition is still an old jslint from 2013 though, so I guess SublimeLinter-contrib-jslint needs a configuration option whether to adjust the lines and columns with one or not.
The text was updated successfully, but these errors were encountered: