Open esalter opened 7 years ago
@esalter I'm not sure I understand your request, could you clarify?
When you say "lint on autocorrect", do you mean that Rubocop should re-lint after autocorrecting a file?
I mean that the act of saving the file should auto-correct it as well. It does not appear to do that right now.
@esalter You are correct. We could plan this as a feature, but it'd probably be opt-in via a config option of some sort.
That would be fine. I took a stab at it locally and it seems easy (just append the option if configured), but I'd want the undo functionality mentioned in the other issue which I'm not sure how to do. Thanks for taking a look. :)
@esalter Would you be interested in contributing once #48 was resolved? The more the merrier, as they say!
I'd be happy to, just ping me. Thanks!
That would be fine. I took a stab at it locally and it seems easy
@esalter Is there a branch with your changes?
Any updates on this?
autoformat/correct on save would indeed be nice, just like I get with prettier when working with JS.
VS Code has a new setting to Run Code Actions on save. It looks like it should be able to run the rubocopAutocorrect
command, like this:
"editor.codeActionsOnSave": {
"ruby.rubocopAutocorrect": true
},
... but it does nothing when saved. I also tried scoping the language, but same result:
"[ruby]": {
"editor.codeActionsOnSave": {
"ruby.rubocopAutocorrect": true
}
},
Anyone else able to get this to work?
following is working for me:
{
"editor.formatOnSave": true,
"editor.formatOnSaveTimeout": 5000,
"ruby.rubocop.executePath": "path/where/rubocop/is/located",
"ruby.format": "rubocop",
}
following is working for me:
{ "editor.formatOnSave": true, "editor.formatOnSaveTimeout": 5000, "ruby.rubocop.executePath": "path/where/rubocop/is/located", "ruby.format": "rubocop", }
I'm unable to get the autocorrection to work. Tried the settings mentioned above, but vscode throws up an error for editor.formatOnSaveTimeout
saying Unknown configuration setting
. Anyone else facing this issue or am I missing something?
I'm unable to get the autocorrection to work. Tried the settings mentioned above, but vscode throws up an error for
editor.formatOnSaveTimeout
sayingUnknown configuration setting
. Anyone else facing this issue or am I missing something?
To be sure: that piece of config is my in <projectdir>/.vscode/settings.json
- works for me with vscode 1.28.2
I landed here looking for a way to run rubocop on save via Solargraph, and realized the current configuration instructions describe a setup that works correctly. Posting here for others who arrived the same way I did.
Here's what is working for me, VS Code version 1.33.0, ruby-rubocop version 0.7.1.
"editor.formatOnSave": true,
"ruby.format": "rubocop",
"ruby.rubocop.onSave": true,
@rdyson I tried this and ruby.format
is an 'unknown configuration setting'
@DanielTetration Perhaps that setting isn't required — ruby.format
is a setting for the Ruby extension.
Try removing the config settings I mention above (all 3 lines) and make sure you have the latest version of the ruby-rubocop extension, which is 0.8.0. Rubocop is invoked on save successfully with this setup, with no additional settings in VS Code config. I verified this by starting with a blank settings.json.
Hope that helps!
I have used in my settings.json
"[ruby]": {
"editor.formatOnSave": true
},
Works fine, but the auto-correction kicks in very very late. I have to wait a couple of seconds. Any idea why?
If anyone has problems with this, I used bundler and it ran fine. Maybe it's some problem with virtual environments like RVM or Rbenv. Cheers!
"ruby.rubocop.useBundler": true
Same issue, even with useBundler
it takes seconds to save the file 🤔
I solved it by writing as follows.
"[ruby]": {
"editor.defaultFormatter": "misogi.ruby-rubocop"
}
Can confirm, this worked for me:
ruby-rubocop
and ruby
vscode extensions installed.vscode/settings.json
at the root.
{
"editor.formatOnSave": true,
"[ruby]": {
"editor.defaultFormatter": "misogi.ruby-rubocop"
}
}
It seems like this plugin only lints on save, not autocorrect. I'm used to being able to just save a file and have it auto-run formatters to correct mistakes. Can that be added?
This is somewhat related to https://github.com/misogi/vscode-ruby-rubocop/issues/48 since I wouldn't want to lose undo history in this case though.
Thanks!