Skip to content
Permalink
Browse files

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.
  • Loading branch information...
btmills committed Mar 30, 2018
1 parent 3351129 commit f4b3af586d82768d3caf1ace77c5c42557a8e4a9
@@ -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
}
}
```
@@ -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;
}
}

@@ -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",
@@ -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"]);
});

@@ -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);

@@ -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"],
@@ -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,
@@ -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
@@ -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,",
@@ -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" }],
@@ -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 } },
@@ -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 {}",
@@ -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))]",
@@ -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) {}",
@@ -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 }] },
@@ -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."] },
@@ -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: {
@@ -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: {
Oops, something went wrong.

0 comments on commit f4b3af5

Please sign in to comment.
You can’t perform that action at this time.