https://github.com/stupidcodefactory/jshint_ruby
API to lint your javascript source code from ruby with jshint
https://github.com/stupidcodefactory/jshint_ruby
Last synced: 6 months ago
JSON representation
API to lint your javascript source code from ruby with jshint
- Host: GitHub
- URL: https://github.com/stupidcodefactory/jshint_ruby
- Owner: StupidCodeFactory
- License: mit
- Created: 2014-01-20T02:26:38.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-20T04:04:35.000Z (over 12 years ago)
- Last Synced: 2024-04-21T02:10:41.171Z (about 2 years ago)
- Language: Ruby
- Homepage:
- Size: 340 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](http://badge.fury.io/rb/jshint_ruby)
[](https://travis-ci.org/StupidCodeFactory/jshint_ruby)
[](https://codeclimate.com/repos/52dc98ba695680512c0037c6/feed)
[](https://gemnasium.com/StupidCodeFactory/jshint_ruby)
[](https://coveralls.io/r/StupidCodeFactory/jshint_ruby)
# JshintRuby
API to lint your javascript source code from ruby.
* It ships with a copy of JSHint
* It uses [ExecJS](https://github.com/sstephenson/execjs) under the hood and is heavily inspired on [execjs](linthttps://github.com/mintdigital/execjslint)
## Installation
Add this line to your application's Gemfile:
gem 'jshint_ruby'
And then execute:
$ bundle
Or install it yourself as:
$ gem install jshint_ruby
## Usage
```ruby
source = File.open('spec/fixtures/source_with_errors.js')
result = JshintRuby.run(source) # => "(error)", "raw"=>"Use '{a}' to compare with '{b}'.", "code"=>"W041", "evidence"=>"if (true == 1)", "line"=>3, "character"=>10, "scope"=>"(main)", "a"=>"===", "b"=>"true", "reason"=>"Use '===' to compare with 'true'."}]>
result.valid? # false
result.errors # [{"id"=>"(error)", "raw"=>"Use '{a}' to compare with '{b}'.", "code"=>"W041", "evidence"=>"if (true == 1)", "line"=>3, "character"=>10, "scope"=>"(main)", "a"=>"===", "b"=>"true", "reason"=>"Use '===' to compare with 'true'."}]
```
## 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