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 empty file error in json and graphql #4553

Merged
merged 7 commits into from
Jun 6, 2018

Conversation

ad1992
Copy link
Contributor

@ad1992 ad1992 commented May 26, 2018

Fixes #4448

@duailibe
Copy link
Member

duailibe commented May 26, 2018

Can't we just do a check here?

const result = coreFormat(text, opts);

const result = text ? coreFormat(text, opts) : "";

@ad1992 ad1992 changed the title Fix empty file error in json Fix empty file error in json and graphql May 26, 2018
@ad1992
Copy link
Contributor Author

ad1992 commented May 27, 2018

The specs for graphql_empty_file and json_empty_file are passing in local but not in travis. I am not sure why. Can someone rerun the specs.

@j-f1
Copy link
Member

j-f1 commented May 27, 2018

It looks like they’re still failing after a re-run @ad1992.

@duailibe
Copy link
Member

are passing in local but not in travis

Are you running with AST_COMPARE=1 ?

@ad1992
Copy link
Contributor Author

ad1992 commented Jun 2, 2018

@duailibe yes you were right it was due to AST_COMPARE=1. Its fixed now.

@@ -63,14 +63,15 @@ function run_spec(dirname, parsers, options) {
if (AST_COMPARE) {
const compareOptions = Object.assign({}, mergedOptions);
delete compareOptions.cursorOffset;
const astMassaged = parse(input, compareOptions);
const astMassaged =
input && input.trim().length ? parse(input, compareOptions) : {};
Copy link
Member

Choose a reason for hiding this comment

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

This might no be the correct fix for this either... maybe we should handle that in prettier.__debug.parse

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reverted this as it got fixed when I rebased with master.

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`empty-file.graphql 1`] = `
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep these tests in tests/empty/.

Just edit tests/empty/jsfmt.spec.js to add graphql and json to the parsers

@ad1992
Copy link
Contributor Author

ad1992 commented Jun 5, 2018

@suchipi @duailibe can this be merged ?

@duailibe
Copy link
Member

duailibe commented Jun 5, 2018

Can you fix the lint failure?

@ad1992
Copy link
Contributor Author

ad1992 commented Jun 5, 2018

@duailibe I had already run yarn lint --fix so there should not be any lint issue.
size = size + tabWidth - (size % tabWidth); got converted to this when I ran yarn lint --fix
size = size + tabWidth - size % tabWidth;
should I revert it back ?

@lydell
Copy link
Member

lydell commented Jun 5, 2018

Well, Travis says that the parens should be there: https://travis-ci.org/prettier/prettier/jobs/387448061#L489

Perhaps your local node_modules is out of date? Try running yarn to update. Then I would guess yarn lint --fix would do the right thing.

@ad1992
Copy link
Contributor Author

ad1992 commented Jun 5, 2018

Yes node_modules was out of date. Its fixed now.

@ad1992
Copy link
Contributor Author

ad1992 commented Jun 6, 2018

@duailibe please review.

@duailibe duailibe merged commit 8ec5432 into prettier:master Jun 6, 2018
@duailibe
Copy link
Member

duailibe commented Jun 6, 2018

Thanks!

@ad1992 ad1992 deleted the aakansha-prettier branch June 6, 2018 13:48
bors bot referenced this pull request in mozilla/delivery-console Jun 8, 2018
185: Update dependency prettier to v1.13.5 r=rehandalal a=renovate[bot]

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



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

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

- Better handling of trailing spaces in Markdown ([#&#8203;4593](`https://github.com/prettier/prettier/pull/4593`))
- Fix empty file error in JSON and GraphQL ([#&#8203;4553](`https://github.com/prettier/prettier/pull/4553`))
- Preserve decorator on TypeScript interfaces ([#&#8203;4632](`https://github.com/prettier/prettier/pull/4632`))
- Inline \_ or $ in the root of a method chain ([#&#8203;4621](`https://github.com/prettier/prettier/pull/4621`))

---

</details>




---

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

Co-authored-by: Renovate Bot <[email protected]>
peterbe referenced this pull request in mozilla-services/tecken Jun 22, 2018
This Pull Request updates dependency [prettier](https://github.com/prettier/prettier) from `v1.13.4` to `v1.13.5`



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

### [`v1.13.5`](https://github.com/prettier/prettier/blob/master/CHANGELOG.md#&#8203;1135)
[Compare Source](prettier/prettier@1.13.4...1.13.5)
[diff](prettier/prettier@1.13.4...1.13.5)

- Better handling of trailing spaces in Markdown ([#&#8203;4593](`https://github.com/prettier/prettier/pull/4593`))
- Fix empty file error in JSON and GraphQL ([#&#8203;4553](`https://github.com/prettier/prettier/pull/4553`))
- Preserve decorator on TypeScript interfaces ([#&#8203;4632](`https://github.com/prettier/prettier/pull/4632`))
- Inline \_ or $ in the root of a method chain ([#&#8203;4621](`https://github.com/prettier/prettier/pull/4621`))

---

</details>




---

This PR has been generated by [Renovate Bot](https://renovatebot.com).
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Sep 4, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Sep 4, 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.

5 participants