Is JSLint available for offline use?

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 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.

JSLint can be run offline with either WSH or Rhino:

Edit: In the two years since this question was asked, JSLint has dropped support for Rhino and WSH. I encourage anyone interested in linting their code to also check out JSHint. It’s a fork of JSLint which aims to be more flexible than the original, but also happens to support Node, Rhino, and WSH (in addition to browsers, of course).

Read More:   Re-enabling window.alert in Chrome


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

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.

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. 🙂

YSlow for Firebug has this feature built in

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 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:

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….

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.

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’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).

JSLintMate screenshots

If you already use ruby gems then you may install jslint gem in one command :

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

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.

Read More:   Does the electron framework allow multi-threading through web workers?

It’s pretty easy to recreate what Crockford has on’s online version of the .js is a minified conglomeration of a few files that includes some overhead I don’t quite understand, like that ADSAFE stuff. Let’s strip it down to a simplest case wrapper instead.

Building your own HTML wrapper for JSLint:

Here’s the code to a web page that’ll look for jslint.js (the latest version of JSLint can currently be found in github here as raw text) in the same directory and fire away in a similar fashion as does now.

        <script src="jslint.js"></script>

            function jslintalizeMe()
                var i, divOut, errs, errsMsg = "";

                divOut = document.getElementById("errors");
                divOut.innerHTML = "";

                if (!JSLINT(document.forms[0].elements[0].value))
                    errs = JSLINT.errors;
                    for (i=0; i < errs.length; i++)
                        err = errs[i];
                        if (null !== err)
                            if (undefined !==
                                errsMsg += "Error: " 
                                + err.code 
                                + " -- line " 
                                + err.line 
                                + " char " 
                                + err.character + "<br />"
                                + "    " 
                                + err.evidence + "<br />"
                                + "    " +
                                 err.reason + "<br /><br />\n";
                                errsMsg += err.reason;
                    divOut.innerHTML = errsMsg;



            <textarea rows="24" cols="80"
                placeholder="// Paste quality code here"></textarea>
            <br />
            <button onclick="jslintalizeMe();return false;">JSLint</button>

        <div id="errors"></div>

^ From an old blog post of mine.

It’s up to the proverbial reader to make the GUI more gooey, but this reports as well as the JSLint site does now.

sample JSLint output from wrapper code

There is a great Yahoo Widget:

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

alt text

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Similar Posts