in Tutorials Web . 75,827 views and so far.

Sublime Text is a very popular code editor for web work, and for good reason: it is extremely powerful and easily extended.

JSHint is “a tool to detect errors and potential problems in JavaScript code and can be used to enforce coding conventions”: it’ll check your JavaScript and let you know of any perceived imperfections before you deploy it.

You probably don’t want to be pasting into the web interface every time you want to check some code so let’s get JSHint installed into Sublime Text 2.

JSHint depends on Node.js, so download it and install it using the installer. It’ll put its files in your hidden /usr/local/bin folder. Next make sure you have Package Control installed in Sublime Text (this should probably be the first thing you do with the program). Follow the instructions at the link. Bring up Package Control inside Sublime Text by using (on a Mac) Cmd-Shift-P. Begin to type “install” in the search box and hit return when “Package Control: Install Package” appears. Begin to type “jshint” and you’ll see that Package Control finds not one but two options:

Now, if you install the first one you might find you get this error when you try to check a JavaScript file:

[Errno 2] No such file or directory

[path: /usr/local/share/npm/bin:

/usr/local/bin:/opt/local/bin]

The solution is to install the second instead, “Sublime-JSHint”. Once this is done, go to Tools → Build System in Sublime Text and select JSHint.

Now when you open up a JavaScript file you can use Cmd-B to check it (or use Tools → Build from the menu) and JSHint will do its stuff!

Look at all those lovely errors! (JSHint’s defaults are actually very strict but these can be configured to your liking.) Happy coding!