Javascript is a very powerful language. I continue to be amazed by what can be accomplished using its prototypes and associative arrays. But its loose typing and reliance on external interpreters means that any non-trivial program will eventually require hours of testing and debugging on each platform that you want it to run on (Firefox, Internet Explorer, Opera, Safari, ...).

In an attempt to minimize this debugging time, I set out a while back to find a lint program that would check for bad coding practices. I found JSLint, but quickly learned that it is far too picky on what it reports as problems. For example, it will report the instantiation of a class if it hasn't been assigned to a variable: new Ajax.Updater( ... ); instead of var j = new Ajax.updater( ... );

This is perfectly legal Javascript and often a good idea. For example, when using Prototype, the Ajax.Updater class doesn't return anything useful. There were numerous other bogus warnings from JSLint.

I also wanted to integrate Javascript checking into my local build environment. Since JSLint appears to be online only, this was not convenient.

Recently I found JavaScript Lint, a command-line tool that does exactly what I need. It comes with an extensive configuration file that lets you control exactly which warnings you want to suppress. So, for example, I don't like warnings complaining about missing semicolons at the end of lines as this is perfectly legal in Javascript! But I do want warnings about variables that are used without being declared first.

Check it out if you program Javascript!

tags: javascript programming
permalink | comments | technorati