Skip to content

Commit

Permalink
Breaking: Upgrade to Espree v4 alpha (refs #9990) (#10152)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
btmills committed Mar 30, 2018
1 parent 3351129 commit f4b3af5
Show file tree
Hide file tree
Showing 19 changed files with 13 additions and 681 deletions.
7 changes: 2 additions & 5 deletions docs/rules/rest-spread-spacing.md
Expand Up @@ -41,15 +41,12 @@ As with other operators, whitespace is allowed between the rest or spread operat

## Rule Details

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:
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:

```json
{
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
"ecmaVersion": 2018
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion lib/config/config-initializer.js
Expand Up @@ -270,7 +270,7 @@ function processAnswers(answers) {
config.parserOptions.ecmaFeatures.jsx = true;
if (answers.react) {
config.plugins = ["react"];
config.parserOptions.ecmaFeatures.experimentalObjectRestSpread = true;
config.parserOptions.ecmaVersion = 2018;
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -43,7 +43,7 @@
"doctrine": "^2.1.0",
"eslint-scope": "^3.7.1",
"eslint-visitor-keys": "^1.0.0",
"espree": "^3.5.4",
"espree": "^4.0.0-alpha.0",
"esquery": "^1.0.0",
"esutils": "^2.0.2",
"file-entry-cache": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/config/config-initializer.js
Expand Up @@ -170,7 +170,7 @@ describe("configInitializer", () => {
const config = init.processAnswers(answers);

assert.strictEqual(config.parserOptions.ecmaFeatures.jsx, true);
assert.strictEqual(config.parserOptions.ecmaFeatures.experimentalObjectRestSpread, true);
assert.strictEqual(config.parserOptions.ecmaVersion, 2018);
assert.deepStrictEqual(config.plugins, ["react"]);
});

Expand Down
7 changes: 2 additions & 5 deletions tests/lib/linter.js
Expand Up @@ -3255,14 +3255,11 @@ describe("Linter", () => {
});
});

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

const messages = linter.verify("var x = { ...y };", {
parserOptions: {
ecmaVersion: 6,
ecmaFeatures: {
experimentalObjectRestSpread: true
}
ecmaVersion: 2018
}
}, filename);

Expand Down
5 changes: 0 additions & 5 deletions tests/lib/rules/comma-dangle.js
Expand Up @@ -129,11 +129,6 @@ ruleTester.run("comma-dangle", rule, {
},

// https://github.com/eslint/eslint/issues/7297
{
code: "var {foo, ...bar} = baz",
options: ["always"],
parserOptions: { ecmaVersion: 8, ecmaFeatures: { experimentalObjectRestSpread: true } }
},
{
code: "var {foo, ...bar} = baz",
options: ["always"],
Expand Down
120 changes: 1 addition & 119 deletions tests/lib/rules/key-spacing.js
Expand Up @@ -312,78 +312,6 @@ ruleTester.run("key-spacing", rule, {

// https://github.com/eslint/eslint/issues/4763
{
code: "({a : foo, ...x, b : bar})['a'];",
options: [{
beforeColon: true,
afterColon: true
}],
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }
}, {
code: [
"var obj = {",
" 'a' : (42 - 12),",
" ...x,",
" foobar : 'value',",
" [(expr)]: val",
"};"
].join("\n"),
options: [{
align: "colon"
}],
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }
}, {
code: [
"callExpr(arg, {",
" key :val,",
" ...x,",
" ...y,",
" 'another' :false,",
" [compute] :'value'",
"});"
].join("\n"),
options: [{
align: "colon",
beforeColon: true,
afterColon: false
}],
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }
}, {
code: [
"var obj = {",
" a: (42 - 12),",
" ...x,",
" 'foobar': 'value',",
" bat: function() {",
" return this.a;",
" },",
" baz: 42",
"};"
].join("\n"),
options: [{
align: "value"
}],
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }
}, {
code: [
"({",
" ...x,",
" a : 0,",
" // same group",
" bcd: 0, /*",
" end of group */",
"",
" // different group",
" e: 0,",
" ...y,",
" /* group b */",
" f: 0",
"})"
].join("\n"),
options: [{
align: "colon"
}],
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }
}, {
code: "({a : foo, ...x, b : bar})['a'];",
options: [{
beforeColon: true,
Expand Down Expand Up @@ -574,7 +502,7 @@ ruleTester.run("key-spacing", rule, {
options: [{
align: "colon"
}],
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }
parserOptions: { ecmaVersion: 2018 }
},

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

// https://github.com/eslint/eslint/issues/4763
{
code: [
"({",
" ...x,",
" a : 0,",
" // same group",
" bcd: 0, /*",
" end of group */",
"",
" // different group",
" e: 0,",
" ...y,",
" /* group b */",
" f : 0",
"})"
].join("\n"),
output: [
"({",
" ...x,",
" a : 0,",
" // same group",
" bcd: 0, /*",
" end of group */",
"",
" // different group",
" e: 0,",
" ...y,",
" /* group b */",
" f: 0",
"})"
].join("\n"),
options: [{ align: "colon" }],
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } },
errors: [
{ message: "Missing space after key 'a'.", line: 3, column: 5, type: "Identifier" },
{ message: "Extra space after key 'f'.", line: 12, column: 5, type: "Identifier" }
]
}, {
code: [
"({",
" ...x,",
Expand Down Expand Up @@ -1642,15 +1533,6 @@ ruleTester.run("key-spacing", rule, {

// https://github.com/eslint/eslint/issues/5724
{
code: "({ a:b, ...object, c : d })",
output: "({ a: b, ...object, c: d })",
options: [{ align: "colon" }],
parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } },
errors: [
{ message: "Missing space before value for key 'a'.", line: 1, column: 6, type: "Identifier" },
{ message: "Extra space after key 'c'.", line: 1, column: 20, type: "Identifier" }
]
}, {
code: "({ a:b, ...object, c : d })",
output: "({ a: b, ...object, c: d })",
options: [{ align: "colon" }],
Expand Down
1 change: 0 additions & 1 deletion tests/lib/rules/no-dupe-keys.js
Expand Up @@ -24,7 +24,6 @@ ruleTester.run("no-dupe-keys", rule, {
"var x = { foo: 1, bar: 2 };",
"+{ get a() { }, set a(b) { } };",
{ code: "var x = { a: b, [a]: b };", parserOptions: { ecmaVersion: 6 } },
{ code: "var x = { a: b, ...c }", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } },
{ code: "var x = { a: b, ...c }", parserOptions: { ecmaVersion: 2018 } },
{ code: "var x = { get a() {}, set a (value) {} };", parserOptions: { ecmaVersion: 6 } },
{ code: "var x = { a: 1, b: { a: 2 } };", parserOptions: { ecmaVersion: 6 } },
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/rules/no-extra-parens.js
Expand Up @@ -408,13 +408,13 @@ ruleTester.run("no-extra-parens", rule, {
"let a = { ...b }",
{
code: "let a = { ...b }",
parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }
parserOptions: { ecmaVersion: 2018 }
},
"let a = [ ...(b, c) ]",
"let a = { ...(b, c) }",
{
code: "let a = { ...(b, c) }",
parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }
parserOptions: { ecmaVersion: 2018 }
},
"var [x = (1, foo)] = bar",
"class A extends B {}",
Expand Down Expand Up @@ -964,7 +964,7 @@ ruleTester.run("no-extra-parens", rule, {
"let a = {...b}",
"Identifier",
1,
{ parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }
{ parserOptions: { ecmaVersion: 2018 } }
),
invalid(
"let a = [...((b, c))]",
Expand All @@ -983,7 +983,7 @@ ruleTester.run("no-extra-parens", rule, {
"let a = {...(b, c)}",
"SequenceExpression",
1,
{ parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }
{ parserOptions: { ecmaVersion: 2018 } }
),
invalid(
"class A extends (B) {}",
Expand Down
2 changes: 0 additions & 2 deletions tests/lib/rules/no-self-assign.js
Expand Up @@ -39,7 +39,6 @@ ruleTester.run("no-self-assign", rule, {
{ code: "({a} = {a: b})", parserOptions: { ecmaVersion: 6 } },
{ code: "({a} = {a() {}})", parserOptions: { ecmaVersion: 6 } },
{ code: "({a} = {[a]: a})", parserOptions: { ecmaVersion: 6 } },
{ code: "({a, ...b} = {a, ...b})", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } },
{ code: "({a, ...b} = {a, ...b})", parserOptions: { ecmaVersion: 2018 } },
{ code: "a.b = a.c", options: [{ props: true }] },
{ code: "a.b = c.b", options: [{ props: true }] },
Expand Down Expand Up @@ -68,7 +67,6 @@ ruleTester.run("no-self-assign", rule, {
{ code: "({a, b} = {b, a})", parserOptions: { ecmaVersion: 6 }, errors: ["'b' is assigned to itself.", "'a' is assigned to itself."] },
{ code: "({a, b} = {c, a})", parserOptions: { ecmaVersion: 6 }, errors: ["'a' is assigned to itself."] },
{ code: "({a: {b}, c: [d]} = {a: {b}, c: [d]})", parserOptions: { ecmaVersion: 6 }, errors: ["'b' is assigned to itself.", "'d' is assigned to itself."] },
{ code: "({a, b} = {a, ...x, b})", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }, errors: ["'b' is assigned to itself."] },
{ code: "({a, b} = {a, ...x, b})", parserOptions: { ecmaVersion: 2018 }, errors: ["'b' is assigned to itself."] },
{ code: "a.b = a.b", options: [{ props: true }], errors: ["'a.b' is assigned to itself."] },
{ code: "a.b.c = a.b.c", options: [{ props: true }], errors: ["'a.b.c' is assigned to itself."] },
Expand Down
20 changes: 0 additions & 20 deletions tests/lib/rules/no-undef.js
Expand Up @@ -72,16 +72,6 @@ ruleTester.run("no-undef", rule, {
{ code: "class A { constructor() { new.target; } }", parserOptions: { ecmaVersion: 6 } },

// Experimental,
{
code: "var {bacon, ...others} = stuff; foo(others)",
parserOptions: {
ecmaVersion: 6,
ecmaFeatures: {
experimentalObjectRestSpread: true
}
},
globals: { stuff: false, foo: false }
},
{
code: "var {bacon, ...others} = stuff; foo(others)",
parserOptions: {
Expand All @@ -105,16 +95,6 @@ ruleTester.run("no-undef", rule, {
{ code: "[obj.a, obj.b] = [0, 1];", parserOptions: { ecmaVersion: 6 }, errors: [{ message: "'obj' is not defined." }, { message: "'obj' is not defined." }] },

// Experimental
{
code: "const c = 0; const a = {...b, c};",
parserOptions: {
ecmaVersion: 6,
ecmaFeatures: {
experimentalObjectRestSpread: true
}
},
errors: [{ message: "'b' is not defined." }]
},
{
code: "const c = 0; const a = {...b, c};",
parserOptions: {
Expand Down

0 comments on commit f4b3af5

Please sign in to comment.