JsLint errors in DataTables source code when building
JsLint errors in DataTables source code when building
Hi. I've created a nice utility page that uses DataTables-1.10.6. But upon checkin, it fails our automated build process with about 320 JsLint errors. I can reproduce these from the command line a la
java -jar C:\<mumble>\lib\jslint.jar jquery.dataTables.js
error: ...jquery.dataTables.js, line 7990: Expected an identifier and instead saw 'namespace'. (a reserved word)
error: ...jquery.dataTables.js, line 7991: Expected an identifier and instead saw 'namespace'. (a reserved word)
error: ...jquery.dataTables.js, line 7992: Expected an identifier and instead saw 'namespace'. (a reserved word)
error: ...jquery.dataTables.js, line 8833: Expected an identifier and instead saw 'is'. (a reserved word)
error: ...jquery.dataTables.js, line 8833: Bad assignment.
error: ...jquery.dataTables.js, line 8837: Expected an identifier and instead saw 'is'. (a reserved word)
These and the bunch that I get from the minified jquery.js
file are the greatest concern (since the others are mostly minified example code, and I can just remove them from our source tree - sad though that seems to me).
An example of the errors from jquery.js
is:
error: ...jquery.js, line 2: Expected an identifier and instead saw '='. (Enclose return value in parentheses?)
error: ...jquery.js, line 2: Expected an identifier and instead saw ','.
error: ...jquery.js, line 2: Expected an identifier and instead saw ','.
... and so on
I searched the web and the DataTables.net site and didn't really see anything about this issue. Am I doing something wrong, or is there some way around this? I don't really have the option of changing what our JsLint Ant target allows or not.
I suppose I could hack jquery.dataTables.js
and "fix" those, and maybe download jquery separately and use an un-minified version. Haven't tried this yet.
Any guidance much appreciated.
Thanks,
Ken
This question has accepted answers - jump to:
Answers
Hi,
Thanks for flagging this up. I run JSHint on very build of DataTables, so normally I should catch such errors.
However in this case, I'm not sure I understand why JSLint is checking for
namespace
andis
. Neither are in the reserved words for ECMAScript 6, or in ECMAScript 7.Searching the JSLint repo I don't even see where it would be checking for
namespace
.Allan
Followup:
Sorry, I meant to include the complete list of files that have at least one jslint error.
Hi Allan,
Thanks for the quick and thorough reply. I've marked this as answered. I think JSHint is probably more up-to-date and in compliance with the spec(s) and, it turns out, I don't even know the provenance of our jslint.jar, but it was last updated in our build framework back in 2007.
We may, in fact, swap that out for JSHint when I get the time. But for now, it turns out that I lied about flexibility in control I have over what we check or not. The accepted practice seems to be to run jslint over only our own source and skip 3rd party packages. So I've simply
--exclude
'd the flagged directories in the build.xml, and all is good.Thanks again for your time,
Ken
The min files will never pass JSLint. The compiler uses all sorts of nasty (/lovely :-) ) tricks to make the code smaller that are perfectly legal code, but you wouldn't want ot read it, which is in part what JSLint is about.
Allan