Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript syntax check for Internet Explorer [closed]

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?

like image 870
Udo G Avatar asked Jun 29 '11 16:06

Udo G


People also ask

How do I know if I have Internet Explorer 11?

I tested the script with IE11 emulator. To find the IE11 emulator, right-click on the web browser click "Inspect element". At the bottom-left of the page, scroll down the navigation bar and click the desktop icon. The "User Agent String" dropdown box contains options to emulate IE6-11.

How can I tell if Internet Explorer is being used?

To detect whether the current browser is Internet Explorer, you can make use of the navigator. userAgent property. The userAgent property returns the value of the user-agent header sent by the browser to the server. It contains information about the name, version, and platform of the browser.


1 Answers

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

like image 99
Prusse Avatar answered Oct 05 '22 04:10

Prusse