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

📎 Support prettier-style jsx quotes #4486

Closed
nstepien opened this issue May 16, 2023 · 6 comments · Fixed by #4555
Closed

📎 Support prettier-style jsx quotes #4486

nstepien opened this issue May 16, 2023 · 6 comments · Fixed by #4555
Assignees
Labels
A-Formatter Area: formatter Help wanted Help would be really appreciated I-Normal Implementation: normal understanding of the tool and awareness task A task, an action that needs to be performed
Milestone

Comments

@nstepien
Copy link
Contributor

Description

Since Rome 12.1.0, Rome started enforcing the same quote style on JSX prop strings.
This breaks parity with prettier: with "singleQuote": true prettier would still format JSX strings with double-quotes.

Playground example

Straying away from prettier as the "standard" makes it a hard pill to swallow as projects would have to reformat the majority of their files.

Possible approaches:

  • revert back to always formatting JSX strings with double quotes
  • add a new option, something like "jsxQuoteStyle": "double" / "single", "double" by default.
    I think it's a fairly safe option to add as it wouldn't affect the formatting of other parts of the code, it'd only change the quote characters and quote escaping in the strings.

Previous discussion: #4469

@nstepien nstepien added the task A task, an action that needs to be performed label May 16, 2023
@ematipico ematipico added Help wanted Help would be really appreciated A-Formatter Area: formatter I-Normal Implementation: normal understanding of the tool and awareness labels May 16, 2023
@ematipico ematipico added this to the v12.2.0 milestone May 16, 2023
@johnschult
Copy link

johnschult commented May 16, 2023

I agree, this started reformatting all our JSX, which was not optimal.

@Vivalldi
Copy link
Contributor

Vivalldi commented May 17, 2023

As an alternative name: markupQuoteStyle. Which pairs well with XML (JSX is JavaScript XML), HTML & YAML

@vascomontyero
Copy link

what is the status of this? wanted to update to version 12, but this is blocking us

@denbezrukov
Copy link
Contributor

I could take it to implement🤗

@afc163
Copy link

afc163 commented Jul 11, 2023

  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "jsxQuoteStyle": "double"
    }
  }

This don't work as expected.

  • Expected behavior:
const App = () => {
  const stringVar = '123'; // quoteStyle single
  return <div id="xxx" />; // jsxQuoteStyle double
}
  • Current behavior:
const App = () => {
  const stringVar = "123"; // jsxQuoteStyle double, quoteStyle single would be useless here
  return <div id="xxx" />; // jsxQuoteStyle double
}

@ematipico
Copy link
Contributor

ematipico commented Jul 11, 2023

This feature hasn't been released yet, but it works as expected: https://docs.rome.tools/playground/?quoteStyle=single&code=YwBvAG4AcwB0ACAAQQBwAHAAIAA9ACAAKAApACAAPQA%2BACAAewAKACAAIABjAG8AbgBzAHQAIABzAHQAcgBpAG4AZwBWAGEAcgAgAD0AIAAnADEAMgAzACcAOwAgAC8ALwAgAHEAdQBvAHQAZQBTAHQAeQBsAGUAIABzAGkAbgBnAGwAZQAKACAAIAByAGUAdAB1AHIAbgAgADwAZABpAHYAIABpAGQAPQAiAHgAeAB4ACIAIAAvAD4AOwAgAC8ALwAgAGoAcwB4AFEAdQBvAHQAZQBTAHQAeQBsAGUAIABkAG8AdQBiAGwAZQAKAH0A

You would need to use a nightly release to avail of the feature.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Formatter Area: formatter Help wanted Help would be really appreciated I-Normal Implementation: normal understanding of the tool and awareness task A task, an action that needs to be performed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants