Skip to content
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

Please support the new "fudge" option in JSLint #135

Closed
devdoc opened this issue Jul 20, 2015 · 6 comments
Closed

Please support the new "fudge" option in JSLint #135

devdoc opened this issue Jul 20, 2015 · 6 comments

Comments

@devdoc
Copy link

devdoc commented Jul 20, 2015

The new JSLint seems to default to 0-based indexing of row/column numbers, which creates problems when trying to map reported errors to text editors which usually use 1-based numbering (see devdoc/SublimeLinter-jslint#5). JSLint seems to include a new option called "fudge" that can be used to revert to 1-based numbers in its reports, but this option does not seem to work with node-jslint. This seems to happen even if the fudge option is included in the Javascript file to be linted as an inline option (/*jslint fudge: true */) which makes me wonder whether there is a bug in JSLint itself. The inline directive does seem to work on jslint.com, though.

@bryanjhv
Copy link
Contributor

Yeah, that's a bit annoying because it works in JSLint web interface but when you open Developer tools and pass a JavaScript source to the jslint function, it is working the same as described... @douglascrockford, any explanation of this behavior?

@bryanjhv
Copy link
Contributor

BTW, the file report.js in the JSLint repo seems to override fudge option only for reports. https://github.com/douglascrockford/JSLint/blob/430ff1f73384a7e002aefcf31c433a5737cd9ccd/report.js

@smikes
Copy link
Collaborator

smikes commented Jul 29, 2015

Douglas doesn't come 'round here, this is the node-based repackaging of jslint. I can take a look at this in the next day or so, thanks for bringing it up.

@pmw57
Copy link
Contributor

pmw57 commented Apr 12, 2016

After taking a quick look at things, the jslint.js script doesn't fudge the line/col values. Instead, it's the report.js file that provides the on-screen report and uses the data.option.fudge value to apply any needed fudging.

Line 37 of report.js:

var fudge = +!!data.option.fudge;

@pmw57
Copy link
Contributor

pmw57 commented Apr 12, 2016

I have found good success by editing jslint\lib\reporter.js - here's what needs to change.

Add a fudge variable to the exports.report function:

errors,
fudge = +!!lint.option.fudge,
logger = this.logger,

Update the terse output

logger.log(file + ':' + (e.line + fudge) + ':' + (col(e) + fudge) + ': ' + message(e));

Update the normal output

line = ' // Line ' + (e.line + fudge) + ', Pos ' + (col(e) + fudge);

And that is all that needs to be done to report.js

Now the node version of jslint will change its output based on a command-line option, or a jslint directive.

The only other change to make if you want this to be permanent, is to update the SublimeLinter user settings so that when you use the latest or es6 edition, you also include the fudge argument.

"args": [
    "--edition=latest",
    "--fudge"
],

And job's done. The report will now update it's output based on a command-line option, a settings file, or a jslint directive at the top of the code.

@smikes
Copy link
Collaborator

smikes commented May 16, 2016

Now supported - merged PR #150. Thanks for the PR, sorry about the delay.

@smikes smikes closed this as completed May 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants