Saturday, December 24, 2011

jslint config in sublime-jslint

I'm new to Sublime Text but I'm quickly becoming a fan. Based on Kelly's recommendation, I installed Sublime Text 2 and Sublime Package Control.

After doing some basic editing I decided to go get a jslint package. I installed sublime-jslint and ran it. Easy peasy but I got warnings because I like 2 space indents instead of 4 in my code and some node-specific stuff.

jslint:mystuff.js:5:12:'require' was used before it was defined.
jslint:mystuff.js:6:3:Expected 'winston' at column 5, not column 3.
jslint:mystuff.js:7:3:Expected 'service' at column 5, not column 3.
jslint:mystuff.js:9:1:'exports' was used before it was defined.
jslint:mystuff.js:10:3:Expected 'use strict' at column 5, not column 3.
jslint:mystuff.js:11:3:Expected 'var' at column 5, not column 3.
jslint:mystuff.js:12:5:Expected 'server' at column 9, not column 5.
jslint:mystuff.js:13:7:Expected 'winston' at column 13, not column 7.

I changed my user settings in the jslint package to add configuration options. The documentation from sublime-jslint had the info on how to configure it but it wasn't totally clear so took me a couple tries to get it right.

Here are the entire contents of my sublime-jslint.sublime-settings file:

"jslint_options": "--indent 2 --node"

Now when I use jslint (by clicking ctrl-j) I get nice results.

mystuff.js lint free!
jslint: ignored 0 errors.

1 comment:

Anonymous said...

Just wish to say your article is as surprising. The clearness in your post is just great and i can assume you are an expert on this subject. Well with your permission let me to grab your feed to keep updated with forthcoming post. Thanks a million and please carry on the rewarding work.