A simple web interface to JSHint with pretty output that allows you easily review code. It's also designed to allow you to override certain issues.
JavaScript CSS
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
public/jshintr-assets
views Fix for latest node, express and jade Jul 3, 2012
.gitignore
LICENSE.md
README.md
app.js
config.js
package.json

README.md

jshintr

JSHintr is a web tool that allows you to set your own code standards, easily review a file against these standards, and share the output with other developers. It leverages the power of JSHint:

JSHint is a community-driven tool to detect errors and potential problems in JavaScript code and to enforce your team's coding conventions. It is very flexible so you can easily adjust it to your particular coding guidelines and the environment you expect your code to execute in.

One barrier to people running jshint is that it's a pain to constantly be copy/pasting code to a textbox to run checks, or to be dropping to a command line. This app aims to help lower this wall, see the section title "Apache handler" below.

If you disagree with a certain issue jshint has raised, you can mark it as skipped. Every issue raised is provided with a code sample with context that expands on hover, even marking the specific characters that were problematic.

It's designed to parse files that only exist on the same system as the app itself, for example, a dev server at your workplace. It should never, ever, EVER be accessible from the outside world, since it has access to the filesystem via a URL parameter.

If you change the options in config.js, you will need to restart the node server.

Skipping tests

If you disagree with a test result and want to minimize it, click "skip" to the right of the issue type. Note that the URL will update automatically. If you come back to this URL, and the skipped test is not found, its hash will be removed from the URL for you.

The hashes are based on a sha1 off the trimmed code that caused the error, and the error itself. Therefore, the line number on which the error occurs does not matter, nor does whitespace before/after the offending code. A change in variable names or the like, however, will trigger a new issue that'll need to be skipped again. It's worth noting that identical errors starting at the same character will have each of their occurrences skipped.

You can also hardcode these hashes in your source file, and they will be considered when your code is evaluated. This is done like this:

/*skipped 1add036f,b82945fd,1252ed09 */

Multiple rules in one file

You can split a single source file in to multiple sections to be checked. This is the syntax:

/*jshintr-split*/

Rules/skips etc will not be inherited from any other levels, so you will need to If you specify ignore using the syntax below, the entire section will not be run through JSHint.

/*jshintr-split ignore*/

You cannot split functions, splits can only go between function definitions.

Apache handler

The original idea for this script was to enable developers to change the extension on a .js file to .jshint and have it be run through a code check. My dev server runs Apache, so below is a mod_rewrite rule to proxy *.jshint requests through to jshintr. This requires that you have mod_proxy enabled, and that jshintr is running on port 3000.

Note that the path received by the application will be .jshint, so it does a regex replace of /hint$/ to ''.

RewriteEngine on
# Allow the assets to pass through
RewriteRule /jshintr-assets/(js/application.js|css/style.css)$ http://localhost:3000/$0 [P,L]
# Do the magic
RewriteRule ^(.+?)\.jshint http://localhost:3000/?file=%{REQUEST_FILENAME} [P]

Config

Modes

The modes setting determines what jshintr does when it it passed a file that already has a jshint headers in it. There are subkeys of "options" and "globals" to determine what you're setting the mode for. Possible values are:

  • mergeUnder (default): uses the config.js rules, with ones in the file overriding them.
  • mergeOver: uses the config.js rules, with the file header "filling in the gaps"
  • leave: ignores all settings in config.js and just uses the file rules
  • clobber: strips out the file's header, and uses the rules defined in config.js.

Requirements

Browser requirements

Anything modern will do, uses css3 animations and html5 history management, so no IE allowed.

Server requirements

  • node.js
  • express
  • jade

Acknowledgments

  • CSS based Connect middleware exception pages
  • JS magic by JSHint