javascript syntax check for Internet Explorer

Udo G picture Udo G · Jun 29, 2011 · Viewed 13.5k times · Source

Is there some tool that can syntax-check my JavaScript files to see if they contain syntax errors that would bother the Javascript engine of Internet Explorer, especially excess trailing commas?

Example:

var some_object = {
  valid : "property",
  one : "comma too much ---> ",
};

This code works fine in FireFox, Chrome and Node.JS but fails in IE because of the trailing comma. The integrated debugger of IE is rarely a help since it doesn't produce useful errors/warnings for large web applications as we have (lots of JavaScript files combined together summing up to 50-100 k lines of code).

JSLint doesn't help as it reports a huge amount of other warnings or stops at some meaningless error.

One idea could be using eval() directly within IE and catch SyntaxError exceptions but I can't do this in an automated way (ie. on a command line).

Unfortunately Node.JS doesn't bother about trailing commas.

No Linux / Windows tool around that can do basic JavaScript syntax checking for a file?

Answer

Prusse picture Prusse · Jun 29, 2011

You can try also http://www.javascriptlint.com/. After installed, you may edit jsl.default.conf to set the warnings reported.

jsl -process file.js