Back
Question
Asked

Is there a Prettier for Ruby/Rails?



Something like rubocop perhaps?

That's what I use since a half a year or so. Takes some getting used to, but has helped me clean up my code a lot.

Make sure to follow the installation instructions as it has some handy info on creating a "todo/ignore" file for existing style violations. That way it initially ignores those and you don't get bombarded with tons of warnings right out the gate. You can go through that todo file step by step and slowly remove stuff so it starts warning about those style violations which you can then fix one at a time.

It's only for Ruby code. Not for Javascript, HTML, CSS, HAML, etc. I haven't researched those options yet (I know there are a bunch), but I will at some point.

Does it do autoformatting and fixing errors or is it just a linter that shows what's wrong with your code?

If you run it with rubocop -a (or equivalent shortcut in your editor) it will fix what it can.

Just replying to this with news that there actually is one now: github.com/prettier/plugin-ru…