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.

  1. Bob (Buffone) says:

    It just got a lot easier to utilize JsLint inside of Eclipse using RockstarApps Web Optimization Plugins. Users can simply right click inside a Eclipse Editor and Choose the menu item - “Rockstarapp -> Validate with JsLint…” and the problems will be displayed via markers in the error like Java compile errors

    Checkout the following link for more information http://www.rockstarapps.com/joomla-1.5.8/products/jslint-eclipse-plugin.html

    Bob (Buffone)

  2. Mat says:

    Note that one needs to use the beta version installed from the ‘Eclipse Update site for the Beta Version of jsLex 1.2.2′ rather than the stable version to get the JSLint functionality.

  3. Great Blog says:

    It is nice to finally locate a website where the blogger knows really well about his subject.

  4. Revenge says:

    Оценка 5, базару ноль

  5. Kitty says:

    Афтар неутомим

  6. sloste says:

    Елки, глубокая заметка

  7. Jasmeet Singh says:

    It is giving this error

    Variable references empty selection: ${resource_loc}

    when i tried to validate js file using this.

  8. P5ycH0 says:

    What we really need is js validation upon saving a document. (or a keyboard shortcut to check the open js file).
    The rockstar jslint plugin is to many clicks away.

Leave a Reply



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