JS Lint in Sublime Text 2

Ahhhh, Javascript. A great language, often misunderstood and misused on the web. You might not have a clue what you’re doing if you’re a beginner because almost everything you type can be interpreted in a way that is completely different than what you intended—that flexibility can also be an somewhat of an advantage.

I ‘m a big fan of JS Lint and as a front end web developer I need a linter to help me validate and maintain my code quality against best practices so I can use the language the way it was intended to use, and maintain form. When it comes to editors I use the popluar Sublime Text 2 as my default editor (as many web developers do these days).  Luckily integrating JS Lint by Crockford in Sublime Text 2 is a breeze.

Just follow the steps below:

Sublime Text 2

  • Obviously, you need to install Sublime Text 2. It’s lightweight, cross platform and performs like an athlete on steroids-blazing fast.
  • Using the console, install Sublime Package Control. Paste in the following commands:

While the package is installing you should see installing [ = ] loader on the bottom left. Then all you have to do is to restart Sublime Text 2.

  • Next. Goto: Projects > Package Control > Install Packages and type in “JS Lint”. You’ll immediately see a list of packages you can install. You’ll also notice that another version js lint with node.js. You may also prefer JS Hint. To get to package control in your Mac: CMD + Shift + P ==> Win, Linux users: try these shortcuts
  • Your last step is to get JS Lint to work after you save any javascript file. Go to Preferences > Package Settings > JSLint > Settings > User Then paste in the following commands:

Now on save you should have your linter below where the console pops up:

Sublime Text 2

If you run into problems with the console you can perform manual steps to install package control. Of course for the curious there is are a slew of packages / plugins out there, so go ahead and enjoy playing around with this lovely text editor.