Skip to content

Commit f4b3af5

Browse files
authored
Breaking: Upgrade to Espree v4 alpha (refs #9990) (#10152)
This upgrades Espree to v4.0.0-alpha.0 and removes our duplicated tests that pair `experimentalObjectRestSpread` and `ecmaVersion: 2018`. It does not implement the deprecation warning or translating the former to the latter in the background.
1 parent 3351129 commit f4b3af5

19 files changed

+13
-681
lines changed

docs/rules/rest-spread-spacing.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,12 @@ As with other operators, whitespace is allowed between the rest or spread operat
4141

4242
## Rule Details
4343

44-
This rule aims to enforce consistent spacing between rest and spread operators and their expressions. The rule also supports the currently experimental object rest and spread properties when enabled:
44+
This rule aims to enforce consistent spacing between rest and spread operators and their expressions. The rule also supports object rest and spread properties in ES2018:
4545

4646
```json
4747
{
4848
"parserOptions": {
49-
"ecmaVersion": 6,
50-
"ecmaFeatures": {
51-
"experimentalObjectRestSpread": true
52-
}
49+
"ecmaVersion": 2018
5350
}
5451
}
5552
```

lib/config/config-initializer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ function processAnswers(answers) {
270270
config.parserOptions.ecmaFeatures.jsx = true;
271271
if (answers.react) {
272272
config.plugins = ["react"];
273-
config.parserOptions.ecmaFeatures.experimentalObjectRestSpread = true;
273+
config.parserOptions.ecmaVersion = 2018;
274274
}
275275
}
276276

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"doctrine": "^2.1.0",
4444
"eslint-scope": "^3.7.1",
4545
"eslint-visitor-keys": "^1.0.0",
46-
"espree": "^3.5.4",
46+
"espree": "^4.0.0-alpha.0",
4747
"esquery": "^1.0.0",
4848
"esutils": "^2.0.2",
4949
"file-entry-cache": "^2.0.0",

tests/lib/config/config-initializer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ describe("configInitializer", () => {
170170
const config = init.processAnswers(answers);
171171

172172
assert.strictEqual(config.parserOptions.ecmaFeatures.jsx, true);
173-
assert.strictEqual(config.parserOptions.ecmaFeatures.experimentalObjectRestSpread, true);
173+
assert.strictEqual(config.parserOptions.ecmaVersion, 2018);
174174
assert.deepStrictEqual(config.plugins, ["react"]);
175175
});
176176

tests/lib/linter.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3255,14 +3255,11 @@ describe("Linter", () => {
32553255
});
32563256
});
32573257

3258-
it("should properly parse object spread when passed ecmaFeatures", () => {
3258+
it("should properly parse object spread when ecmaVersion is 2018", () => {
32593259

32603260
const messages = linter.verify("var x = { ...y };", {
32613261
parserOptions: {
3262-
ecmaVersion: 6,
3263-
ecmaFeatures: {
3264-
experimentalObjectRestSpread: true
3265-
}
3262+
ecmaVersion: 2018
32663263
}
32673264
}, filename);
32683265

tests/lib/rules/comma-dangle.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ ruleTester.run("comma-dangle", rule, {
129129
},
130130

131131
// https://github.com/eslint/eslint/issues/7297
132-
{
133-
code: "var {foo, ...bar} = baz",
134-
options: ["always"],
135-
parserOptions: { ecmaVersion: 8, ecmaFeatures: { experimentalObjectRestSpread: true } }
136-
},
137132
{
138133
code: "var {foo, ...bar} = baz",
139134
options: ["always"],

tests/lib/rules/key-spacing.js

Lines changed: 1 addition & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -312,78 +312,6 @@ ruleTester.run("key-spacing", rule, {
312312

313313
// https://github.com/eslint/eslint/issues/4763
314314
{
315-
code: "({a : foo, ...x, b : bar})['a'];",
316-
options: [{
317-
beforeColon: true,
318-
afterColon: true
319-
}],
320-
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }
321-
}, {
322-
code: [
323-
"var obj = {",
324-
" 'a' : (42 - 12),",
325-
" ...x,",
326-
" foobar : 'value',",
327-
" [(expr)]: val",
328-
"};"
329-
].join("\n"),
330-
options: [{
331-
align: "colon"
332-
}],
333-
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }
334-
}, {
335-
code: [
336-
"callExpr(arg, {",
337-
" key :val,",
338-
" ...x,",
339-
" ...y,",
340-
" 'another' :false,",
341-
" [compute] :'value'",
342-
"});"
343-
].join("\n"),
344-
options: [{
345-
align: "colon",
346-
beforeColon: true,
347-
afterColon: false
348-
}],
349-
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }
350-
}, {
351-
code: [
352-
"var obj = {",
353-
" a: (42 - 12),",
354-
" ...x,",
355-
" 'foobar': 'value',",
356-
" bat: function() {",
357-
" return this.a;",
358-
" },",
359-
" baz: 42",
360-
"};"
361-
].join("\n"),
362-
options: [{
363-
align: "value"
364-
}],
365-
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }
366-
}, {
367-
code: [
368-
"({",
369-
" ...x,",
370-
" a : 0,",
371-
" // same group",
372-
" bcd: 0, /*",
373-
" end of group */",
374-
"",
375-
" // different group",
376-
" e: 0,",
377-
" ...y,",
378-
" /* group b */",
379-
" f: 0",
380-
"})"
381-
].join("\n"),
382-
options: [{
383-
align: "colon"
384-
}],
385-
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }
386-
}, {
387315
code: "({a : foo, ...x, b : bar})['a'];",
388316
options: [{
389317
beforeColon: true,
@@ -574,7 +502,7 @@ ruleTester.run("key-spacing", rule, {
574502
options: [{
575503
align: "colon"
576504
}],
577-
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }
505+
parserOptions: { ecmaVersion: 2018 }
578506
},
579507

580508
// https://github.com/eslint/eslint/issues/5613
@@ -1359,43 +1287,6 @@ ruleTester.run("key-spacing", rule, {
13591287

13601288
// https://github.com/eslint/eslint/issues/4763
13611289
{
1362-
code: [
1363-
"({",
1364-
" ...x,",
1365-
" a : 0,",
1366-
" // same group",
1367-
" bcd: 0, /*",
1368-
" end of group */",
1369-
"",
1370-
" // different group",
1371-
" e: 0,",
1372-
" ...y,",
1373-
" /* group b */",
1374-
" f : 0",
1375-
"})"
1376-
].join("\n"),
1377-
output: [
1378-
"({",
1379-
" ...x,",
1380-
" a : 0,",
1381-
" // same group",
1382-
" bcd: 0, /*",
1383-
" end of group */",
1384-
"",
1385-
" // different group",
1386-
" e: 0,",
1387-
" ...y,",
1388-
" /* group b */",
1389-
" f: 0",
1390-
"})"
1391-
].join("\n"),
1392-
options: [{ align: "colon" }],
1393-
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } },
1394-
errors: [
1395-
{ message: "Missing space after key 'a'.", line: 3, column: 5, type: "Identifier" },
1396-
{ message: "Extra space after key 'f'.", line: 12, column: 5, type: "Identifier" }
1397-
]
1398-
}, {
13991290
code: [
14001291
"({",
14011292
" ...x,",
@@ -1642,15 +1533,6 @@ ruleTester.run("key-spacing", rule, {
16421533

16431534
// https://github.com/eslint/eslint/issues/5724
16441535
{
1645-
code: "({ a:b, ...object, c : d })",
1646-
output: "({ a: b, ...object, c: d })",
1647-
options: [{ align: "colon" }],
1648-
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } },
1649-
errors: [
1650-
{ message: "Missing space before value for key 'a'.", line: 1, column: 6, type: "Identifier" },
1651-
{ message: "Extra space after key 'c'.", line: 1, column: 20, type: "Identifier" }
1652-
]
1653-
}, {
16541536
code: "({ a:b, ...object, c : d })",
16551537
output: "({ a: b, ...object, c: d })",
16561538
options: [{ align: "colon" }],

tests/lib/rules/no-dupe-keys.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ ruleTester.run("no-dupe-keys", rule, {
2424
"var x = { foo: 1, bar: 2 };",
2525
"+{ get a() { }, set a(b) { } };",
2626
{ code: "var x = { a: b, [a]: b };", parserOptions: { ecmaVersion: 6 } },
27-
{ code: "var x = { a: b, ...c }", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } },
2827
{ code: "var x = { a: b, ...c }", parserOptions: { ecmaVersion: 2018 } },
2928
{ code: "var x = { get a() {}, set a (value) {} };", parserOptions: { ecmaVersion: 6 } },
3029
{ code: "var x = { a: 1, b: { a: 2 } };", parserOptions: { ecmaVersion: 6 } },

tests/lib/rules/no-extra-parens.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,13 @@ ruleTester.run("no-extra-parens", rule, {
408408
"let a = { ...b }",
409409
{
410410
code: "let a = { ...b }",
411-
parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }
411+
parserOptions: { ecmaVersion: 2018 }
412412
},
413413
"let a = [ ...(b, c) ]",
414414
"let a = { ...(b, c) }",
415415
{
416416
code: "let a = { ...(b, c) }",
417-
parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }
417+
parserOptions: { ecmaVersion: 2018 }
418418
},
419419
"var [x = (1, foo)] = bar",
420420
"class A extends B {}",
@@ -964,7 +964,7 @@ ruleTester.run("no-extra-parens", rule, {
964964
"let a = {...b}",
965965
"Identifier",
966966
1,
967-
{ parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }
967+
{ parserOptions: { ecmaVersion: 2018 } }
968968
),
969969
invalid(
970970
"let a = [...((b, c))]",
@@ -983,7 +983,7 @@ ruleTester.run("no-extra-parens", rule, {
983983
"let a = {...(b, c)}",
984984
"SequenceExpression",
985985
1,
986-
{ parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }
986+
{ parserOptions: { ecmaVersion: 2018 } }
987987
),
988988
invalid(
989989
"class A extends (B) {}",

tests/lib/rules/no-self-assign.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ ruleTester.run("no-self-assign", rule, {
3939
{ code: "({a} = {a: b})", parserOptions: { ecmaVersion: 6 } },
4040
{ code: "({a} = {a() {}})", parserOptions: { ecmaVersion: 6 } },
4141
{ code: "({a} = {[a]: a})", parserOptions: { ecmaVersion: 6 } },
42-
{ code: "({a, ...b} = {a, ...b})", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } },
4342
{ code: "({a, ...b} = {a, ...b})", parserOptions: { ecmaVersion: 2018 } },
4443
{ code: "a.b = a.c", options: [{ props: true }] },
4544
{ code: "a.b = c.b", options: [{ props: true }] },
@@ -68,7 +67,6 @@ ruleTester.run("no-self-assign", rule, {
6867
{ code: "({a, b} = {b, a})", parserOptions: { ecmaVersion: 6 }, errors: ["'b' is assigned to itself.", "'a' is assigned to itself."] },
6968
{ code: "({a, b} = {c, a})", parserOptions: { ecmaVersion: 6 }, errors: ["'a' is assigned to itself."] },
7069
{ code: "({a: {b}, c: [d]} = {a: {b}, c: [d]})", parserOptions: { ecmaVersion: 6 }, errors: ["'b' is assigned to itself.", "'d' is assigned to itself."] },
71-
{ code: "({a, b} = {a, ...x, b})", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }, errors: ["'b' is assigned to itself."] },
7270
{ code: "({a, b} = {a, ...x, b})", parserOptions: { ecmaVersion: 2018 }, errors: ["'b' is assigned to itself."] },
7371
{ code: "a.b = a.b", options: [{ props: true }], errors: ["'a.b' is assigned to itself."] },
7472
{ code: "a.b.c = a.b.c", options: [{ props: true }], errors: ["'a.b.c' is assigned to itself."] },

tests/lib/rules/no-undef.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,6 @@ ruleTester.run("no-undef", rule, {
7272
{ code: "class A { constructor() { new.target; } }", parserOptions: { ecmaVersion: 6 } },
7373

7474
// Experimental,
75-
{
76-
code: "var {bacon, ...others} = stuff; foo(others)",
77-
parserOptions: {
78-
ecmaVersion: 6,
79-
ecmaFeatures: {
80-
experimentalObjectRestSpread: true
81-
}
82-
},
83-
globals: { stuff: false, foo: false }
84-
},
8575
{
8676
code: "var {bacon, ...others} = stuff; foo(others)",
8777
parserOptions: {
@@ -105,16 +95,6 @@ ruleTester.run("no-undef", rule, {
10595
{ code: "[obj.a, obj.b] = [0, 1];", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'obj' is not defined." }, { message: "'obj' is not defined." }] },
10696

10797
// Experimental
108-
{
109-
code: "const c = 0; const a = {...b, c};",
110-
parserOptions: {
111-
ecmaVersion: 6,
112-
ecmaFeatures: {
113-
experimentalObjectRestSpread: true
114-
}
115-
},
116-
errors: [{ message: "'b' is not defined." }]
117-
},
11898
{
11999
code: "const c = 0; const a = {...b, c};",
120100
parserOptions: {

0 commit comments

Comments
 (0)