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

fix: check parentheses between optional chain and other types #11325

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Mar 24, 2020

Q                       A
Fixed Issues? Seems like they have not been reported.
Patch: Bug Fix? Yes
Tests Added + Pass? Yes
License MIT

Rule of thumb: copy isCallExpression and isMemberExpression references whenever the base itself is not an optional chain.

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: generator labels Mar 24, 2020
@@ -59,8 +59,12 @@ export function UpdateExpression(node: Object, parent: Object): boolean {
return (
// (foo++).test(), (foo++)[0]
t.isMemberExpression(parent, { object: node }) ||
// (foo++)?.test(), (foo++)?.[0]
t.isOptionalMemberExpression(parent, { object: node }) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should be adding an alias for these, so we don't need to duplicate everywhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree.

Copy link
Contributor Author

@JLHwung JLHwung Mar 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really difficult to come up with a proper name other than CallExpression/MemberExpression itself. 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MemberExpressionish 😛

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah, I was thinking isMemberish and isCallish.

@nicolo-ribaudo nicolo-ribaudo merged commit 146ea41 into babel:master Mar 24, 2020
@JLHwung JLHwung deleted the check-parenthesis-between-optional-chain-and-others branch March 24, 2020 17:42
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 24, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: generator PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants