In our current project we are using JSLint for verifying that Javacript is written correctly, and that it satisfies a few style checks. This is included as an Ant task in our build.xml
.
However, I have found that the license of JSLint makes it incompatible with free and open-source software:
// The Software shall be used for Good, not Evil.
I also find JSLint a bit too overzealous in its checks, and makes JQuery-based development difficult. I understand that its intent is not to help one develop scripts, but to check that the script will work in most existing language implementations.
Finally, it's just not smart enough with its scoping: what's wrong with defining a variable in the head of a for
loop? (i.e. for (var i = 0; ...)
rather than var i; for (i = 0; ...)
).
(EDIT: This is actually a problem with Javascript itself. JavaScript does not have block scope, unlike most C-like languages.)
What alternatives exist for verifying the syntax and style for Javascript scripts, intended to be executed within modern web browsers? Any implementation language is fine. I've even thought about using the Rhino library to load and execute the script within Java.