Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce single-quotes for JSX #78

Merged
merged 2 commits into from Mar 20, 2022
Merged

Enforce single-quotes for JSX #78

merged 2 commits into from Mar 20, 2022

Conversation

Richienb
Copy link
Contributor

The quotes for strings and string values of JSX attributes should both be single:

const foo = 'bar';

<a href='https://example.com'>foo</a>

vs the current configuration which enforces different styles in the same file:

const foo = 'bar';

<a href="https://example.com">foo</a>

What do you think?

@sindresorhus
Copy link
Member

I agree. I initially made it double-quotes as the React docs used it, but I have come to prefer single-quotes for JSX.

Some good arguments in: airbnb/javascript#269 (comment)

@sindresorhus sindresorhus changed the title Enforce single quotes for JSX Enforce single-quotes for JSX Mar 20, 2022
@sindresorhus sindresorhus merged commit 93194d2 into xojs:main Mar 20, 2022
sindresorhus added a commit that referenced this pull request Mar 20, 2022
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
@fregante
Copy link
Member

It's kinda funny that I keep reading "HTML uses double quotes" while it's as true as "JavaScript uses single quotes." Both are supported and are a stylistic preference.

I'm ok with this change, even it will cause some churn

@Primajin
Copy link

Sorry to be that guy again but do we really want to prefer Javascript style over HTML style for JSX? Isn't the whole idea of JSX to use HTML-like code?

@fregante
Copy link
Member

Read my last comment. There's no such thing as "HTML style". I write my HTML as: <div id='👋'>

@Primajin
Copy link

Primajin commented May 17, 2022

Ahh thanks, learned something new today: I am writing HTML since the nineties and I never questioned it that it was double quotes - I just thought it's a given.

Sorry I had interpreted your comment differently but now I understand it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants