-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Prettier assumes untagged template string parameter is graphql #7790
Comments
Do not use |
When a "formatter" starts dictating what names can be used for functions it has gone beyond the scope of formatting. |
Yep, that's a known issue: #5588. |
Not sure this really qualifies as a duplicate of #5588. That issue is about tagged templates. |
Good point, but essentially it's the same problem. |
We should reopen this. This is not about This comment prettier/src/language-js/embed.js Lines 50 to 58 in 29b9f6b
graphql() , we should just exclude CallExpression prettier/src/language-js/embed.js Lines 515 to 517 in 29b9f6b
html: only check prettier/src/language-js/embed.js Line 543 in 29b9f6b
markdown: same prettier/src/language-js/embed.js Line 164 in 29b9f6b
css: same prettier/src/language-js/embed.js Line 365 in 29b9f6b
|
It's enough to mention this in #5588. No need to treat this as a separate issue. |
But we are not going to fix #5588 in the near future, right? But |
Okay, let's mark it as bug until we do not disable prettify tagged templated |
Okay, but calling it a bug is strange, given that it was intentionally implemented in #2781 as a solution for #2780. Conceptually, it's the same feature as formatting tagged templates. As we don't know how many users rely on this currently, we can't just remove it, which means it needs configurability. So it's really the same problem as #5588 / #6626. |
I didn't know #2781 , if we don't want remove this feature now, maybe we can make it only work on second argument? |
@thorn0 I agree with you, but we still haven’t decided how to fix it:
Sometimes I found formatting tagged templates is very useful, I would not want to delete it, but I understand that this is a potentially dangerous action, with limitations, maybe we should describe them in docs |
@fisker Yes, why not, sounds good. @evilebottnawi Something like #6626 has to be implemented. I see no other ways. |
@thorn0 Yep, but i think it is not high priority right now |
Prettier 1.19.1
Playground link
Input:
Output:
Expected behavior:
The template strings passed to
graphql()
should not be reformatted because there is no guarantee that they are graphql queries.The text was updated successfully, but these errors were encountered: