-
Notifications
You must be signed in to change notification settings - Fork 660
feat(rome_js_formatter, rome_cli): add arrowParentheses
option
#4667
Conversation
✅ Deploy Preview for docs-rometools ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
For testing, here's a start. We have our arrow function testing suite. What you need to is to create an Then you'd have to update the testing suite, so it can read the new option. Here is where you can do that. Once you've done it, run the command The test suite will update ALL the snapshot tests with a new test case with the new options. There, you can check if the formatting is what you expect to be. |
just updated them, but i'm not sure if i did it correctly, the new tests (or rather outputs) this added look completely the same as the other ones |
I'm not really sure tbh, the code looks good. I would need to debug it. It seems that the option is still not passed/overridden. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a fantastic addition! Thank you for implementing it!
Two things before merging the PR:
- if you can revert changes that belong to the website (only the documentation, the playground is fine). We usually update the docs just before doing the release;
- if possible, add a new test case in the CLI, where we test that passing the new option yields the expected output. You can use this test as example
crates/rome_js_formatter/src/js/expressions/arrow_function_expression.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_formatter/src/js/expressions/arrow_function_expression.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of users will be happy with this new feature! 🙌
Summary
Closes #4666
Personally, the only thing that's keeping me for migrating to Rome formatter-wise is the lack of an
arrowParens
formatter option. Most developers don't really want to change their code style just to migrate to a new tool, especially when this change affects code readability.This pull requests adds an
--arrow-parentheses
option (similar to prettier'sarrowParens
) that can be set to:always
for always adding parentheses to arrow functionsas-needed
for only adding parentheses where it's necessaryTest Plan
Made all arrow function tests also run on
"arrow_parentheses": "AsNeeded"