Making it easy to lint your JavaScript assets in any Rails 3.1+ application.
Add this line to your application's Gemfile:
group :development, :test do
gem 'jshint'
endAnd then execute:
$ bundleRun the generator:
bundle exec rake jshint:install_configTo start using JSHint simply run the Rake task:
bundle exec rake jshintThis 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/javascriptsJSHint 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']
exclude_paths: []
options:
boss: true
browser: true
...
globals:
jQuery: true
$: trueFor more configuration options see the JSHint documentation.
To exclude one of the above folders from being linted, you can define an array of exclude_paths within your configuration file.
files: ['**/*.js']
exclude_paths: ['vendor/assets/javascripts']
...To use jshint in your default Rake config, just add it to the list of default tasks. For example, this configuration will run jshint in development or test environments.
# your-rails-project/Rakefile
if %w(development test).include? Rails.env
task default: :jshint
endifYou can view the changelog here.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request


