Skip to content

Commit

Permalink
fix: correct prettier placeholder regex (#4302)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Apr 12, 2018
1 parent bdc5e00 commit 47cb5ad
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/language-js/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ function replacePlaceholders(quasisDoc, expressionDocs) {
const placeholder = parts[atPlaceholderIndex];
const rest = parts.slice(atPlaceholderIndex + 1);
const placeholderMatch = placeholder.match(
/@prettier-placeholder-(.+)-id(.*)/
/@prettier-placeholder-(.+)-id([\s\S]*)/
);
const placeholderID = placeholderMatch[1];
// When the expression has a suffix appended, like:
Expand Down
14 changes: 14 additions & 0 deletions tests/multiparser_js_css/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ styled.div\`
\${props => props.red ? 'color: red;' : ''};
/* prettier-ignore */
\`
styled.div\`
\${sanitize} \${fonts}
html {
margin: 0;
}
\`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const ListItem = styled.li\`\`;
Expand Down Expand Up @@ -136,4 +143,11 @@ styled.div\`
/* prettier-ignore */
\`;
styled.div\`
\${sanitize} \${fonts}
html {
margin: 0;
}
\`;
`;
7 changes: 7 additions & 0 deletions tests/multiparser_js_css/styled-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,10 @@ styled.div`
${props => props.red ? 'color: red;' : ''};
/* prettier-ignore */
`

styled.div`
${sanitize} ${fonts}
html {
margin: 0;
}
`

0 comments on commit 47cb5ad

Please sign in to comment.