-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
styled components interpolated selectors dont generate newline #6392
Copy link
Copy link
Open
Labels
area:multiparserIssues with printing one language inside another, like CSS-in-JSIssues with printing one language inside another, like CSS-in-JSlang:css/scss/lessIssues affecting CSS, Less or SCSSIssues affecting CSS, Less or SCSS
Description
If we have multiple styled components interpolated and separated by comma, the expected newline after the comma is missing.
Styled Components allow interpolation of nested styled components, see here for the syntax.
Prettier will put css selectors separated by , on new lines, introduced here: #2047. This works in styled components using regular css selectors, see second block in the playground link. It only fails when we try to use interpolated styled components.
Prettier 1.18.2
Playground link
--parser babelInput:
const A = styled(_A)`
${B}, ${C} {
style: value;
}
`
const A = styled(_A)`
.classA, .classB {
style: value;
}
`Output:
const A = styled(_A)`
${B}, ${C} {
style: value;
}
`;
const A = styled(_A)`
.classA,
.classB {
style: value;
}
`;Expected behavior:
const A = styled(_A)`
${B},
${C} {
style: value;
}
`;
const A = styled(_A)`
.classA,
.classB {
style: value;
}
`;Reactions are currently unavailable
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:css/scss/lessIssues affecting CSS, Less or SCSSIssues affecting CSS, Less or SCSS