JSHint on Rails - Forked from psionides/jslint_on_rails to work with JSHint - the check tool that does not tyrannize your code, by jshint community
Pull request Compare This branch is 29 commits ahead, 27 commits behind mackuba:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
tasks renaming file Apr 4, 2011
.gitignore debugging Apr 28, 2011
Gemfile.lock added Gemfile.lock Dec 5, 2010
Rakefile fixed Rakefile for new RSpec Dec 5, 2010
install.rb renaming stuff Mar 30, 2011
uninstall.rb renaming stuff Mar 30, 2011


##JSHint On Rails JSHint on rails is a fork project from JSLint_on_rails, adapted to work with jshint.

Installation Dependencies

  • Java 5 >
  • Ruby 1.8 >
  • Rails 2 >


Rails 3

  • add gem 'jshint_on_rails' to you're projects Gemfile

The first time you run it, a file in config/jshint.yml will be created. It can be customized to fit your needs (well explained below).

As this project is a fork of psionides jslint_on_rails, the instructions are the same. Click here to follow his instructions.


After the installation, observe that you'll probably will need to customize some settings, for example, the files you want to test and the ones you want to ignore (ex.: libraries such as jquery, mootools, underscore, etc).

The default config allows you to:

  • write single line conditional statements
  • ignore whitespaces (to support the option above and still being indented)


To start checking your stuff run the following:

[bundle exec] rake jshint

Then you should see:

Running JSHint:

checking public/javascripts/scripts.js... OK
checking public/javascripts/models.js... OK
checking public/javascripts/presenters.js... OK

No JS errors found  =)

If anything is wrong, you will get something like this instead:

Running JSHint:

checking public/javascripts/scripts.js... 2 errors:

Lint at line 24 character 15: Use '===' to compare with 'null'.
if (a == null && b == null) {

Lint at line 72 character 6: Extra comma.

Found 2 errors =(
rake aborted!
JSHint test failed.

If you want to test specific file or files (just once, without modifying the config), you can pass paths to include and/or paths to exclude to the rake task:

rake jshint paths=public/javascripts/models/*.js,public/javascripts/lib/*.js exclude_paths=public/javascripts/lib/jquery.js