Skip to content

Commit b1eac6d

Browse files
authored
fix: don't recognize directives in ES3, allow parenthesized rest target (#554)
1 parent bd3b5c6 commit b1eac6d

8 files changed

Lines changed: 333 additions & 14 deletions

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
"bugs": {
3030
"url": "https://github.com/eslint/espree/issues"
3131
},
32-
"funding":"https://opencollective.com/eslint",
32+
"funding": "https://opencollective.com/eslint",
3333
"license": "BSD-2-Clause",
3434
"dependencies": {
35-
"acorn": "^8.7.1",
35+
"acorn": "^8.8.0",
3636
"acorn-jsx": "^5.3.2",
3737
"eslint-visitor-keys": "^3.3.0"
3838
},

tests/fixtures/ecma-version/3/strict/func-strict.result.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ export default {
101101
],
102102
"value": "use strict",
103103
"raw": "\"use strict\""
104-
},
105-
"directive": "use strict"
104+
}
106105
},
107106
{
108107
"type": "VariableDeclaration",

tests/fixtures/ecma-version/3/strict/use-strict.result.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ export default {
4949
],
5050
"value": "use strict",
5151
"raw": "\"use strict\""
52-
},
53-
"directive": "use strict"
52+
}
5453
},
5554
{
5655
"type": "VariableDeclaration",

tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-3.result.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-3.src.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/fixtures/ecma-version/9/rest-property/invalid-parenthesized-4.result.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ export default {
22
"index": 5,
33
"lineNumber": 1,
44
"column": 6,
5-
"message": "Parenthesized pattern"
5+
"message": "Assigning to rvalue"
66
};
Lines changed: 327 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,327 @@
1+
export default {
2+
"type": "Program",
3+
"loc": {
4+
"start": {
5+
"line": 1,
6+
"column": 0
7+
},
8+
"end": {
9+
"line": 1,
10+
"column": 19
11+
}
12+
},
13+
"range": [
14+
0,
15+
19
16+
],
17+
"body": [
18+
{
19+
"type": "ExpressionStatement",
20+
"loc": {
21+
"start": {
22+
"line": 1,
23+
"column": 0
24+
},
25+
"end": {
26+
"line": 1,
27+
"column": 19
28+
}
29+
},
30+
"range": [
31+
0,
32+
19
33+
],
34+
"expression": {
35+
"type": "AssignmentExpression",
36+
"loc": {
37+
"start": {
38+
"line": 1,
39+
"column": 1
40+
},
41+
"end": {
42+
"line": 1,
43+
"column": 17
44+
}
45+
},
46+
"range": [
47+
1,
48+
17
49+
],
50+
"operator": "=",
51+
"left": {
52+
"type": "ObjectPattern",
53+
"loc": {
54+
"start": {
55+
"line": 1,
56+
"column": 1
57+
},
58+
"end": {
59+
"line": 1,
60+
"column": 11
61+
}
62+
},
63+
"range": [
64+
1,
65+
11
66+
],
67+
"properties": [
68+
{
69+
"type": "RestElement",
70+
"loc": {
71+
"start": {
72+
"line": 1,
73+
"column": 2
74+
},
75+
"end": {
76+
"line": 1,
77+
"column": 10
78+
}
79+
},
80+
"range": [
81+
2,
82+
10
83+
],
84+
"argument": {
85+
"type": "Identifier",
86+
"loc": {
87+
"start": {
88+
"line": 1,
89+
"column": 6
90+
},
91+
"end": {
92+
"line": 1,
93+
"column": 9
94+
}
95+
},
96+
"range": [
97+
6,
98+
9
99+
],
100+
"name": "obj"
101+
}
102+
}
103+
]
104+
},
105+
"right": {
106+
"type": "Identifier",
107+
"loc": {
108+
"start": {
109+
"line": 1,
110+
"column": 14
111+
},
112+
"end": {
113+
"line": 1,
114+
"column": 17
115+
}
116+
},
117+
"range": [
118+
14,
119+
17
120+
],
121+
"name": "foo"
122+
}
123+
}
124+
}
125+
],
126+
"sourceType": "script",
127+
"tokens": [
128+
{
129+
"type": "Punctuator",
130+
"value": "(",
131+
"loc": {
132+
"start": {
133+
"line": 1,
134+
"column": 0
135+
},
136+
"end": {
137+
"line": 1,
138+
"column": 1
139+
}
140+
},
141+
"range": [
142+
0,
143+
1
144+
]
145+
},
146+
{
147+
"type": "Punctuator",
148+
"value": "{",
149+
"loc": {
150+
"start": {
151+
"line": 1,
152+
"column": 1
153+
},
154+
"end": {
155+
"line": 1,
156+
"column": 2
157+
}
158+
},
159+
"range": [
160+
1,
161+
2
162+
]
163+
},
164+
{
165+
"type": "Punctuator",
166+
"value": "...",
167+
"loc": {
168+
"start": {
169+
"line": 1,
170+
"column": 2
171+
},
172+
"end": {
173+
"line": 1,
174+
"column": 5
175+
}
176+
},
177+
"range": [
178+
2,
179+
5
180+
]
181+
},
182+
{
183+
"type": "Punctuator",
184+
"value": "(",
185+
"loc": {
186+
"start": {
187+
"line": 1,
188+
"column": 5
189+
},
190+
"end": {
191+
"line": 1,
192+
"column": 6
193+
}
194+
},
195+
"range": [
196+
5,
197+
6
198+
]
199+
},
200+
{
201+
"type": "Identifier",
202+
"value": "obj",
203+
"loc": {
204+
"start": {
205+
"line": 1,
206+
"column": 6
207+
},
208+
"end": {
209+
"line": 1,
210+
"column": 9
211+
}
212+
},
213+
"range": [
214+
6,
215+
9
216+
]
217+
},
218+
{
219+
"type": "Punctuator",
220+
"value": ")",
221+
"loc": {
222+
"start": {
223+
"line": 1,
224+
"column": 9
225+
},
226+
"end": {
227+
"line": 1,
228+
"column": 10
229+
}
230+
},
231+
"range": [
232+
9,
233+
10
234+
]
235+
},
236+
{
237+
"type": "Punctuator",
238+
"value": "}",
239+
"loc": {
240+
"start": {
241+
"line": 1,
242+
"column": 10
243+
},
244+
"end": {
245+
"line": 1,
246+
"column": 11
247+
}
248+
},
249+
"range": [
250+
10,
251+
11
252+
]
253+
},
254+
{
255+
"type": "Punctuator",
256+
"value": "=",
257+
"loc": {
258+
"start": {
259+
"line": 1,
260+
"column": 12
261+
},
262+
"end": {
263+
"line": 1,
264+
"column": 13
265+
}
266+
},
267+
"range": [
268+
12,
269+
13
270+
]
271+
},
272+
{
273+
"type": "Identifier",
274+
"value": "foo",
275+
"loc": {
276+
"start": {
277+
"line": 1,
278+
"column": 14
279+
},
280+
"end": {
281+
"line": 1,
282+
"column": 17
283+
}
284+
},
285+
"range": [
286+
14,
287+
17
288+
]
289+
},
290+
{
291+
"type": "Punctuator",
292+
"value": ")",
293+
"loc": {
294+
"start": {
295+
"line": 1,
296+
"column": 17
297+
},
298+
"end": {
299+
"line": 1,
300+
"column": 18
301+
}
302+
},
303+
"range": [
304+
17,
305+
18
306+
]
307+
},
308+
{
309+
"type": "Punctuator",
310+
"value": ";",
311+
"loc": {
312+
"start": {
313+
"line": 1,
314+
"column": 18
315+
},
316+
"end": {
317+
"line": 1,
318+
"column": 19
319+
}
320+
},
321+
"range": [
322+
18,
323+
19
324+
]
325+
}
326+
]
327+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
({...(obj)} = foo);

0 commit comments

Comments
 (0)