-
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
Add eslint rule for curly brace presence in JSX #62026
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -692 B (-0.04%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
Flaky tests detected in c3922be. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9272561203
|
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.
Thanks for this 🙌
Getting the static analysis check to pass should be pretty straightforward, I've left a few suggestions. I'd prefer getting it fixed here and now, since the errors are actually introduced (or start to be reported) since this PR.
Other than that, good to go, this brings some nice consistency to the codebase 👍
Note: After merging the PR, let's add the merge commit hash to the |
…int/jsx-curly-brace-presence
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.
<Provider value={ { value: '2nd provided' } }> | ||
<Consumer>{ ( context ) => context.value }</Consumer> | ||
</Provider> | ||
{ '|' } | ||
<Consumer>{ ( context ) => context.value }</Consumer> | ||
|<Consumer>{ ( context ) => context.value }</Consumer> |
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.
Should these |
have been on separate lines?
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 was also a bit weirded out by this, and ran a full pass of formatting just in case. Seems to be just a bit of a weird edge case, but it conforms with auto-formatting so 🤷♂️
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.
cc @jsnajdr: Prettier is being unpretty here 😅
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 need some more info about what exactly is the problem. Prettier didn't do the change from { '|' }
to |
, did it? It was done manually to fix (or autofix) the curly brace rule, right?
Is the new syntax incorrect? Does it produce, for example, more or less whitespace that expected in the rendered HTML?
Or is it just unpleasant to look at?
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.
Looks like it was auto-fixed but I'll let @DaniGuardiola confirm.
Looks unpleasant to me, but I'm happy to just not look at it too much. 😅
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.
It's correct, just unpretty :)
The unnecessary curly was eslint autofix, but as I said above I did a full formatting pass afterwards just in case and there were no changes, so this is how prettier likes it.
It looks like base branch was little out of the date and we missed a spot, which currently causing CI check to fail - #62109. |
Followed up to ignore this commit in git blame in: #62144. |
* Add rule. * Run autofixes. * Disable react/no-unescaped-entities * Use useInstanceId * Disable entities rule inline. Co-authored-by: DaniGuardiola <daniguardiola@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
* Add rule. * Run autofixes. * Disable react/no-unescaped-entities * Use useInstanceId * Disable entities rule inline. Co-authored-by: DaniGuardiola <daniguardiola@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Context: #61969 (comment)
Rule docs: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
This rule is autofixable and, with the current configuration, has this effect:
This PR enables the rule (see
.eslintrc
and applies the fix throughout the repo. This is a completely safe fix as the semantics are the same.Note: the lint CI errors showing up in this PR are, to the best of my knowledge, pre-existing. They are probably being triggered simply because the PR is touching these files. They should be safe to ignore for the purposes of this PR, though I think it would be beneficial to take a full pass at the whole repo and squash (or mindfully silence) these errors entirely, in a separate PR.