Jump to >

JSHint

JSHint is a tool which checks JavaScript code for common errors, including style consistency errors.

Supported File Types

The following are supported by this tool:

  • JavaScript: *.js

Additional file extensions can be specified by configuring the Extra file extensions option.

Installation

This tool requires a Node.js install.

Once installed, you can install JSHint by running:

$ sudo npm install -g jshint

It may also be available in your system’s package manager.

Configuration

JSHint Location

If the jshint command is in a non-standard location, and can’t be found in Review Bot’s PATH environment variable, then you’ll need to specify the path in the Review Bot worker config file:

exe_paths = {
    'jshint': '/path/to/jshint',
}

You will need to restart the Review Bot worker after making this change.

Enabling JSHint in Review Board

First, you’ll need to add a Review Bot configuration in Review Board (see Tool Configurations).

The following configuration options are available:

Extra file extensions (optional):

A comma-separated list of additional file extensions to run JSHint on.

This should look like: .ext1, .ext2, .ext3

Extract JavaScript from HTML (optional):

Whether JavaScript content in HTML files should be extracted and checked. The following choices are available:

  • Auto - Extracts only if it thinks the file is an HTML file

  • Always - Always treats a file as possible HTML

  • Never - Never extracts JavaScript from a non-JavaScript file

If specifying this, you will want to add .html or suitable template extensions in Extra file extensions.

This is equivalent to jshint --extract=....

Configuration (optional):

A custom JSON configuration for JSHint.

Callers should be sure to validate this configuration before setting it.

This is equivalent to jshint --config=... with a path to a file containing the provided configuration.