views:

1432

answers:

11

I'd like to use JSLint but am wary of tools that have access to my unfiltered source-code. Is there an offline version or is there another similar tool that does "lint error checking" for JavaScript offline?

Edit: One with a GUI / shows you a styled list of errors, instead of command line?

+4  A: 

JSLint can be run offline with either WSH or Rhino:

http://www.jslint.com/lint.html#try

Ben Blank
+3  A: 

YSlow for Firebug has this feature built in

David Caunt
Direct link to JS lint screenshot http://developer.yahoo.com/yslow/help/#js_lint
Jenko
Ooops. Aparently it "submits it to JSLint"... online.
Jenko
Ooops - my bad sorry
David Caunt
+9  A: 

Yes:

Basically, you just need an embedded JavaScript compiler to run jslint.js.

jakemcgraw
No GUI except command line / IDE.
Jenko
I prefer the CLI version, you can automate a report after building, but to each his own.
jakemcgraw
+8  A: 

If you like the JSLint web interface, you can do File > Save Page As... and Save as type: Web Page, complete (in Firefox, doing it in Internet Explorer may be slightly different) to a local folder.

I change the name to jslint.htm to get it under 8.3 with no spaces.

It seems to work when saved locally.

Three things:

  1. This may violate his license, although I leave the Copyright intact and don't modify any of his code, and technically my web browser already created a copy of his site on my local HD, so I'm not sure whether I'm in violation or not and I'm not a lawyer so I'll keep doing this until I get a letter telling me to stop.
  2. The page may somehow still be able to send your code to the Internet, although the chance of it being possible is very remote. That said, the WSH or Rhino versions could probably send the code you submit to the Internet easier than a version in a locally saved web page could (if you're paranoid).
  3. You'll get behind on any bug fixes or updates Douglas does. But the same thing applies to the WSH or Rhino versions if you don't update them regularly.
Grant Wagner
Pretty good idea.
Jenko
Here's the link to "the web interface" for those who don't know. http://www.jslint.com/
Jenko
@Jeremy: Included the link in the answer. Thanks for pointing that out.
Grant Wagner
A: 

Since JSLint itself is written in JavaScript, you can run it offline by copying the HTML and referenced JavaScript files locally. IE7's "Save As..." "webpage, complete" feature does this just fine.

Travis Beale
+2  A: 

There's another JS Linter, called JavaScript Lint, that has both online and downloadable command line versions. I use the downloadable version all time. I've been thinking about integrating it into SVN as part of a hook. I like it better than JSLint because it has more options and seems to detect more things. It can be configured to treat certain identifiers as predefined, for toolkits and the like, which allows it to check for usage of undefined variables, which I'm pretty sure JSLint can't do.

rmeador
+1  A: 

I have a tool for running jslint from the command line with either the Spidermonkey shell or Rhino. It also includes a plugin for VIM that allows you to press a button to automatically highlight any problem lines while editing a file:

http://github.com/hallettj/jslint.vim/

Jesse Hallett
+2  A: 

If you're in a Java environment, you may find my jslint4java tool useful. It comes in a command line variant, and can also be integrated into an ant script. No GUI, because I suck badly at those. :-)

Dominic Mitchell
This is great - especially the ant task (http://jslint4java.googlecode.com/svn/docs/1.3.3/ant.html)
Glenn Barnett
A: 

Cory Bennet has a good post on command-line JSLint. Much of your setup will be getting SpiderMonkey working. Not so bad if you're running Linux; a wee harder if you're using windows and CygWin. And here are some more discussion and comparison with Rhino run-times.

Michael Paulukonis
A: 

There is a great Yahoo Widget:

http://ajaxian.com/archives/jslint-multi

It is open source, if you are paranoid you can audit the code.

alt text

+2  A: 

If you use TextMate, I've made a bundle that runs JSLint and displays the output in a graphical window. It's all self-contained; nothing else needs to be installed to use it:

View JSLint.tmbundle at GitHub

Geoffrey Grosenbach