Fix formatting styled(Foo).attrs(...)`` (#3073)

master
Brian Ng 2017-10-20 17:10:55 -05:00 committed by Lucas Azzola
parent 5b7b012fcd
commit 12f028cd46
3 changed files with 16 additions and 3 deletions

View File

@ -430,10 +430,13 @@ function isStyledComponents(path) {
return ( return (
// styled(Component)`` // styled(Component)``
isStyledIdentifier(tag.callee) || isStyledIdentifier(tag.callee) ||
// styled.foo.attr({})``
(tag.callee.type === "MemberExpression" && (tag.callee.type === "MemberExpression" &&
tag.callee.object.type === "MemberExpression" && // styled.foo.attr({})``
isStyledIdentifier(tag.callee.object.object)) ((tag.callee.object.type === "MemberExpression" &&
isStyledIdentifier(tag.callee.object.object)) ||
// styled(Component).attr({})``
(tag.callee.object.type === "CallExpression" &&
isStyledIdentifier(tag.callee.object.callee))))
); );
case "Identifier": case "Identifier":

View File

@ -27,6 +27,9 @@ styled(ExistingComponent)\`
styled.button.attr({})\` styled.button.attr({})\`
border : rebeccapurple\`; border : rebeccapurple\`;
styled(ExistingComponent).attr({})\`
border : rebeccapurple\`;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const ListItem = styled.li\`\`; const ListItem = styled.li\`\`;
@ -57,4 +60,8 @@ styled.button.attr({})\`
border: rebeccapurple; border: rebeccapurple;
\`; \`;
styled(ExistingComponent).attr({})\`
border: rebeccapurple;
\`;
`; `;

View File

@ -24,3 +24,6 @@ styled(ExistingComponent)`
styled.button.attr({})` styled.button.attr({})`
border : rebeccapurple`; border : rebeccapurple`;
styled(ExistingComponent).attr({})`
border : rebeccapurple`;