Monday, August 17, 2009

JSLint with Eclipse

Some simple steps to check your JavaScript Code with JSLint:

  1. download and install JSRhino
  2. make it somehow available, e.g. create a js.bat (one line: java -jar "path/to/rhino/js.jar" %*
  3. download JSLint and put it in some folder, e.g. /path/to/jslint.js
  4. Add an external tool configuration in Eclipse:

    Location: path/to/js.bat

    Working Directory: ${workspace_loc}

    Arguments: path/to/jslint.js ${resource_loc}

  5. you can now check your JavaScript code with JSLint by calling this external tool.


P.S.: There is a very interessting talk by Douglas Crockford  (creator of JSON and JSLint) at google tech talk that highlights the good and bad aspects of JavaScript. I liked that a lot.