jslint4java tolerates unused variables
I have downloaded and set up jslint4java. When I use the following command:
java -jar C:\...\jslint4java-2.0.0.jar --encoding UTF-8 --indent 4 --browser *.js
Although there are some unused variables in the file, jsLint does not complain about them. I want it to. But I did not find any appropriate option in the command line docu.
Any advice on what setting I am missing there?
Note: This is about variables not method parameters. I found the --unparam
option, but it is about parameters, and it is for dis-abling rather than for en-abling the check. I do not use this option, so the check is supposed to work.
The jslint for Visual Studio plug-in does complain about the unused variables.
Simple code example:
$(document).ready(function() {
var a = 0,
b = 1;
alert(b);
});
In this example, the jslint for Visual Studio plug-in correctly complains about variable a
not being used, whilst jslint4java doesn't.
Do you have a code sample where it complains? If the result is different to jslint.com with the same options selected, it's a bug in jslint4java (though please bear in mind that jslint4java may be running a slightly older version of JSLint).
I've figured out what's up. It's not necessarily a bug in jslint4java. You do see the "unused variable" warning if you specify --report report
on the command line. JSLint produces an optional HTML report on your code in addition to any warnings. That must be what the VS plugin is using. I've got no idea why they're not surfaced as regular JSLint warnings.
You're not the only one to notice this: http://tech.groups.yahoo.com/group/jslint_com/message/2526
The unparam
option controls unused parameters. Default is that it will complain. If jslint4java doesn't, it's probably a bug. Internally to jslint, unused parameters are passed in a separate field after the analysis, jslint4java might have missed it.
精彩评论