Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add an option to print single quotes in JSX #4798
I really don't think we should add this option... arrow parens I was sympathetic to because it's annoying to eg. convert an identifier to destructuring syntax, and I'm open to space between function name and params list because it makes the code easier to grep. But single/double quotes is just nitpicking, and I don't want the teams that use prettier to have to have a conversation about this.
I know this is unintuitive, since prettier is a code formatter, but in my opinion, the major value of prettier is that it makes you stop caring about syntax. It is not what people expect at first but once you let go it is very freeing to "let the formatting be what it will" and focus on the problems the code is solving instead of the aesthetic of the code.
@suchipi thoughts on putting this to a private vote amongst the maintainers or something? Perhaps over email?
We're all in agreement that we hate bikeshedding discussions, but it's not clear that there's overwhelming evidence one way or another on this one (eg; community demand seems strong, including from some luminaries). Eg; prettier's existence/stance doesn't seem to prevent teams from having conversations about this, it's just "do we use prettier when it lacks this feature".
I can say that I haven't yet adopted prettier specifically because of its lack of support for single quote JSX attributes. We don't write conversational english in our raw attributes, there is no need to care about the need to handle a potential apostrophe in your text, and forcing the attributes to be double quotes when all your other strings are single quotes is disorienting.
But I'm not an influencer I guess.
All this discussion was already had in the long issue thread that OP mentioned.
It's a clear tradeoff between "give the people what they want" and "never add options", which is just up to the maintainers.
In any case @smirea thanks for the work on this PR – the better it looks, the more likely it'll be accepted, I hope
this feature is backwards compatible with the old signature via the config.
We could support all 5 options (true/js false/none all) without a deprecation to not have it be slightly awkward for non-js projects, my 2 cents is that it's better to bite the bullet sooner rather than later
Example of the current behavior:
Any prettier plugin could be relying on that option being a boolean.
changed the title from
Feat option single quote jsx, fixes #1080
Add an option to print single quotes in JSX
Aug 18, 2018
referenced this pull request
Aug 28, 2018
added a commit
this pull request
Aug 31, 2018
reviving this with updates, added
Can I get some final feedback on this and what would be the ideal format before I finalize tests and update snapshots?
Personally personally, I would've not even added an extra option and have jsx follow js quotes and not have the notion of "we use a type of quote everywhere in js, except for this place" ... but I get how that is not possible now
In lieu of that, I think the
I'll give it a day and if there aren't any other suggestions i'll go ahead and add
An idea I had recently: (this may be completely crazy)
This preserves backward compatibility since
Is this excessively complex?