

Google releases its own Javascript Lint tool  - edd
http://closuretools.blogspot.com/2010/08/introducing-closure-linter.html

======
stevelosh
Here's a couple of lines to let you use this with :make (on a single file) and
the QuickFix window in Vim:

    
    
        au BufNewFile,BufRead *.js set makeprg=gjslint\ %
        au BufNewFile,BufRead *.js set errorformat=%-P-----\ FILE\ \ :\ \ %f\ -----,Line\ %l\\,\ E:%n:\ %m,%-Q,%-GFound\ %s,%-GSome\ %s,%-Gfixjsstyle%s,%-Gscript\ can\ %s,%-G
    

If any experts in Vim's makeprg/errorformat want to clean this up, that would
be awesome. I just hacked it together and it seems to work well enough.

------
maw
The installation instructions tell you to run "easy_install [http://closure-
linter.googlecode.com/files/closure_linter-la...](http://closure-
linter.googlecode.com/files/closure_linter-latest.tar.gz). All well and good,
but install instructions that don't reference specific version numbers freak
me out. I might have gotten a little too much reproducibility religion, with
all that that entails, but it seems better than being so cavalier when setting
up environments.

~~~
rquirk
I'm not sure what easy_install does exactly, but I guess you could replace
latest with a version number. On <http://code.google.com/p/closure-
linter/downloads/> there's a 2.2.1 there, so instead of using "latest", you
could use "2.2.1". If you care enough about this, then you probably could do
some digging. Having a "latest" means they don't have to update the
instructions every release, and for most people this will Just Work.

~~~
prodigal_erik
easy_install is yet another single-language package manager. It doesn't
interop with the legitimate OS package manager's database of installed
dependencies, and your admins probably have very little experience with it.
Best to run it on one sacrificial box and then turn whatever it leaves behind
into a real RPM package (or whatever your platform wants).

~~~
maw
You can set things up so that easy_install installs into a special root. And
you nearly always should.

The closest to an exception I can come up with is when you rely on image-based
installs instead of package-by-package upgrades. And even then I can't manage
to convince myself.

No exceptions at all for individual developers' machines.

------
thechangelog
Does anyone know how this would differ from jslint? I couldn't find anything
immediately obvious.

~~~
maw
It gives you a different set of ridiculous warnings about things that have
nothing to do with your code's correctness.

Ha ha, only serious

But for real there are many warnings that pretty plainly seem to be about
enforcing somebody's preferences -- gjslint wants you to write "function()"
but jslint wants you to write "function ()", for example. Enforcing
conventions is good, but I'm pretty sure it's orthogonal to flagging real,
common problems (in javascript land, things such missing "var" or ";")

Using both and suppressing the stupid warnings doesn't seem like a bad idea,
if you can take the time to get it right.

~~~
btilly
In the example they gave, they had 9 errors. 1 was something that leads to
browser incompatibility. (Trailing comma at the end of the array. IE doesn't
implement the spec, Firefox does.) 1 was something that often points to logic
errors. (Inconsistent indentation.) And the other 7 were someone's idea of
correct style.

That said, I suspect that this lint tool will catch some issues where
technically correct code can make <http://code.google.com/closure/compiler/>
unhappy. If you're using the Closure library, that's kind of the whole point.

------
kilowatt
I was hoping I could run this realtime in vim, but it appears too slow on a
1000 line JS file.

------
kilian
Ouch, they shipped with a broken fixjsstyle command:
[http://groups.google.com/group/closure-linter-
discuss/browse...](http://groups.google.com/group/closure-linter-
discuss/browse_thread/thread/30fa86792d11b208) Luckily it didn't break my
jsfile, but that's kind of clumsy.

~~~
acdha
After fixing that, I ran into an even more surprising error which someone had
already reported - turns out a simple JavaScript closure chokes it:

(function() {})();

<http://code.google.com/p/closure-linter/issues/detail?id=3>

~~~
Hovertruck
I remember running into this issue with their minifier at some point as well.

------
eclark
It fails on file I have thrown at it with some complexity other than jquery.

