JsLint errors in DataTables source code when building

JsLint errors in DataTables source code when building

kmarxkmarx Posts: 3Questions: 1Answers: 0

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

  • allanallan Posts: 61,920Questions: 1Answers: 10,153 Site admin
    Answer ✓

    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 and is. 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

  • kmarxkmarx Posts: 3Questions: 1Answers: 0

    Followup:
    Sorry, I meant to include the complete list of files that have at least one jslint error.

    • 15 - DataTables\examples\resources\syntax\shCore.js
    • 21 - DataTables\extensions\AutoFill\js\dataTables.autoFill.min.js
    • 17 - DataTables\extensions\ColReorder\js\dataTables.colReorder.min.js
    • 10 - DataTables\extensions\ColVis\js\dataTables.colVis.min.js
    • 68 - DataTables\extensions\FixedColumns\js\dataTables.fixedColumns.min.js
    • 39 - DataTables\extensions\FixedHeader\js\dataTables.fixedHeader.min.js
    • 35 - DataTables\extensions\KeyTable\js\dataTables.keyTable.min.js
    • 14 - DataTables\extensions\Responsive\js\dataTables.responsive.min.js
    • 9 - DataTables\extensions\Scroller\js\dataTables.scroller.min.js
    • 23 - DataTables\extensions\TableTools\js\dataTables.tableTools.min.js
    • 6 - DataTables\media\js\jquery.dataTables.js
    • 25 - DataTables\media\js\jquery.dataTables.min.js
    • 38 - DataTables\media\js\jquery.js
  • kmarxkmarx Posts: 3Questions: 1Answers: 0

    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

  • allanallan Posts: 61,920Questions: 1Answers: 10,153 Site admin
    Answer ✓

    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

This discussion has been closed.