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(multiparser): no additional trailing newline for graphql in js #4616

Merged
merged 2 commits into from
May 31, 2018

Conversation

ikatyang
Copy link
Member

@ikatyang ikatyang commented May 31, 2018

Fixes #4615

The root cause is the output doc from graphql printer does not match the desired input from stripTrailingHardline.

function stripTrailingHardline(doc) {
// HACK remove ending hardline, original PR: #1984
if (
doc.type === "concat" &&
doc.parts.length === 2 &&
doc.parts[1].type === "concat" &&
doc.parts[1].parts.length === 2 &&
doc.parts[1].parts[0].hard &&
doc.parts[1].parts[1].type === "break-parent"
) {
return doc.parts[0];
}
return doc;
}


Prettier pr-4616
Playground link

--parser babylon

Input:

graphql`
  fragment x on y {
    z
  }

  fragment a on b {
    c
  }
`;

Output:

graphql`
  fragment x on y {
    z
  }

  fragment a on b {
    c
  }
`;

@ikatyang ikatyang requested a review from vjeux May 31, 2018 16:28
Copy link
Contributor

@vjeux vjeux left a comment

Choose a reason for hiding this comment

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

Thanks! Fortunately the workaround for this hack isn't too bad.

@ikatyang ikatyang merged commit b55997e into prettier:master May 31, 2018
@ikatyang ikatyang deleted the fix/graphql-trailing-newline branch May 31, 2018 16:38
bors bot referenced this pull request in mozilla/delivery-console Jun 1, 2018
175: Update dependency prettier to v1.13.4 r=rehandalal a=renovate[bot]

This Pull Request updates dependency [prettier](https://github.com/prettier/prettier) from `v1.13.3` to `v1.13.4`



<details>
<summary>Release Notes</summary>

### [`v1.13.4`](https://github.com/prettier/prettier/blob/master/CHANGELOG.md#&#8203;1134)
[Compare Source](prettier/prettier@1.13.3...1.13.4)
[link](prettier/prettier@1.13.3...1.13.4)

- Fix a regression when printing graphql-in-js ([#&#8203;4616](`https://github.com/prettier/prettier/pull/4616`))

---

</details>




---

This PR has been generated by [Renovate Bot](https://renovatebot.com).

Co-authored-by: Renovate Bot <[email protected]>
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Aug 29, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Aug 29, 2018
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