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

Parenthesize object expression when it may end up at the start of an expression #3158

Merged
merged 1 commit into from
Dec 13, 2015

Conversation

amasad
Copy link
Member

@amasad amasad commented Dec 12, 2015

T6811

@codecov-io
Copy link

Current coverage is 84.88%

Merging #3158 into master will decrease coverage by -0.13% as of 819bed5

@@            master   #3158   diff @@
======================================
  Files          214     214       
  Stmts        15592   15594     +2
  Branches      3329    3330     +1
  Methods          0       0       
======================================
- Hit          13256   13237    -19
- Partial        688     708    +20
- Missed        1648    1649     +1

Review entire Coverage Diff as of 819bed5

Powered by Codecov. Updated on successful CI builds.

@@ -55,6 +55,13 @@ export function ObjectExpression(node: Object, parent: Object): boolean {
return true;
}

if ((t.isBinaryExpression(parent) || t.isLogicalExpression(parent)) && parent.left === node) {
// We'd need to check that the parent's parent is an ExpressionStatement. But this
Copy link
Contributor

Choose a reason for hiding this comment

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

More than just an ExpressionStatement, it could be an AssignmentExpression as well.

foo = {} === 1;

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it's legal in those cases. The only time that it's illegal is that when it's Binary|LogicalExpression inside an ExpressionStatement:

bad: {} === 1
bad: {} && 1
ok: foo = {} === 1

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh sorry, I see what you're saying

amasad added a commit that referenced this pull request Dec 13, 2015
Parenthesize object expression when it may end up at the start of an expression
@amasad amasad merged commit 4e82edb into master Dec 13, 2015
@amasad amasad deleted the paren-object branch December 13, 2015 04:43
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 8, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 8, 2019
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants