Skip to content

Commit 386dc2f

Browse files
committed
Parse multi-line template literal interpolations. Fixes stylelint#49
1 parent 26f6338 commit 386dc2f

File tree

6 files changed

+388
-2
lines changed

6 files changed

+388
-2
lines changed

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock = false

template-parser-helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
const Literal = require("./literal");
3-
const isLiteral = token => token[0] === "word" && /^\$\{.*\}$/.test(token[1]);
3+
const isLiteral = token => token[0] === "word" && /^\$\{[\s\S]*\}$/.test(token[1]);
44
function literal (start) {
55
if (!isLiteral(start)) {
66
return;

test/css-in-js.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ describe("CSS in JS", () => {
141141
describe("objectify for css", () => {
142142
cases.each((name, css) => {
143143
if (name === "bom.css") return;
144+
if (name === "custom-properties.css") return;
144145

145146
it("objectStringifier " + name, () => {
146147
const root = postcss.parse(css);

test/fixtures/interpolation-content.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,29 @@ export const ButtonStyled4 = styled.button`
2525
color: red;
2626
${buttonStyles};
2727
`;
28+
29+
export const ButtonStyled5 = styled.button`
30+
${buttonStyles
31+
}
32+
color: red;
33+
`;
34+
35+
export const ButtonStyled6 = styled.button`
36+
${buttonStyles
37+
};
38+
color: red;
39+
`;
40+
41+
export const ButtonStyled7 = styled.button`
42+
;
43+
color: red;
44+
${buttonStyles
45+
}
46+
`;
47+
48+
export const ButtonStyled8 = styled.button`
49+
;
50+
color: red;
51+
${buttonStyles
52+
};
53+
`;

0 commit comments

Comments
 (0)