Skip to content

Comments

Prevent breaking MemberExpression inside NewExpression#3075

Merged
azz merged 2 commits intoprettier:masterfrom
duailibe:fix-3061
Oct 21, 2017
Merged

Prevent breaking MemberExpression inside NewExpression#3075
azz merged 2 commits intoprettier:masterfrom
duailibe:fix-3061

Conversation

@duailibe
Copy link
Collaborator

Fix #3061

(firstNonMemberParent &&
((firstNonMemberParent.type === "VariableDeclarator" &&
firstNonMemberParent.id.type !== "Identifier") ||
(firstNonMemberParent.type === "NewExpression" ||
Copy link
Member

Choose a reason for hiding this comment

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

What about CallExpression?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@azz I'm not sure what you meant.. what about CallExpression?

Copy link
Member

Choose a reason for hiding this comment

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

As in the same without new. It actually already behaves as expected, but I'm not sure why.

function functionName() {
  // indent to make the line break
  if (true) {
    this._aVeryLongVariableNameToForrrrrrrBreak = this.Promise(
      (resolve, reject) => {
        // do something
      }
    );
  }
}

Copy link
Collaborator Author

@duailibe duailibe Oct 21, 2017

Choose a reason for hiding this comment

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

Ah, understood now! That's because that case doesn't get here, actually. That's printed by printMemberChain, as you can see here:

prettier/src/printer.js

Lines 889 to 893 in 54bdd30

// We detect calls on member lookups and possibly print them in a
// special chain format. See `printMemberChain` for more info.
if (!isNew && isMemberish(n.callee)) {
return printMemberChain(path, options, print);
}

Copy link
Member

Choose a reason for hiding this comment

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

Ah, of course!

@azz azz merged commit b53a426 into prettier:master Oct 21, 2017
@duailibe duailibe deleted the fix-3061 branch October 21, 2017 23:30
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants