javascript syntax check for Internet Explorer [closed]
Asked Answered
G

2

15

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?

Goodkin answered 29/6, 2011 at 16:56 Comment(1)
What trailing slash? I don't see one in your example. You mean "trailing comma"?Bluebottle
S
5

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

Sirenasirenic answered 29/6, 2011 at 17:6 Comment(1)
This helped me too, It was required that it worked on ie7 and one small error was proving a lot of problems, thanks for jslFunctional
B
-5

Our JavaScript Formatter will prettyprint your JavaScript code. It uses a full JavaScript parser to do so. It reports syntax errors as it parses. Windows.

Bluebottle answered 29/6, 2011 at 17:4 Comment(2)
7 years in and this get downvotes. Will the downvoter please explain how this doesn't solve exactly the problem posed?Bluebottle
Your answer is unclearly worded, your given solution costs money, it only works on Windows, and there are no docs on your site that specify whether its correctness check even meets the OP's needs. Namely, whether it can handle browser specific linting. Your site doesn't even say what JS engine it's validating against.Backstroke

© 2022 - 2024 — McMap. All rights reserved.