Formatting incorrect using styled-component component selector pattern
See original GitHub issuePrettier 2.0.1 Playground link
--parser babel
Input:
const Icon = styled.div`
flex: none;
transition: fill 0.25s;
width: 48px;
height: 48px;
${Link}:hover {
fill: rebeccapurple;
}
`;
Output:
const Icon = styled.div`
flex: none;
transition: fill 0.25s;
width: 48px;
height: 48px;
${Link}: hover{
fill: rebeccapurple;
}
`;
Expected behavior:
const Icon = styled.div`
flex: none;
transition: fill 0.25s;
width: 48px;
height: 48px;
${Link}:hover {
fill: rebeccapurple;
}
`;
When using the component selector pattern from styled-components, I am seeing an issue with the formatting of the output CSS. This above is a slightly modified example from the documentation. Note that if I included an &
to the selector (before the curly brace) it will format correctly (e.g., ${Link}:hover &
).
The examples I am seeing in my own application are being formatted:
${DataCell}: empty: before{
${Tab}: first-child{
${Tab}:nth-child (2) {
All of which I would expect to break styling behavior.
Love the new update, though! The Prettier team must have worked incredibly hard to make so many impressive improvements.
Thank you for your time.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Advanced Usage - styled-components
styled -components has full theming support by exporting a <ThemeProvider> wrapper component. This component provides a theme to all React components underneath ...
Read more >Demystifying styled-components - Josh W Comeau
In this post, we'll learn exactly how styled-components works by ... it to a React component, bypassing the CSS selectors we've always used....
Read more >Before and After pseudo classes used with styled-components
Pseudo-selectors in styled-components work just like they do in CSS. (or rather, Sass) Whatever isn't working is likely a problem in your ...
Read more >How To Use React Styled Components Efficiently - Copycat
Using styled -components makes it simple to use actual CSS to style components by writing JavaScript code. These components are known as “styled ......
Read more >Styled Components: Enforcing Best Practices In Component ...
Because styled-components is just CSS, it supports all of CSS perfectly fine. Media queries, pseudo-selectors, even nesting just work. We are ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you for addressing so quickly!
@thorn0 yes, I think it will save the situation, that’s why I didn’t want to update postcss-less, as a contributor stylelint I have already raised more than once the question of forking a project and rewriting, maybe we should rush it