Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 97420

vscode( vscode-ruby + rubocop ) how to auto correct on save?

$
0
0

Environments

  • vscode Version 1.19.1 (1.19.1)
  • rubocop (0.52.1)
  • Darwin mbp 16.7.0 Darwin Kernel Version 16.7.0: Wed Oct 4 00:17:00 PDT 2017; root:xnu-3789.71.6~1/RELEASE_X86_64 x86_64
  • ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-darwin16]

followed https://github.com/rubyide/vscode-ruby#linters and installed all gems and edited the settings.json like this.

{

  "ruby.rubocop.executePath": "/Users/ac/.rbenv/shims/",
  "ruby.rubocop.onSave": true,
  "ruby.lint": {
    "ruby": {
      "unicode": true //Runs ruby -wc -Ku
    },
    "reek": true,
    "rubocop": {
      "lint": true,
      "rails": true
    },
    "fasterer": true,
    "debride": {
      "rails": true //Add some rails call conversions.
    },
    "ruby-lint": true
  },
  "ruby.locate": {
    "include": "**/*.rb",
    "exclude": "{**/@(test|spec|tmp|.*),**/@(test|spec|tmp|.*)/**,**/*_spec.rb}"
  }

}

On vscode, code highlighting is working fine.
*just to note, you see the extensions installed, and warnings in the problem tab.

rubocop is working ok

Question

I was under the inpression that vscode-ruby and rubocop would auto-correct indentations and cop rules on file save, but apparently it doesn't.
If I want it to format my code like prettier, how should I set this up?


Viewing all articles
Browse latest Browse all 97420

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>