Skip to content
This repository was archived by the owner on Feb 9, 2023. It is now read-only.

Commit 2b6a4c5

Browse files
authored
Merge pull request #31 from stylelint/fix-maximum-call-stack-size-exceeded-error
Fix maximum call stack size exceeded error
2 parents ca9a49c + 46da7db commit 2b6a4c5

File tree

4 files changed

+220
-1
lines changed

4 files changed

+220
-1
lines changed

template-parser-helper.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ module.exports = {
8686
function parseTemplateLiteralStyles(styles, input, range) {
8787
const offset = input.quasis[0].start;
8888
const source = input.css;
89-
const parseStyle = docFixer(offset, source, input.parseOptions);
89+
90+
const opts = Object.assign({}, input.parseOptions);
91+
92+
delete opts.templateLiteralStyles;
93+
delete opts.expressions;
94+
delete opts.quasis;
95+
96+
const parseStyle = docFixer(offset, source, opts);
9097

9198
const nodes = [];
9299
let index = range[0];
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import styled, { css } from 'styled-components';
2+
const StyledComponent = styled.div`
3+
margin: 8px 0;
4+
5+
${() =>
6+
css`
7+
div {
8+
${expr};
9+
}
10+
`}
11+
`;
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
{
2+
"raws": {},
3+
"type": "root",
4+
"nodes": [
5+
{
6+
"raws": {
7+
"semicolon": false,
8+
"after": "\n"
9+
},
10+
"type": "root",
11+
"nodes": [
12+
{
13+
"raws": {
14+
"before": "\n ",
15+
"between": ": "
16+
},
17+
"type": "decl",
18+
"source": {
19+
"start": {
20+
"line": 3,
21+
"column": 3
22+
},
23+
"input": {
24+
"file": "styled-components-nesting-expr.js",
25+
"quasis": [
26+
{
27+
"start": 84,
28+
"end": 105
29+
},
30+
{
31+
"start": 165,
32+
"end": 166
33+
}
34+
]
35+
},
36+
"end": {
37+
"line": 3,
38+
"column": 16
39+
}
40+
},
41+
"prop": "margin",
42+
"value": "8px 0"
43+
},
44+
{
45+
"raws": {
46+
"before": "\n\n "
47+
},
48+
"text": "${() =>\n css`\n div {\n ${expr};\n }\n `}",
49+
"type": "literal",
50+
"source": {
51+
"start": {
52+
"line": 5,
53+
"column": 3
54+
},
55+
"input": {
56+
"file": "styled-components-nesting-expr.js",
57+
"quasis": [
58+
{
59+
"start": 84,
60+
"end": 105
61+
},
62+
{
63+
"start": 165,
64+
"end": 166
65+
}
66+
]
67+
}
68+
},
69+
"nodes": [
70+
{
71+
"raws": {
72+
"semicolon": false,
73+
"after": "\n "
74+
},
75+
"type": "root",
76+
"nodes": [
77+
{
78+
"raws": {
79+
"before": "\n ",
80+
"between": " ",
81+
"semicolon": false,
82+
"after": "\n "
83+
},
84+
"type": "rule",
85+
"nodes": [
86+
{
87+
"raws": {
88+
"before": "\n ",
89+
"ownSemicolon": ";"
90+
},
91+
"text": "${expr}",
92+
"type": "literal",
93+
"source": {
94+
"start": {
95+
"line": 8,
96+
"column": 9
97+
},
98+
"input": {
99+
"file": "styled-components-nesting-expr.js",
100+
"quasis": [
101+
{
102+
"start": 121,
103+
"end": 142
104+
},
105+
{
106+
"start": 149,
107+
"end": 163
108+
}
109+
]
110+
}
111+
}
112+
}
113+
],
114+
"source": {
115+
"start": {
116+
"line": 7,
117+
"column": 7
118+
},
119+
"input": {
120+
"file": "styled-components-nesting-expr.js",
121+
"quasis": [
122+
{
123+
"start": 121,
124+
"end": 142
125+
},
126+
{
127+
"start": 149,
128+
"end": 163
129+
}
130+
]
131+
},
132+
"end": {
133+
"line": 9,
134+
"column": 7
135+
}
136+
},
137+
"selector": "div"
138+
}
139+
],
140+
"source": {
141+
"input": {
142+
"file": "styled-components-nesting-expr.js",
143+
"quasis": [
144+
{
145+
"start": 121,
146+
"end": 142
147+
},
148+
{
149+
"start": 149,
150+
"end": 163
151+
}
152+
]
153+
},
154+
"start": {
155+
"line": 6,
156+
"column": 9
157+
},
158+
"inline": false,
159+
"lang": "template-literal",
160+
"syntax": {}
161+
}
162+
}
163+
]
164+
}
165+
],
166+
"source": {
167+
"input": {
168+
"file": "styled-components-nesting-expr.js",
169+
"quasis": [
170+
{
171+
"start": 84,
172+
"end": 105
173+
},
174+
{
175+
"start": 165,
176+
"end": 166
177+
}
178+
]
179+
},
180+
"start": {
181+
"line": 2,
182+
"column": 36
183+
},
184+
"inline": false,
185+
"lang": "template-literal",
186+
"syntax": {}
187+
}
188+
}
189+
],
190+
"source": {
191+
"input": {
192+
"file": "styled-components-nesting-expr.js"
193+
},
194+
"start": {
195+
"line": 1,
196+
"column": 1
197+
},
198+
"lang": "jsx"
199+
}
200+
}

test/supports.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ describe('should support for each CSS in JS package', () => {
4242
'lit-css.mjs',
4343
'react-emotion.jsx',
4444
'react-native.mjs',
45+
'styled-components-nesting-expr.js',
4546
'styled-components-nesting.js',
4647
'styled-components-nesting2.js',
4748
'styled-components-nesting3.js',

0 commit comments

Comments
 (0)