mackuba / jslint_on_rails Goto Github PK
View Code? Open in Web Editor NEWJSLint JavaScript checker wrapped in a Ruby gem (unmaintained)
Home Page: http://psionides.eu
License: MIT License
JSLint JavaScript checker wrapped in a Ruby gem (unmaintained)
Home Page: http://psionides.eu
License: MIT License
The JSLint included is from 2010-12-21 and there appear to be numerous fixes from here: https://github.com/douglascrockford/JSLint/commits/master/jslint.js
Sadly, just dropping in a new JSLint file doesn't magically work.
Hi,
I'm using Rails 3.2.3 and jslint_on_rails 1.1 under Windows 7 x64 and this is the error that I get:
$ bundle
Fetching gem metadata from https://rubygems.org/.......
[...]
Installing jslint_on_rails (1.1)
[...]
Using rails (3.2.3)
[...]
Your bundle is complete!
$ rake jslint:copy_config
rake aborted!
can't convert nil into String
$ rake jslint --trace
rake aborted!
can't convert nil into String
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jslint_on_rails-1.1/lib/jslint/utils.rb:14:in `join'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jslint_on_rails-1.1/lib/jslint/utils.rb:14:in `<module:JSLint>'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jslint_on_rails-1.1/lib/jslint/utils.rb:4:in `<top (required)>'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jslint_on_rails-1.1/lib/jslint.rb:2:in `require'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jslint_on_rails-1.1/lib/jslint.rb:2:in `<top (required)>'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jslint_on_rails-1.1/lib/jslint_on_rails.rb:1:in `require'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/jslint_on_rails-1.1/lib/jslint_on_rails.rb:1:in `<top (required)>'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/runtime.rb:68:in `require'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/runtime.rb:66:in `each'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/runtime.rb:66:in `block in require'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/runtime.rb:55:in `each'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/runtime.rb:55:in `require'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.rc.7/lib/bundler.rb:118:in `require'
c:/Users/Tanguy/MyApp/config/application.rb:7:in `<top (required)>'
c:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
c:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
c:/Users/Tanguy/MyApp/Rakefile:5:in `<top (required)>'
c:/Ruby193/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load'
c:/Ruby193/lib/ruby/1.9.1/rake/rake_module.rb:25:in `load_rakefile'
c:/Ruby193/lib/ruby/1.9.1/rake/application.rb:501:in `raw_load_rakefile'
c:/Ruby193/lib/ruby/1.9.1/rake/application.rb:82:in `block in load_rakefile'
c:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
c:/Ruby193/lib/ruby/1.9.1/rake/application.rb:81:in `load_rakefile'
c:/Ruby193/lib/ruby/1.9.1/rake/application.rb:65:in `block in run'
c:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handling'
c:/Ruby193/lib/ruby/1.9.1/rake/application.rb:63:in `run'
c:/Ruby193/bin/rake:32:in `<main>'
Regards,
The library does not work with ruby 1.9 because of dependency of ftools.
Any ideas how we can workaround this problem?
I tried installing this via gem deployed with apt on Ubuntu. I installed via your instructions:
gem install jslint_on_rails
It fails with:
no such file to load -- jslint/tasks
I have a few js files with local jslint options set using /*jslint eqeqeq:true */ for example. I expect these options to apply to that one source js file and no others. But it seems that jslint_on_rails applies this option to that file and all subsequent files that it checks. I expected it to reset the options to those specified in the jslint.yml file for each new source file that it checks.
As Apple announced in the fall, Java is not going to be preinstalled on Macs starting with Lion.
jslint_on_rails should detect if jsc or Rhino is appropriote and choose the correct interperter for JSLint to keep people from having to install Java.
Last year I decided to leave the webdev world and concentrate only on Cocoa development. I still love Ruby as a language (especially as compared to ObjC - Swift is much better though), but it was just too much effort to try to keep up with Ruby, JS and Cocoa all the time, and I had to choose something.
I haven't been up to date with all the latest developments in the Ruby world since then, I'm not even sure which version of Ruby is the latest stable one now (2.1 I think?). And obviously I had no use for a Rails JSLint plugin for some time now. I'm not willing to put any more effort into this gem, since I have other projects to maintain too, but if someone is interested in taking it over and maintaining it, I can transfer the ownership of the repo and the RubyGems entry.
Current project status:
It hasn't been updated in a loooong time. The bundled JSLint version hasn't been updated for even longer, ever since Crockford made some major changes there and added some annoying checks which couldn't be disabled (I think he might have changed that back later). If you want to update it, you'd need to either copy my hacks (those 3 extra options) over to the newest JSLint, or just drop these options (I don't really care).
There's some code on master
which hasn't been released that gets rid of Rhino and lets you use any execjs-compatible JS runtime. It should work, or at least it did, though you'd have to test it (is execjs still a thing?). There's also some refactoring done on the hackkrk
branch and unmerged, and some experiments with output coloring in the last commits on master
. You can use those if you want.
Regarding JSHint:
I don't think it makes sense to drop JSLint and switch to JSHint, there are already a few forks that have done just that and re-released the gem as jshint_on_rails
. And I don't think it makes sense to try to support both in one gem, as they have significantly diverged in the last few years and the options lists would have to be completely different - but you could try to do that if you want (there are some old commits made in that direction on the jshint
branch).
In jslint.yml, I have this:
predef: 'window,$,jQuery' # Names of predefined global variables - comma-separated string
This passes the string on the command like, like so:
java -cp /full/path/to/rhino.jar org.mozilla.javascript.tools.shell.Main /full/path/to/jslint.js [other options],predef="window,$,jQuery",[more other options]
However, the rhino function at the end of lint.js splits on commas to separate options, which means this isn't parsed correctly. The only way I've found to make it work is to put the following (slightly ridiculous) string in jslint.yml:
predef: 'new Array("window").concat(["$"]).concat(["jQuery"])'
Hi,
Is there any chance of adding colors in output?
Red for the Lint warnings. Normal color for the code snippet.
Summary may also be in red if the test fails, green otherwise.
I hope you will consider these recommendations.
Cheers
This will make it show up on rubygems.org. I'm doing due diligence on our gems and need to find out the licenses for all the gems. Having it show up on rubygems.org cuts out the step of having to go to the github repo.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.