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
Selectors within template literal CSS get newlined and cause parsing error #13961
Comments
…What does the title mean |
Thanks for updating the title @kylemh! I guess this bug is similar to #6392 and #5086 In the meantime, you can use Prettier 2.8.8 --parser babel Input: const SomeStyledSpan = styled.span``;
const SomeStyledDiv = styled.div``;
const SomeStyledSection = styled.section``;
// prettier-ignore
const SomeStyledComponent = styled.span`
& ${SomeStyledSpan}:empty ~ ${SomeStyledDiv} ${SomeStyledSection},
& ${SomeStyledSpan}:active ~ ${LabelContainer} ${SomeStyledSection} {
transform: none;
}
`; Output: const SomeStyledSpan = styled.span``;
const SomeStyledDiv = styled.div``;
const SomeStyledSection = styled.section``;
// prettier-ignore
const SomeStyledComponent = styled.span`
& ${SomeStyledSpan}:empty ~ ${SomeStyledDiv} ${SomeStyledSection},
& ${SomeStyledSpan}:active ~ ${LabelContainer} ${SomeStyledSection} {
transform: none;
}
`; |
Yep! I've been using One big difference between the linked issues is that the formatting in this issue causes CSS parser errors. Prettier breaks other tools here. The other two issues are just about subjective desires regarding when/how to do line breaks after comma separations. Prettier doesn't break other tools regardless of those issues being worked on or ignored. In other words, I think this issue is a much bigger deal than #6392 or #5086 |
Prettier 2.7.1
Playground link
Input:
Output:
Expected behavior:
When using
styled-components
strings can't wrap if they're part of a single selector otherwise we get a CSS parsing error.The text was updated successfully, but these errors were encountered: