Inlined chunks of css in styled-component template literal gets joined to next line
See original GitHub issuePrettier 1.14.3 Playground link
Input:
const secondary = `
font-size: 12px;
`;
const foo = styled.div`
${secondary}
flex: 0 0 auto;
`;
Output:
const secondary = `
font-size: 12px;
`;
const foo = styled.div`
${secondary} flex: 0 0 auto;
`;
Expected behavior:
Since a ${}
expression can be anything, don’t join subsequent lines to it. It’s not likely to ever be the correct thing to do.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Styled-Components and Template Literals - Stack Overflow
Is this valid JS ?? and what does it mean? This is a code snippet from styled-components Library? const Button = styled.a` /* ......
Read more >Getting Sassy with styled-components | by Adam Gruber
Progressively migrating your app from Sass to styled-components seems daunting, but with a couple of quick tips and the right tooling it's a...
Read more >Working with Styled-components in React - Section.io
Styled -components are based on tagged template literals, meaning actual CSS code is written between backticks when styling your components.
Read more >Template Literals | CSS-Tricks
The Template Literal, introduced in ES6, is a new way to create a string. With it comes new features that allow us more...
Read more >FAQs - styled-components
In general, always use the css helper when composing styling partials to be interpolated into a styled component.. import styled, { keyframes } ......
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 FreeTop 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
Top GitHub Comments
In theory to avoid this issue we should keep line break if he exists, because it is hard to detect should we add newline or not
@lydell
Yeah, true, but there-in lies the flexibility, right? 😄
I couldn’t find a way, but is it possible to just turn off parsing of template literal content somewhere?