Force template literals to break after ` for sytled-components (#2926)

Force template literals to break after ` for styled-components
master
Lucas Duailibe 2017-10-02 12:55:42 -03:00 committed by Simon Lydell
parent 64ec692b92
commit 2466ce11a5
3 changed files with 28 additions and 1 deletions

View File

@ -177,6 +177,13 @@ function fromHtmlParser2(path, options) {
function transformCssDoc(quasisDoc, parent) {
const parentNode = parent.path.getValue();
const isEmpty =
parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
if (isEmpty) {
return "``";
}
const expressionDocs = parentNode.expressions
? parent.path.map(parent.print, "expressions")
: [];
@ -187,7 +194,7 @@ function transformCssDoc(quasisDoc, parent) {
}
return concat([
"`",
indent(concat([softline, stripTrailingHardline(newDoc)])),
indent(concat([hardline, stripTrailingHardline(newDoc)])),
softline,
"`"
]);

View File

@ -1,6 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`styled-components.js 1`] = `
const ListItem = styled.li\`\`;
const ListItem = styled.li\` \`;
const Dropdown = styled.div\`position: relative;\`
const Button = styled.button\`
color: palevioletred ;
@ -22,6 +28,14 @@ styled(ExistingComponent)\`
styled.button.attr({})\`
border : rebeccapurple\`;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const ListItem = styled.li\`\`;
const ListItem = styled.li\`\`;
const Dropdown = styled.div\`
position: relative;
\`;
const Button = styled.button\`
color: palevioletred;

View File

@ -1,3 +1,9 @@
const ListItem = styled.li``;
const ListItem = styled.li` `;
const Dropdown = styled.div`position: relative;`
const Button = styled.button`
color: palevioletred ;