JSHint

travis-ci Code Climate Coverage Status

Making it easy to lint your JavaScript assets in any Rails 3.1+ application.

Installation

Add this line to your application's Gemfile:

group :development, :test do
  gem 'jshint'
end

And then execute:

$ bundle

Run the generator:

bundle exec rake jshint:install_config

Usage

To start using JSHint simply run the Rake task:

bundle exec rake jshint

This Rake task runs JSHint across all the JavaScript assets within the following three folders to ensure that they're lint free. Using that data it builds a report which is shown in STDOUT.

your-rails-project/app/assets/javascripts
your-rails-project/vendor/assets/javascripts
your-rails-project/lib/assets/javascripts

Configuration

JSHint has some configuration options. You can read the default configuration created by JSHint in your applications config folder.

# your-rails-project/config/jshint.yml
files: ['**/*.js']
options:
  boss: true
  browser: true
  ...
  globals:
    jQuery: true
    $: true

For more configuration options see the JSHint documentation.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request