Skip to content

Commit a3ae0bd

Browse files
Upgrade: acorn to 5.0.1 (#327)
* Upgrade: acorn to 5.0.1 * Remove FunctionExpression conversion logic * Add tests for parenthesized functions/classes (fixes #302)
1 parent 15ef24f commit a3ae0bd

7 files changed

+535
-10
lines changed

espree.js

-7
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,6 @@ function esprimaFinishNode(result) {
194194
}
195195
}
196196

197-
// Acorn currently uses expressions instead of declarations in default exports
198-
if (result.type === "ExportDefaultDeclaration") {
199-
if (/^(Class|Function)Expression$/.test(result.declaration.type)) {
200-
result.declaration.type = result.declaration.type.replace("Expression", "Declaration");
201-
}
202-
}
203-
204197
// Acorn uses undefined instead of null, which affects serialization
205198
if (result.type === "Literal" && result.value === undefined) {
206199
result.value = null;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"license": "BSD-2-Clause",
2020
"dependencies": {
21-
"acorn": "^4.0.11",
21+
"acorn": "^5.0.1",
2222
"acorn-jsx": "^3.0.0"
2323
},
2424
"devDependencies": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
module.exports = {
2+
"type": "Program",
3+
"start": 0,
4+
"end": 26,
5+
"loc": {
6+
"start": {
7+
"line": 1,
8+
"column": 0
9+
},
10+
"end": {
11+
"line": 1,
12+
"column": 26
13+
}
14+
},
15+
"range": [
16+
0,
17+
26
18+
],
19+
"body": [
20+
{
21+
"type": "ExportDefaultDeclaration",
22+
"start": 0,
23+
"end": 26,
24+
"loc": {
25+
"start": {
26+
"line": 1,
27+
"column": 0
28+
},
29+
"end": {
30+
"line": 1,
31+
"column": 26
32+
}
33+
},
34+
"range": [
35+
0,
36+
26
37+
],
38+
"declaration": {
39+
"type": "ClassExpression",
40+
"start": 16,
41+
"end": 24,
42+
"loc": {
43+
"start": {
44+
"line": 1,
45+
"column": 16
46+
},
47+
"end": {
48+
"line": 1,
49+
"column": 24
50+
}
51+
},
52+
"range": [
53+
16,
54+
24
55+
],
56+
"id": null,
57+
"superClass": null,
58+
"body": {
59+
"type": "ClassBody",
60+
"start": 22,
61+
"end": 24,
62+
"loc": {
63+
"start": {
64+
"line": 1,
65+
"column": 22
66+
},
67+
"end": {
68+
"line": 1,
69+
"column": 24
70+
}
71+
},
72+
"range": [
73+
22,
74+
24
75+
],
76+
"body": []
77+
}
78+
}
79+
}
80+
],
81+
"sourceType": "module",
82+
"tokens": [
83+
{
84+
"type": "Keyword",
85+
"value": "export",
86+
"start": 0,
87+
"end": 6,
88+
"loc": {
89+
"start": {
90+
"line": 1,
91+
"column": 0
92+
},
93+
"end": {
94+
"line": 1,
95+
"column": 6
96+
}
97+
},
98+
"range": [
99+
0,
100+
6
101+
]
102+
},
103+
{
104+
"type": "Keyword",
105+
"value": "default",
106+
"start": 7,
107+
"end": 14,
108+
"loc": {
109+
"start": {
110+
"line": 1,
111+
"column": 7
112+
},
113+
"end": {
114+
"line": 1,
115+
"column": 14
116+
}
117+
},
118+
"range": [
119+
7,
120+
14
121+
]
122+
},
123+
{
124+
"type": "Punctuator",
125+
"value": "(",
126+
"start": 15,
127+
"end": 16,
128+
"loc": {
129+
"start": {
130+
"line": 1,
131+
"column": 15
132+
},
133+
"end": {
134+
"line": 1,
135+
"column": 16
136+
}
137+
},
138+
"range": [
139+
15,
140+
16
141+
]
142+
},
143+
{
144+
"type": "Keyword",
145+
"value": "class",
146+
"start": 16,
147+
"end": 21,
148+
"loc": {
149+
"start": {
150+
"line": 1,
151+
"column": 16
152+
},
153+
"end": {
154+
"line": 1,
155+
"column": 21
156+
}
157+
},
158+
"range": [
159+
16,
160+
21
161+
]
162+
},
163+
{
164+
"type": "Punctuator",
165+
"value": "{",
166+
"start": 22,
167+
"end": 23,
168+
"loc": {
169+
"start": {
170+
"line": 1,
171+
"column": 22
172+
},
173+
"end": {
174+
"line": 1,
175+
"column": 23
176+
}
177+
},
178+
"range": [
179+
22,
180+
23
181+
]
182+
},
183+
{
184+
"type": "Punctuator",
185+
"value": "}",
186+
"start": 23,
187+
"end": 24,
188+
"loc": {
189+
"start": {
190+
"line": 1,
191+
"column": 23
192+
},
193+
"end": {
194+
"line": 1,
195+
"column": 24
196+
}
197+
},
198+
"range": [
199+
23,
200+
24
201+
]
202+
},
203+
{
204+
"type": "Punctuator",
205+
"value": ")",
206+
"start": 24,
207+
"end": 25,
208+
"loc": {
209+
"start": {
210+
"line": 1,
211+
"column": 24
212+
},
213+
"end": {
214+
"line": 1,
215+
"column": 25
216+
}
217+
},
218+
"range": [
219+
24,
220+
25
221+
]
222+
},
223+
{
224+
"type": "Punctuator",
225+
"value": ";",
226+
"start": 25,
227+
"end": 26,
228+
"loc": {
229+
"start": {
230+
"line": 1,
231+
"column": 25
232+
},
233+
"end": {
234+
"line": 1,
235+
"column": 26
236+
}
237+
},
238+
"range": [
239+
25,
240+
26
241+
]
242+
}
243+
]
244+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default (class {});

0 commit comments

Comments
 (0)