Giter VIP home page Giter VIP logo

jshint's Introduction

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']
exclude_paths: []
options:
  boss: true
  browser: true
  ...
  globals:
    jQuery: true
    $: true

For more configuration options see the JSHint documentation.

Excluding folders from being Linted

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']
...

Rake integration

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
endif

Changelog

You can view the changelog here.

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.