What steps will reproduce the problem? 1.Run this code through jslint4java // Filter level 1 $('#level1 div.nav-con div.ArrayCollection').each(function(i, o) { var iteratedLevel1Id = jQuery.data(o, 'level1Id'); if (iteratedLevel1Id === level1IdToShow) { $(o).show(); } else { $(o).hide(); } });
2.Run this code on jslint at jslint.com or using other jslint text editor tools.
What is the expected output? What do you see instead?
- the unused variable i should be reported but isnt in jslint4java.
What version of the product are you using? On what operating system?
- 2.0.2
Please provide any additional information below.
- running via powershell. Other errors being reported as expected but not any unused vars. Config: --report "junit" --sloppy --plusplus --sub --vars --predef "$, jQuery, Sys, Window, SWFAddress, SWFAddressEvent, document" --maxerr 1000 --evil
Comment #1
Posted on Mar 6, 2012 by Happy BearI see the same thing you do:
% java -jar /opt/misc/jslint4java/jslint4java-2.0.2.jar --report "junit" --sloppy --plusplus --sub --vars --predef "$, jQuery, Sys, Window, SWFAddress, SWFAddressEvent, document" --maxerr 1000 --evil ~/Desktop/issue78.js /Users/dom/Desktop/issue78.js:2:59:Expected exactly one space between 'function' and '('. /Users/dom/Desktop/issue78.js:4:30:'level1IdToShow' was used before it was defined.
However, if I switch the report type to the HTML report:
% java -jar /opt/misc/jslint4java/jslint4java-2.0.2.jar --report "report" --sloppy --plusplus --sub --vars --predef "$, jQuery, Sys, Window, SWFAddress, SWFAddressEvent, document" --maxerr 1000 --evil ~/Desktop/issue78.js
/Users/dom/Desktop/issue78.jsError:Problem at line 2 character 59: Expected exactly one space between 'function' and '('.
$('#level1 div.nav-con div.ArrayCollection').each(function(i, o) {Problem at line 4 character 30: 'level1IdToShow' was used before it was defined.
if (iteratedLevel1Id === level1IdToShow) {Undefined variable: level1IdToShow
2 'each'
Unused variable: i
2 'each'
Global $, jQuery
2 'each'(i, o)Unused iVariable iteratedLevel1IdGlobal $, jQuery
/*properties
data, each, hide, show
*/
You can see the “unused variable” mentioned in there. Unfortunately, this is not reported back to jslint4java via the usual mechanisms, only in the HTML report.
Just to check I've downloaded the latest JSLint and verified that the same behaviour occurs.
Comment #2
Posted on Mar 7, 2012 by Happy GiraffeThanks for confirming the bug.
Do you think this might be looked at for a later release?
We're hoping to use the tool as part of our server build to run a JsLint after check-in.
On the developers' machines we're looking at having a plugin like JsLint.VS2010 to validate as part of the local build. This would catch unused variables before the dev could check in for the situation above. This isnt failsafe though of course because the dev could always alter their local config then our server build with this version of JsLint4Java would miss it.
thanks again
Comment #3
Posted on Mar 7, 2012 by Happy GiraffeOne more thing - Just noticed the same for "Line too long" errors in the above example. They show when using JsLint.VS2010 but not with jslint4java as described above.
Comment #4
Posted on Mar 7, 2012 by Happy BearGiven what the JSLINT() function reports back, I'm unlikely to be able to support this any time soon. Have a look at the supported APIs:
https://github.com/douglascrockford/JSLint/blob/master/jslint.js
The only API that returns the necessary information is the HTML report. In order to usefully interpret that, I'd have to end up parsing it, which is quite fragile. Although, looking at the source code for the report function, it appears that most of the information is exposed via the .data() function, which we already extract. Let me have a think about this.
Comment #5
Posted on Mar 13, 2012 by Happy BearFixed in: 9ffed2ce
https://github.com/happygiraffe/jslint4java/commit/9ffed2ceb7cf2201938ef9022f0614024a5d1496
Comment #6
Posted on Mar 14, 2012 by Happy Bear(No comment was entered for this change.)
Comment #7
Posted on Mar 28, 2013 by Quick CamelThis is marked as fixed, but it still isn't working. If it isn't supportable, then okay, but why is it marked as fixed?
Comment #8
Posted on Apr 10, 2013 by Happy BearIt is fixed, but you need to add a --warnings flag. This is less than ideal, so it should be made the default.
Status: Fixed
Labels:
Type-Defect
Priority-Medium
Milestone-Release2.0.3