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

Empty JSON/graphql file throws error #4448

Closed
azz opened this issue May 9, 2018 · 3 comments
Closed

Empty JSON/graphql file throws error #4448

azz opened this issue May 9, 2018 · 3 comments
Labels
lang:graphql Issues affecting GraphQL lang:json Issues affecting JSON locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program

Comments

@azz
Copy link
Member

azz commented May 9, 2018

If a JSON file is empty or just has whitespace, Prettier throws an error. I think we should just output an empty file in this case. This issue causes prettier/pretty-quick#28.

Prettier 1.12.1
Playground link

--parser json

Input:

 

Output:

SyntaxError: Unexpected token (1:2)
> 1 |  
    |  ^
@azz azz added type:bug Issues identifying ugly output, or a defect in the program lang:json Issues affecting JSON labels May 9, 2018
@lipis
Copy link
Member

lipis commented May 9, 2018

What about other empty file types?

@azz
Copy link
Member Author

azz commented May 10, 2018

I thought all the other would be fine (empty file is already ok), but looks like graphql fails too.

@azz azz added the lang:graphql Issues affecting GraphQL label May 10, 2018
@azz azz changed the title Empty JSON file throws error Empty JSON/graphql file throws error May 10, 2018
@ad1992
Copy link
Contributor

ad1992 commented May 26, 2018

@azz @lipis the graphql empty file error is due to the parse of graphql .

  const parser = require("graphql/language");
  parser.parse("");

This gives GraphQLError: Syntax Error: Unexpected <EOF>
Can be veriffied here as well https://graphql.github.io/swapi-graphql/?

@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
lang:graphql Issues affecting GraphQL lang:json Issues affecting JSON locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

3 participants