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 "lint
error checking" for JavaScript offline?
Edit: One with a GUI and that shows you a styled list of errors, instead of a command line interface?
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
I have JSLint with Node.js validating code in my deploy scripts to ensure I don't accidentally push code that could break my site. It can save a lot of time handling customer support issues later.
If you already use ruby gems then you may install jslint gem in one command : http://rubygems.org/gems/jslint
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).
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....
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.
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 togit clone
two other JS projects of Douglas Crockford, then concatenate (and minimise) some JS files from all three git repositories intoweb_jslint.js
.I did it like this, with the YUI Compressor:
Then open
jslint.html
with your browser.