appfolio / eslint-rails

MIT License
39 stars 22 forks source link

passing options to rake eslint:run #17

Open metapraveen opened 8 years ago

metapraveen commented 8 years ago

Sorry if I have missed any obvious point, how do I pass option to eslint while running rake eslint:run I am adding this gem to my rails project and I want to run eslint on only chnaged or new files, so I need to pass option --cache to eslint

e0da commented 8 years ago

So I think we should just add a variable parameter to the rake task. When we do rake test, we can do

rake test TEST=path/to/my_test.rb TESTOPTS='--name=test_a_feature'

So I'm thinking we could add something so you can do

rake eslint:run ESLINTOPTS='--cached'

The only downside I see is that we probably should not mirror this capability in the web interface because I haven't thought of a good way to do it yet. Also, maybe people don't use the web interface?

DLvalentine commented 6 years ago

I certainly love the web interface when I am manually fixing warnings/errors by hand. It helps a lot, and reduces the strain of having to read terminal output, which isn't always pretty.

I do wish there was an easier way to provide flags, and think it is critical considering eslint can attempt to auto correct issues with the --fix flag. Rubocop has an excellent way of handling flags like that, and I would very much like to see this be a thing with eslint-rails.

DLvalentine commented 6 years ago

I will consider taking a look at this perhaps contributing in order to make this a reality 😎🤔🍻

DLvalentine commented 6 years ago

So I forked this repo and wrote in code to allow for auto-correction, as well as a few more goodies. Seeing as this repo isn't really being actively maintained, I will keep the fork separate unless it is desired that they be merged.

New features include

  1. updated readme
  2. updated eslint
  3. autocorrection feature
  4. different exit statuses based on eslint.json settings. If you have a rule set to error, the build will exit 1. If it is set to warning and no errors exist, it will exit 0
  5. updated the controller to not break if you don't provide force_deafult
  6. updated the web interface to allow you to use autocorrect, or not
  7. updated the rake tasks
  8. updated the before_filter to be before_action, since the former was deprecated

I'll be continuing my own support for this in my free time, and intend to include many more features and improvements :)