Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

🐛 12.1.0: Single quote style applied to JSX elements #4469

Closed
1 task done
gkiely opened this issue May 13, 2023 · 8 comments
Closed
1 task done

🐛 12.1.0: Single quote style applied to JSX elements #4469

gkiely opened this issue May 13, 2023 · 8 comments
Labels
S-To triage Status: user report of a possible bug that needs to be triaged

Comments

@gkiely
Copy link

gkiely commented May 13, 2023

Environment information

Error when running rome rage

What happened?

// rome.json

{
  "javascript": {
    "formatter": {
      "quoteStyle": "single"
    }
  }
}
// App.tsx
<div className='myClass'></div>

Expected result

// App.tsx
<div className="myClass"></div>

Code of Conduct

  • I agree to follow Rome's Code of Conduct
@gkiely gkiely added the S-To triage Status: user report of a possible bug that needs to be triaged label May 13, 2023
@nissy-dev
Copy link
Contributor

nissy-dev commented May 14, 2023

This is intentional behavior. Rome doesn't treat JSX attributes specially (it means that JSX attribute values also are formatted based on "quoteStyle" setting).
ref: #4054 and threads based on #2465 (comment)

@gkiely
Copy link
Author

gkiely commented May 14, 2023

@nissy-dev I hope the team reconsiders, it is a popular choice for developers.

@ematipico
Copy link
Contributor

@nissy-dev I hope the team reconsiders, it is a popular choice for developers.

Please refer to the discussion: prettier regrets having some of those options, they create too much bikeshedding and they are difficult to justify.

@ematipico ematipico closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2023
@nstepien
Copy link
Contributor

Is parity with Prettier not a goal anymore?
I'm worried deviating from Prettier would make it harder to adopt Rome's formatting in large codebases.

Maybe a jsxQuoteStyle option may be worth it, doesn't seem like a significant maintenance burden, but I could be wrong.

@ematipico
Copy link
Contributor

ematipico commented May 14, 2023

Is parity with Prettier not a goal anymore? I'm worried deviating from Prettier would make it harder to adopt Rome's formatting in large codebases.

Maybe a jsxQuoteStyle option may be worth it, doesn't seem like a significant maintenance burden, but I could be wrong.

The parity makes sense, but it doesn't make sense to repeat the mistakes that a tool did; it would be a bit unfortunate to carry over those here.

We are always open to suggestions! Does it make sense to treat JSX quotes differently from the rest of other quotes? Why? Would that cause more friction in terms of maintainability, bugs, etc.? Would that create bike-shedding or not? If someone feels strongly, they can always open a discussion! :)

@nstepien
Copy link
Contributor

it doesn't make sense to repeat the mistakes that a tool did

What may have been a mistake in the past has now become standard. 🤷‍♂️
The React docs themselves use double quotes for jsx props, and single quotes otherwise.
I think the idea may have been that HTML is usually formatted with double quotes, so the habit stuck with JSX.
That's my 2 cents.

@ematipico
Copy link
Contributor

Makes sense, we should open an issue

@nstepien
Copy link
Contributor

@ematipico I've opened #4486

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S-To triage Status: user report of a possible bug that needs to be triaged
Projects
None yet
Development

No branches or pull requests

4 participants