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:
- 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:
|
1 |
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation') |
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:
|
1 2 3 4 5 6 7 8 9 10 |
{ // there are others as well, such as white space // if you don't prefer Crockford's whitespace usage. // this is to run jslint on save "run_on_save": true, // debug flag. "debug": true } |
Now on save you should have your linter below where the console pops up:
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.



Comments on this entry are closed.