tools
tools copied to clipboard
📎 Implement option `preserve_quotes`
Description
See discussion for context: https://github.com/rome/tools/discussions/2465#discussioncomment-2592318
The team agrees that we would give the possibility to preserve the quotes inside the properties an object, if requested.
Given the following input:
const a = { "a": 2 }
The default behaviour will format the snippet like this:
const a = { a: 2 }
While using the option --preserve-quotes will format the snippet like this:
const a = { "a": 2 }
Please refer to Prettier's documentation about the option: https://prettier.io/docs/en/options.html#quote-props
This is where we should start having a look: https://github.com/rome/tools/blob/main/crates/rome_js_formatter/src/js/objects/property_object_member.rs
Then, the actual literal is here: https://github.com/rome/tools/blob/main/crates/rome_js_formatter/src/js/objects/literal_member_name.rs
We should mind the fact taht JsLiteralMemberName is also used inside TypeScript, which means that we have read what Prettier does in case of TypeScript (it says that we should not change things because "a" and a have two different meanings) and then apply the option accordingly.
This work depends on #2405
I would like to work on this!
I would like to work on this!
Awesome. I assigned you the issue. Let me know if you need any help.