Saturday, 19 September 2009

Checking Javascript Files With JSLINT in Netbeans

Enough about minifying JavaScript, what about checking JS files with JSLint too.

Try this in NetBeans:-

Download the latest lib from and put in your ant/lib directory or on the class path. I put it in the netbeans project folder in the example.

Override the pre-compile ant target in your netbeans build.xml so that it looks something like the following example, substituting the class path and includes as appropriate:-

When you build your web application the chosen JavaScript files will be run through the JSLint ant task and checked for errors, the build will fail if any problems are found.

This has saved me hours of debugging JavaScript especially when using cross browser JS libs such as EXTJs.