Running JSLint In Eclipse On Windows

Eclipse is such a wonderful and extensible development environment that all of us here at Linkstorm do our development work with it.  Whether we are working on front-end or back-end code, the various plugins available to assist us are vast.

Much of our JavaScript development is done within Eclipse using the JSEclipse plugin (which is now only available as part of the Adobe Flex Builder installation).  If you’ve worked extensively with JavaScript you’re familiar with the repetitive nature of testing and debugging the code using the various verifiers and debuggers out there.

One particular JavaScript verifier that I constantly find myself running code through is Douglas Crockford’s JSLint.  For those that aren’t aware of what JSLint is, it is simply itself a JavaScript program that looks for issues and problems in other JavaScript programs and checks the syntax. As you can imagine, the process for copying, pasting, and validating code through the JSLint web interface is very tedious and repetitive.  Fortunately there is a version of JSLint made specifically for Rhino.  Rhino is essentially a Java implementation of JavaScript and is what allows us to run JSLint locally.

Running JSLint through the command line locally is already much easier than the whole web interface process, but by taking it further and integrating it into Eclipse further helps speed up development time.

Here’s how I got it working within Eclipse on my Windows box. First you’ll need to download both Rhino & JSLint.  You’ll only need to download the Rhino binary.  After you’ve downloaded both items, you’ll want to place the Rhino “js.jar” and JSLint “jslint.js” files into an easily accessible directory.

Now you’re all set to get it running through Eclipse.  Within Eclipse you will need to get to the External Tools Configuration screen by selecting the drop down from the external tools icon on your toolbar.

From the configuration screen you’ll want to select “New Launch Configuration” to create a new configuration for the external tool.

Here you can name your new configuration JSLint to identify it and enter in all the configuration settings.

You will only need to input values on the “Main” tab.  For the “Location” you will need to point that to where your JAVA resides.

The other important configuration to input is the “Arguments”. You will want to enter:

-jar file_path_to_rhino/js.jar file_path_to_jslint/jslint.js ${resource_loc}

Once this is complete you are all set to run JSLint on your JavaScript files from within Eclipse.  To run JSLint on a file simply highlight it in the Explorer and select your JSLint External Tool configuration you have created. The output from JSLint will show up in the Console tab.

You can leave a response, or trackback from your own site.

Leave a Reply

Your Privacy is important to us. We will never give, lease or sell your personal information.