-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Prettier respects template literals, but not tagged templates #3670
Copy link
Copy link
Closed
Labels
area:multiparserIssues with printing one language inside another, like CSS-in-JSIssues with printing one language inside another, like CSS-in-JSlang:javascriptIssues affecting JSIssues affecting JSlang:markdownIssues affecting MarkdownIssues affecting Markdownlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!Issues with an accompanying pull request. These issues will probably be fixed soon!
Metadata
Metadata
Assignees
Labels
area:multiparserIssues with printing one language inside another, like CSS-in-JSIssues with printing one language inside another, like CSS-in-JSlang:javascriptIssues affecting JSIssues affecting JSlang:markdownIssues affecting MarkdownIssues affecting Markdownlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!Issues with an accompanying pull request. These issues will probably be fixed soon!
As far as I can tell, it's prettier's philosophy to leave template literals unaffected (except for breaking on the tokens) because adding breaks and indentation actually modifies the code. This tends to work fine, but it breaks when it comes to tagged templates, the syntax where you call a function with a template literal and leave off the parens.
A simple fix in my code was to add the parens back in to the function call, but this won't work for everyone as it actually changes the arguments for the resulting function call.
Prettier 1.9.2
Playground link
Input:
Output: