tools icon indicating copy to clipboard operation
tools copied to clipboard

📎 Implement option `preserve_quotes`

Open ematipico opened this issue 3 years ago • 4 comments

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

ematipico avatar Apr 22 '22 08:04 ematipico

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.

ematipico avatar Apr 22 '22 08:04 ematipico

This work depends on #2405

MichaReiser avatar Apr 22 '22 09:04 MichaReiser

I would like to work on this!

bhbs avatar Aug 15 '22 08:08 bhbs

I would like to work on this!

Awesome. I assigned you the issue. Let me know if you need any help.

MichaReiser avatar Aug 15 '22 09:08 MichaReiser