-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inlined rubocop:disable comments are formatted to a new line #819
Comments
I tried digging into the code, in places such as this, but to no avail… plugin-ruby/src/ruby/parser.rb Line 2029 in 30b835a
|
There's probably something I'm missing, but changing this line plugin-ruby/test/js/ruby/comments.test.js Line 155 in 30b835a
to:
works… Any help or insight would be greatly appreciated! |
Hi @coisnepe - have you checked out the CONTRIBUTING.md docs? That should help you get an understanding of where to start. You'll need to know which AST nodes I don't have time at the moment to handle this issue but I'll get back around to it eventually. In the meantime please feel free to dig in! |
Hi @kddeisz, thank you so much for taking the time to reply. I'll dig into this doc, which I had overlooked -sorry. Thanks for pointing it out. In the meantime I just want to add the the issue isn't about I'm in the process of migrating all the inlined comments to disable/enable multilines, as I want to get going with the "prettier" migration. Thanks again for your help and time, implementing code formatting in my company's codebase is going to be a huge leap forward! We'll dig into the source code eventually to try and submit a Pull Request, if relevant. |
Using guides here: https://prettier.io/docs/en/install.html and here: https://github.com/prettier/plugin-ruby Decided to opt straight for installing via yarn, as mentions editor integration better: `yarn add --dev --exact prettier` `echo {}> .prettierrc.json` Then built up the `.prettierignore` file from `.gitignore` and added in `.rubocop_todo.yml` as its autogenerated and `.history/*` to handle one of my plugins. Added ``` inherit_from: - node_modules/@prettier/plugin-ruby/rubocop.yml ``` To `rubocop.yml` and ran prettier. Needed to fix duplicate keys in a couple of yaml files. Then ran rubocop, some conflicts, but regenerated my todo and down to 9 all Lint/RedundantCopDisableDirective, these seem to be associated with metrics cops. Given this is a massive commit anyway, decided to inline all the cop todos for these. Actually, may inline *all* metrics cops (bar line length) Done this, had a bit of a battle with rubocop infinite loops, but managed to fix those. Now an eslint battle `yarn add --dev eslint-config-prettier` Then add 'prettier' to the esLintrc files under extends (in last place) Removed some custom formatting configuration Added `config/cucumber.yml` and `config/database.yml` to prettierignore as it seems to be confused by the erb Also, some battle with rubocop metrics cops still. Mostly doesn't like inline disables, issue in to fix this: prettier/plugin-ruby#819 Manually fixed these by switching to the block rathet than inline style
@coisnepe I ran into the same thing trying to move formatting in our project from Rubocop to Prettier. Did you have any luck with fixing or investigating this? Thanks for looking into it! |
Hey @uhoh-itsmaciek, I ended up running a regex against our code base to find the inlined rubocop disables to automatically replace them with the disable/enable pattern. It mostly worked, and in case it didn't I replaced them manually. |
@coisnepe great, thanks for the info. |
I've got a fix coming for this! It will be out in the next release. |
Metadata
2.7.2
@prettier/plugin-ruby
version:1.5.2
Somewhat linked to #706 in that it's inline comments that are taken to a newline, but it's not restricted to specific keywords, i.e.
raise
. Inline rubocop comments are there for a reason (admittedly not always good ones), but I'm dealing with a massive codebase with over 400 inlined rubocop comments so ideally I'd like to find a way to not manually convert the inlined comments todisable\n....\nenable
!Input
Current output
Expected output
The text was updated successfully, but these errors were encountered: