TextMate has a number of great bundles which help you develop in many many languages. The feature I miss most is formatting for JavaScript just like Perl Tidy does it for Perl.
I recently saw JavaScript::Beautifier in the “Recent” list on the CPAN and was wondering if I can bind it to TextMate. This is how I did it:
First of all, install it:
sudo cpan -i JavaScript::Beautifier
Next, add the command to TextMate. Open the Bundle Editor (Bundles/Bundle Editor/Show Bundle Editor).

Then select JavaScript and click on “New Command” (bottom left).
Name it “Beautifier” (or whatever you want) and paste the following in the command text field:
require_cmd js_beautify.pl 'sudo cpan -i JavaScript::Beautifier' js_beautify.pl $TM_FILEPATH
Set the rest of the options like this:
Now you are ready to go! Open up a JavaScript document and hit Shift+Crtl+H and the current document should be formatted.
