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
Added support for the graph ql comment tag #4395
Conversation
As described in the issue #4360 Prettier still adds a space inbetween the comment tag and the template literal.
After reading #4395 (comment) I don't think we should do this. Feels really hack-ish. The suggestion in #4360 (comment) seems like a better solution const gql = String.raw;
gql`query MyQuery {}`; |
@duailibe well I mean this is the way those other tools do this as well, so its not more or less hacky than those other tools ("would you jump off a bridge if your friends did" fallacy i know...) additionally const gql = String.raw;
gql`query MyQuery {}`; also feels kinda hacky... but its your call, I understand your hesitation to merge this 😕 |
Actually after thinking about it, the Additionally I dislike it as a workaround because of someone sees |
@duailibe could you expound on why you think we shouldn't do this? |
@suchipi Just because we already have a pretty consistent way to format non-JS stuff in JS, that is using template literals or Comments is an area of Prettier that works good enough for the effort we've put in but we still get reports of it's behavior so it seems a fragile strategy to rely on them for this kind of stuff. That said, I changed my mind and I don't oppose to it. If other maintainers are comfortable with adding this functionality, I'm on board. |
So what is the status of this discussion? |
I’m 👍 on the change, and @duailibe seems have changed their mind and is also 👍 (or at least not 👎). |
@tjallingt to fix the test, you probably need to skip the check of the AST here: https://github.com/prettier/prettier/blob/master/src/language-js/clean.js More specifically, something along these lines: prettier/src/language-js/clean.js Lines 111 to 132 in 8e1b60e
|
That should fix the failing test 👍 I really dislike that I had to duplicate the hasGraphQLComment stuff so maybe that should be exported to EDIT: this also still adds an undesired space between the comment tag and the template literal, I could take a look at fixing that if desired but I have a hunch that might be kinda tricky 😕 |
@tjallingt let's not worry about the space between the comment and the template literal tag for now. Also, I'm not sure we have a consistent approach with duplicated logic in clean; do whatever you feel is best. |
The it's ready for review and merge I think |
@tjallingt There are some merge conflicts to fix before merging, though |
Fixed the conflicts |
oh mb didn't see them 😕 |
As described in the issue #4360
Prettier still adds a space in between the comment tag and the template literal.