I\'d like to use JSLint, but I 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 \"
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.
(source: googlecode.com)
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.
Instead of downloading with a browser, you can also directly download the sources. This has the advantage that you can update them with the versioning system, and read the commented source code.
git clone https://github.com/douglascrockford/JSLint.git
This gives you HTML and JS source files, but you cannot use them as they are. Follow the build process in README
. In a nutshell, you need to git clone
two other JS projects of Douglas Crockford, then concatenate (and minimise) some JS files from all three git repositories into web_jslint.js
.
I did it like this, with the YUI Compressor:
cat ../ADsafe/adsafe.js ../JSON-js/json2.js intercept.js jslint.js > /tmp/web_jslint.uncomp.js
java -jar ../../yuicompressor-2.4.7.jar /tmp/web_jslint.uncomp.js > web_jslint.js
Then open jslint.html
with your browser.
If you already use ruby gems then you may install jslint gem in one command : http://rubygems.org/gems/jslint
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.
UPDATE: 2013.11 - if you're using node.js on the commandline (and why wouldn't you?) you can run both jslint and the new eslint. [NB: I have contributed bug-reports and test-code to eshint.] Both of these are way easier to setup than what I have above....
If you're using TextMate, the JSLintMate bundle has a simple interface, supports both JSLint and JSHint, and lets you set custom options in various ways (e.g., a config file per project, global options across all projects).