-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Allow double quotes and template string sometimes #7555
Allow double quotes and template string sometimes #7555
Conversation
I may be in the minority, but my preference is toward the strict consistency. There's also another point of: When we're using the single quote in strings, particularly localized strings, we're misusing it as an apostrophe, which has its own character |
Thank you! Yeah, the usage of single-quotes for apostrophe is another thing I'd happily go through and correct. That's an interesting idea; re: annoyance of needing to escape it minimising the problem. 😄 |
To be my own self-critic, I've found myself in a fascinating rabbit hole of a topic surrounding apostrophes vs. single quotes. The Wikipedia article claims:
https://en.wikipedia.org/wiki/Apostrophe Yet, as best I can tell, the Unicode specification itself says U+2019 (
https://www.unicode.org/charts/PDF/U2000.pdf Anyways, I did not mean to make this a big point, but I felt compelled to share that the issue is more complicated than I might have implied it was 😄 |
Still on my tangent: In the same way we have a rule preventing three dots in favor of the ellipsis proper, we could introduce something similar for apostrophe, though it may be hard to tell where (if any) is valid use for the single quotation. Then again, in its rare usage, an inline Lines 117 to 120 in d316177
|
I am so into this tangent, fixing those kind of nitpicks gives me much happiness. 😄 |
If considered for adoption, this will need to include relevant guideline documentation in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's document this in coding guidelines, including mention of appropriate use of apostrophe.
I think we can probably also adopt this for core coding standards Once this is in here I'll look at proposing that for core and updating |
87b1672
to
2d10143
Compare
Sorry I neglected this; updated the coding standards and tried to go through as much of the code as possible and replace single-quotes that should have been apostrophes with the correct character. Should be set for another review, then we can look at changing the core standards as well... though we should probably chat about whether Gutenberg is the canonical source for core JS standards anyhow, as it's the biggest piece of JS in WordPress 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the fact we don't need to escape those strings anymore, it also makes a lot of sense to use ’
for translations 👍
For tests we probably should pick one approach and be consistent, at the moment it's all random :)
@@ -137,7 +137,7 @@ describe( 'block parser', () => { | |||
} ); | |||
|
|||
describe( 'parseWithAttributeSchema', () => { | |||
it( 'should return the matcher\'s attribute value', () => { | |||
it( "should return the matcher's attribute value", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put ’
here, too. To match with other test names :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I didn't want to go too wild with tests but I suppose just being consistent everywhere is cool. Will do!
@@ -571,7 +571,7 @@ describe( 'block parser', () => { | |||
} ); | |||
|
|||
const parsed = parse( | |||
'<!-- wp:core/test-block {"smoked":"yes","url":"http://google.com","chicken":"ribs & \'wings\'"} -->' + | |||
`<!-- wp:core/test-block {"smoked":"yes","url":"http://google.com","chicken":"ribs & 'wings'"} -->` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an epic string which tricks all standards
068fce3 - like it 👍 |
Mentioned in the coding guidelines, so I think we're good 🙂
Counter-point in the wild: In copying and modifying existing code which is allowed to be exempted, it's not clear to a developer that they'd need to change between single and double quotes: 27b4423 #5476 (comment) (assumed to be copied by recommendation in #5476 (comment) ) |
Description
Fixes #7366.
This PR is two commits:
\
😉How has this been tested?
Everything still works; eslint doesn't yell at you.
Types of changes
Code quality.
Checklist:
Obviously this violates https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/#strings, so I guess we should have a chat about this in
#core-js
or something first. 🤷♂️