Skip to content

cosm/jshintrb

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jshintrb

Build Status

Ruby wrapper for JSHint. The main difference from jshint it does not depend on Java. Instead it uses ExecJS.

Installation

jshintrb is available as ruby gem.

$ gem install jshintrb

Ensure that your environment has a JavaScript interpreter supported by ExecJS. Usually, installing therubyracer gem is the best alternative.

Usage

require 'jshintrb'

Jshintrb.lint(File.read("source.js"))
# => array of warnings

Jshintrb.report(File.read("source.js"))
# => string

Or you can use it with rake

require "jshintrb/jshinttask"
Jshintrb::JshintTask.new :jshint do |t|
  t.pattern = 'javascript/**/*.js'
  t.options = :defaults
end

When initializing Jshintrb, you can pass options

Jshintrb::Lint.new(:undef => true).lint(source)
# Or
Jshintrb.lint(source, :undef => true)

List of all available options

If you pass :defaults as option, it is the same as if you pass following

{
  :bitwise => true,
  :curly => true,
  :eqeqeq => true,
  :forin => true,
  :immed => true,
  :latedef => true,
  :newcap => true,
  :noarg => true,
  :noempty => true,
  :nonew => true,
  :plusplus => true,
  :regexp => true,
  :undef => true,
  :strict => true,
  :trailing => true,
  :browser => true
}

TODO

  • update to the latest jshint. Need to resolve problems with CommonJS (see):
  • add more tests
  • add color reporter. Maybe colorize
  • add cli. Support same options as jshint/node-jshint

About

Ruby wrapper for JSHint

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 96.2%
  • Ruby 3.8%