Sublime Text is a very popular code editor for web work, and for good reason: it is extremely powerful and easily extended.
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
- 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)
- 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:
[Errno 2] No such file or directory
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.
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!