I develop quite a lot javascript these days and a perfect tool to ensure code quality is JSLint. Back then I had it integrated into TextMate, the same can be done to Sublime Text 2 through it’s build Environments.

I’m going to show you how to do it:

1. Create a new Build Environment in Sublime Text:

Afterwards a file will open, paste the following text into it:

{
"cmd": ["java", "org.mozilla.javascript.tools.shell.Main", "/Users/YOURUSERNAME/Library/JSLint/jslint.js", "$file"],
"selector": "*.js"
}

Save the file at this Location:

/Users/YOURUSERNAME/Library/Application Support/Sublime Text 2/Packages/User

Replace YOURUSERNAME with your username e.g. nicam

2. Install Rhino on your system

$ curl ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R3.zip > /tmp/rhino.zip
$ cd /tmp
$ unzip rhino.zip
$ mkdir ~/Library/Java
$ mkdir /home/nicam/Library/Java/Extensions
$ mv /tmp/rhino1_7R3/js.jar ~/Library/Java/Extensions/

3. Install JSLint

$ mkdir ~/Library/JSLint
$ curl http://dl.dropbox.com/u/419439/jslint.js > ~/Library/JSLint/jslint.js

4. Enjoy

In your SublimeText 2 just hit CMD+B to execute the build.



  1. Julian on Wednesday 20, 2011

    Nice tip! I’ll give this a try with Node (since I already have that installed and it’s faster than Rhino, obviously) :)