Sublime Forum

(V2 only) JavaScript Google Closure Linter Build

#1

Hey all,

I use this build file to test my JavaScript code against Google Closure Linter standards :smile:

{ "cmd": "gjslint", "$file"], "file_regex": "^Line ([0-9]*), E:(-0-9]*): (.*)", "selector": "source.js" }
Iā€™m going to change this in the future to also include Google Closure Compiler.

Cheers,
James

Updates
Added capture for negative error numbers. (First time Iā€™ve had one)

0 Likes

#2

Thanks. This will be handy.

I know this is for v2 but for any new people it might make sense to keep the version number in the post title to differentiate.

0 Likes

#3

Or even better. Maybe jon can setup a new topic under the forums for v2 plugins?

0 Likes

#4

[quote=ā€œn00geā€]Thanks. This will be handy.

I know this is for v2 but for any new people it might make sense to keep the version number in the post title to differentiate.[/quote]

Cheers n00ge :smile:

I changed the title by the way!

0 Likes

#5

Updated this to match line numbers in the output, so can click on the errors.

Also using a patch that enables rules to be turned off, since I donā€™t agree with line lengths of 80: http://codereview.appspot.com/4291044/

{
   "cmd": "C:\\Python27\\Scripts\\gjslint", "--ignore_errors", "110", "$file"],
   "file_regex": "FILE ]*: ]*(.*) ",
   "line_regex": "^Line ([0-9]*), E:.*",
   "selector": "source.js"
}

Works much better now I think.
Would be nice to run against a whole project and get the matching working but not sure if thatā€™s possible; this good enough for me for the moment.

Cheers,
Westy

0 Likes

#6

Hereā€™s a build script I made to run Google Closure to compress javascript files.

Create a new files in ā€œpackages/Google Closure/Google Closure.sublime-buildā€

{
	"cmd": "java", "-jar", "${packages}/Google Closure/compiler.jar", "--js", "$file", "--js_output_file", "${file_base_name}.min.${file_extension}"],
	"selector": "source.js"
}

then download the Google Closure binary from code.google.com/closure/compiler/ and unzip into the packages/Google Closure folder.
Restart SB2 and your done.

Running the build process will create a new file called your_file_name.min.js

0 Likes