Google Closure Linter TextMate Bundle
I love the Google Closure project. As a big fan of its compiler and the linter, I use both regularly at work and for my personal projects. However, it is not without its flaws. The biggest hurtle to integrating the Closure Linter into my workflow: it's strictly a command line tool. I have nothing against using the terminal but, the workflow for running the linter over my JS looks like this:
- Make some changes to the JS file.
- Open the terminal, run gsjlint source.js
- Look over the results (ugly terminal output).
- Jump back to the Editor, and find where the problems were.
- go to 1.
This tedium quickly became frustrating. I wanted a more automated approach to running the Closure Linter; so I hacked together a TextMate Bundle to make all of our lives a little easier. I was able to integrate the linter into my TextMate workflow without a hitch. Thus, here's my new workflow:
- Make some changes to the JS file.
- Hit "Shift + Ctl + Opt + A", results appear in a TextMate Browser window, next to the code.
- Keep making changes, and using keyboard shortcut to update the linter window.
Here's a screenshot of this new workflow in action:
Pretty neat! However, some of the changes that the Closure Linter wants you to make are monotonous. I don't want to waste time putting a space before my = sign, or converting double quotes " to single quotes '. Luckily, part of the Closure Linter utilities is a "fixjsstyle.py" utility that will run over your JS and perform all of those little corrections for you. I've included this in the Bundle with the shortcut "Shift + Ctl + Opt + Z". This will run the style fixer over your current file and display what it fixed in a tooltip.
If you're interested in giving it a try you can download the bundle directly. The Closure Utilities are required for this bundle to work. Alternatively, the source code is available on GitHub. The README contains installation instructions for the git version; you can keep the bundle up to date using the GetBundles manager (which you should be using if you aren't already). If you find any bugs, or have any feature requests, GitHub has a great Issue Tracker that I'd love if you used. This way I can keep everything in one spot. Feel free to fork and contribute any patches; all are welcome.