Repository navigation
fix: keep parens around jsx that starts a member, call or new expression - #889
Merged
Merged
Conversation
…-member # Conflicts: # src/generation/generate.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Single-line JSX lost the parens it needs when it starts a call,
new, tagged template, non-null or instantiation expression, which produced code that doesn't parse. With the defaultjsx.multiLineParens: prefer:With
always, member access lost its parens as well ((<div />).propsbecame<div />.props), and((<div />))()was unstable with both. The paren expression is skipped in these positions, and the parens were only added back when the JSX was multi-line.Single-line JSX now keeps its parens when it's the object of a member expression, the callee of a call, optional call or
new, the tag of a tagged template, or the expression of a non-null or instantiation expression. Output only changes for this broken code. In the regression corpus I use, nothing changed.neveralready kept these parens. Its check from #888 now uses the same helper, so the positions where parens are needed are listed in one place.Tests
JsxElement_ParensNeeded_Prefer.txt,JsxElement_ParensNeeded_Always.txtandJsxElement_ParensNeeded_Never.txtcover JSX that's called, constructed, a tag, non-null, instantiated, the object of a member expression, multi-line JSX in those positions, and nested parens.