Repository navigation
Labels
area:multiparserIssues with printing one language inside another, like CSS-in-JSlang:css/scss/lessIssues affecting CSS, Less or SCSSlang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.
Description
note the presence/absence of ; after injected expression
const Header = styled.div`
${something()};
margin:4px;
`is parsed and formatted as
const Header = styled.div`
${something()};
margin: 4px;
`;const Header = styled.div`
${something()}
margin:4px;
`is parsed and formatted as
const Header = styled.div`
${something()}
margin:4px;
`;const Header = styled.div`
${something()};
& > ${Child}:not(:first-child) {
margin-left:5px;
}
`is parsed and formatted as
const Header = styled.div`
${something()};
& > ${Child}:not(:first-child) {
margin-left: 5px;
}
`;const Header = styled.div`
${something()}
& > ${Child}:not(:first-child) {
margin-left:5px;
}
`is not parsed
Error: Couldn't insert all the expressions
at transformCssDoc (https://prettier.io/lib/standalone.js:22171:11)
at Object.embed$4 [as embed] (https://prettier.io/lib/standalone.js:22011:18)
at Object.printSubtree (https://prettier.io/lib/standalone.js:15781:31)
at callPluginPrintFunction (https://prettier.io/lib/standalone.js:15898:29)
at https://prettier.io/lib/standalone.js:15863:16
at Object.printComments (https://prettier.io/lib/standalone.js:15586:17)
at printGenerically (https://prettier.io/lib/standalone.js:15862:22)
at FastPath.call (https://prettier.io/lib/standalone.js:15700:16)
at printPathNoParens (https://prettier.io/lib/standalone.js:25178:91)
at Object.genericPrint$3 [as print] (https://prettier.io/lib/standalone.js:23541:28)
Metadata
Metadata
Assignees
Labels
area:multiparserIssues with printing one language inside another, like CSS-in-JSlang:css/scss/lessIssues affecting CSS, Less or SCSSlang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.
Activity
thorn0 commentedon Apr 20, 2020
Note that this error is shown only on the playground for debugging purposes. In production, Prettier just skips formatting this template literal. And I'd say this is the right thing to do because how can we know what
something()can be? It can be a part of the selector or a separate rule set, so it's not clear how to format it. Leaving it as is the safest option.thecodrr commentedon Apr 20, 2020
The error occurs when you have multiple string concatenations. If you remove
${Child}or${something()}, there's no error. As such, this works without an issue:thecodrr commentedon Apr 20, 2020
@thorn0 Can I claim this?
thorn0 commentedon Apr 20, 2020
@thecodrr I'm already looking into it.
thecodrr commentedon Apr 20, 2020
Oops. Okay good luck.