fix(css-in-js): do not duplicate comments (#5416)

master
Ika 2018-11-10 16:43:59 +08:00 committed by GitHub
parent d4c248bb0b
commit cc6899e5c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 2 deletions

View File

@ -207,8 +207,11 @@ function genericPrint(path, options, print) {
? concat([ ? concat([
isDetachedRulesetCallNode(node) isDetachedRulesetCallNode(node)
? "" ? ""
: isTemplatePlaceholderNode(node) : isTemplatePlaceholderNode(node) &&
? node.raws.afterName /^\s*\n/.test(node.raws.afterName)
? /^\s*\n\s*\n/.test(node.raws.afterName)
? concat([hardline, hardline])
: hardline
: " ", : " ",
path.call(print, "params") path.call(print, "params")
]) ])

View File

@ -140,6 +140,25 @@ styled.a\`
margin: 0; margin: 0;
} }
\` \`
const StyledComponent = styled.div\`
\${anInterpolation}
/* a comment */
.aRule {
color: red
}
\`;
const StyledComponent = styled.div\`
\${anInterpolation}
/* a comment */
.aRule {
color: red
}
\`;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const ListItem = styled.li\`\`; const ListItem = styled.li\`\`;
@ -282,4 +301,23 @@ styled.a\`
} }
\`; \`;
const StyledComponent = styled.div\`
\${anInterpolation}
/* a comment */
.aRule {
color: red;
}
\`;
const StyledComponent = styled.div\`
\${anInterpolation}
/* a comment */
.aRule {
color: red;
}
\`;
`; `;

View File

@ -137,3 +137,22 @@ styled.a`
margin: 0; margin: 0;
} }
` `
const StyledComponent = styled.div`
${anInterpolation}
/* a comment */
.aRule {
color: red
}
`;
const StyledComponent = styled.div`
${anInterpolation}
/* a comment */
.aRule {
color: red
}
`;