diff --git a/docs/rules/rest-spread-spacing.md b/docs/rules/rest-spread-spacing.md index 27cc626c1b7..d8d6063b94d 100644 --- a/docs/rules/rest-spread-spacing.md +++ b/docs/rules/rest-spread-spacing.md @@ -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 } } ``` diff --git a/lib/config/config-initializer.js b/lib/config/config-initializer.js index e4865a008ca..3e99be9ec57 100644 --- a/lib/config/config-initializer.js +++ b/lib/config/config-initializer.js @@ -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; } } diff --git a/package.json b/package.json index 6bb7690c95d..e381ef2fe6a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tests/lib/config/config-initializer.js b/tests/lib/config/config-initializer.js index 47f180fb15e..e1a24dc36ee 100644 --- a/tests/lib/config/config-initializer.js +++ b/tests/lib/config/config-initializer.js @@ -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"]); }); diff --git a/tests/lib/linter.js b/tests/lib/linter.js index 80301cbc823..a64a6a55ee6 100644 --- a/tests/lib/linter.js +++ b/tests/lib/linter.js @@ -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); diff --git a/tests/lib/rules/comma-dangle.js b/tests/lib/rules/comma-dangle.js index 0a8403ebcfb..7cd95823157 100644 --- a/tests/lib/rules/comma-dangle.js +++ b/tests/lib/rules/comma-dangle.js @@ -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"], diff --git a/tests/lib/rules/key-spacing.js b/tests/lib/rules/key-spacing.js index 183c91eb09f..2ed67e08e9f 100644 --- a/tests/lib/rules/key-spacing.js +++ b/tests/lib/rules/key-spacing.js @@ -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" }], diff --git a/tests/lib/rules/no-dupe-keys.js b/tests/lib/rules/no-dupe-keys.js index aeccfb4ced7..76a6c7ec1b5 100644 --- a/tests/lib/rules/no-dupe-keys.js +++ b/tests/lib/rules/no-dupe-keys.js @@ -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 } }, diff --git a/tests/lib/rules/no-extra-parens.js b/tests/lib/rules/no-extra-parens.js index 10d30ce2c03..1738b1a6660 100644 --- a/tests/lib/rules/no-extra-parens.js +++ b/tests/lib/rules/no-extra-parens.js @@ -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) {}", diff --git a/tests/lib/rules/no-self-assign.js b/tests/lib/rules/no-self-assign.js index 553ac460265..6623f4c9d7e 100644 --- a/tests/lib/rules/no-self-assign.js +++ b/tests/lib/rules/no-self-assign.js @@ -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."] }, diff --git a/tests/lib/rules/no-undef.js b/tests/lib/rules/no-undef.js index bf7e775a6af..2372b87d519 100644 --- a/tests/lib/rules/no-undef.js +++ b/tests/lib/rules/no-undef.js @@ -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: { diff --git a/tests/lib/rules/no-unused-vars.js b/tests/lib/rules/no-unused-vars.js index 5fd39ede774..3f529aa3956 100644 --- a/tests/lib/rules/no-unused-vars.js +++ b/tests/lib/rules/no-unused-vars.js @@ -180,11 +180,6 @@ ruleTester.run("no-unused-vars", rule, { }, // Using object rest for variable omission - { - code: "const data = { type: 'coords', x: 1, y: 2 };\nconst { type, ...coords } = data;\n console.log(coords);", - options: [{ ignoreRestSiblings: true }], - parserOptions: { ecmaVersion: 2015, ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "const data = { type: 'coords', x: 1, y: 2 };\nconst { type, ...coords } = data;\n console.log(coords);", options: [{ ignoreRestSiblings: true }], @@ -272,11 +267,6 @@ ruleTester.run("no-unused-vars", rule, { }, // https://github.com/eslint/eslint/issues/8119 - { - code: "(({a, ...rest}) => rest)", - options: [{ args: "all", ignoreRestSiblings: true }], - parserOptions: { ecmaVersion: 2015, ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "(({a, ...rest}) => rest)", options: [{ args: "all", ignoreRestSiblings: true }], @@ -376,13 +366,6 @@ ruleTester.run("no-unused-vars", rule, { }, // Rest property sibling without ignoreRestSiblings - { - code: "const data = { type: 'coords', x: 1, y: 2 };\nconst { type, ...coords } = data;\n console.log(coords);", - parserOptions: { ecmaVersion: 2015, ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [ - { line: 2, column: 9, message: "'type' is assigned a value but never used." } - ] - }, { code: "const data = { type: 'coords', x: 1, y: 2 };\nconst { type, ...coords } = data;\n console.log(coords);", parserOptions: { ecmaVersion: 2018 }, @@ -392,14 +375,6 @@ ruleTester.run("no-unused-vars", rule, { }, // Unused rest property with ignoreRestSiblings - { - code: "const data = { type: 'coords', x: 1, y: 2 };\nconst { type, ...coords } = data;\n console.log(type)", - options: [{ ignoreRestSiblings: true }], - parserOptions: { ecmaVersion: 2015, ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [ - { line: 2, column: 18, message: "'coords' is assigned a value but never used." } - ] - }, { code: "const data = { type: 'coords', x: 1, y: 2 };\nconst { type, ...coords } = data;\n console.log(type)", options: [{ ignoreRestSiblings: true }], @@ -410,13 +385,6 @@ ruleTester.run("no-unused-vars", rule, { }, // Unused rest property without ignoreRestSiblings - { - code: "const data = { type: 'coords', x: 1, y: 2 };\nconst { type, ...coords } = data;\n console.log(type)", - parserOptions: { ecmaVersion: 2015, ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [ - { line: 2, column: 18, message: "'coords' is assigned a value but never used." } - ] - }, { code: "const data = { type: 'coords', x: 1, y: 2 };\nconst { type, ...coords } = data;\n console.log(type)", parserOptions: { ecmaVersion: 2018 }, @@ -426,13 +394,6 @@ ruleTester.run("no-unused-vars", rule, { }, // Nested array destructuring with rest property - { - code: "const data = { vars: ['x','y'], x: 1, y: 2 };\nconst { vars: [x], ...coords } = data;\n console.log(coords)", - parserOptions: { ecmaVersion: 2015, ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [ - { line: 2, column: 16, message: "'x' is assigned a value but never used." } - ] - }, { code: "const data = { vars: ['x','y'], x: 1, y: 2 };\nconst { vars: [x], ...coords } = data;\n console.log(coords)", parserOptions: { ecmaVersion: 2018 }, @@ -444,19 +405,13 @@ ruleTester.run("no-unused-vars", rule, { // Nested object destructuring with rest property { code: "const data = { defaults: { x: 0 }, x: 1, y: 2 };\nconst { defaults: { x }, ...coords } = data;\n console.log(coords)", - parserOptions: { ecmaVersion: 2015, ecmaFeatures: { experimentalObjectRestSpread: true } }, + parserOptions: { ecmaVersion: 2018 }, errors: [ { line: 2, column: 21, message: "'x' is assigned a value but never used." } ] }, // https://github.com/eslint/eslint/issues/8119 - { - code: "(({a, ...rest}) => {})", - options: [{ args: "all", ignoreRestSiblings: true }], - parserOptions: { ecmaVersion: 2015, ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: ["'rest' is defined but never used."] - }, { code: "(({a, ...rest}) => {})", options: [{ args: "all", ignoreRestSiblings: true }], diff --git a/tests/lib/rules/no-useless-rename.js b/tests/lib/rules/no-useless-rename.js index 325ab3cef77..2a864c06bd3 100644 --- a/tests/lib/rules/no-useless-rename.js +++ b/tests/lib/rules/no-useless-rename.js @@ -48,26 +48,14 @@ ruleTester.run("no-useless-rename", rule, { "export {foo as bar, baz as qux};", "export {foo as bar} from 'foo';", "export {foo as bar, baz as qux} from 'foo';", - { - code: "const {...stuff} = myObject;", - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "const {...stuff} = myObject;", parserOptions: { ecmaVersion: 2018 } }, - { - code: "const {foo, ...stuff} = myObject;", - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "const {foo, ...stuff} = myObject;", parserOptions: { ecmaVersion: 2018 } }, - { - code: "const {foo: bar, ...stuff} = myObject;", - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "const {foo: bar, ...stuff} = myObject;", parserOptions: { ecmaVersion: 2018 } @@ -234,36 +222,18 @@ ruleTester.run("no-useless-rename", rule, { output: "({foo, bar}) => {}", errors: ["Destructuring assignment foo unnecessarily renamed.", "Destructuring assignment bar unnecessarily renamed."] }, - { - code: "const {foo: foo, ...stuff} = myObject;", - output: "const {foo, ...stuff} = myObject;", - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: ["Destructuring assignment foo unnecessarily renamed."] - }, { code: "const {foo: foo, ...stuff} = myObject;", output: "const {foo, ...stuff} = myObject;", parserOptions: { ecmaVersion: 2018 }, errors: ["Destructuring assignment foo unnecessarily renamed."] }, - { - code: "const {foo: foo, bar: baz, ...stuff} = myObject;", - output: "const {foo, bar: baz, ...stuff} = myObject;", - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: ["Destructuring assignment foo unnecessarily renamed."] - }, { code: "const {foo: foo, bar: baz, ...stuff} = myObject;", output: "const {foo, bar: baz, ...stuff} = myObject;", parserOptions: { ecmaVersion: 2018 }, errors: ["Destructuring assignment foo unnecessarily renamed."] }, - { - code: "const {foo: foo, bar: bar, ...stuff} = myObject;", - output: "const {foo, bar, ...stuff} = myObject;", - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: ["Destructuring assignment foo unnecessarily renamed.", "Destructuring assignment bar unnecessarily renamed."] - }, { code: "const {foo: foo, bar: bar, ...stuff} = myObject;", output: "const {foo, bar, ...stuff} = myObject;", diff --git a/tests/lib/rules/object-property-newline.js b/tests/lib/rules/object-property-newline.js index 6a6a2616c91..28cc282ac82 100644 --- a/tests/lib/rules/object-property-newline.js +++ b/tests/lib/rules/object-property-newline.js @@ -31,11 +31,8 @@ ruleTester.run("object-property-newline", rule, { "var obj = {\nk1: 'val1'\n};", "var obj = {};", { code: "var obj = {\n[bar]: 'baz',\nbaz\n};", parserOptions: { ecmaVersion: 6 } }, - { code: "var obj = {\nk1: 'val1',\nk2: 'val2',\n...{}\n};", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "var obj = {\nk1: 'val1',\nk2: 'val2',\n...{}\n};", parserOptions: { ecmaVersion: 2018 } }, - { code: "var obj = { k1: 'val1',\nk2: 'val2',\n...{} };", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "var obj = { k1: 'val1',\nk2: 'val2',\n...{} };", parserOptions: { ecmaVersion: 2018 } }, - { code: "var obj = { ...{} };", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "var obj = { ...{} };", parserOptions: { ecmaVersion: 2018 } }, "foo({ k1: 'val1',\nk2: 'val2' });", "foo({\nk1: 'val1',\nk2: 'val2'\n});", @@ -43,11 +40,8 @@ ruleTester.run("object-property-newline", rule, { { code: "foo({\na,\nb,\n});", parserOptions: { ecmaVersion: 6 } }, { code: "foo({\nbar() {},\nbaz\n});", parserOptions: { ecmaVersion: 6 } }, { code: "foo({\n[bar]: 'baz',\nbaz \n})", parserOptions: { ecmaVersion: 6 } }, - { code: "foo({\nk1: 'val1',\nk2: 'val2',\n...{}\n});", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "foo({\nk1: 'val1',\nk2: 'val2',\n...{}\n});", parserOptions: { ecmaVersion: 2018 } }, - { code: "foo({ k1: 'val1',\nk2: 'val2',\n...{} });", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "foo({ k1: 'val1',\nk2: 'val2',\n...{} });", parserOptions: { ecmaVersion: 2018 } }, - { code: "foo({ ...{} });", parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "foo({ ...{} });", parserOptions: { ecmaVersion: 2018 } }, // allowAllPropertiesOnSameLine: true @@ -56,18 +50,14 @@ ruleTester.run("object-property-newline", rule, { { code: "var obj = { k1: 'val1' };", options: [{ allowAllPropertiesOnSameLine: true }] }, { code: "var obj = {\nk1: 'val1'\n};", options: [{ allowAllPropertiesOnSameLine: true }] }, { code: "var obj = {};", options: [{ allowAllPropertiesOnSameLine: true }] }, - { code: "var obj = { 'k1': 'val1', k2: 'val2', ...{} };", options: [{ allowAllPropertiesOnSameLine: true }], parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "var obj = { 'k1': 'val1', k2: 'val2', ...{} };", options: [{ allowAllPropertiesOnSameLine: true }], parserOptions: { ecmaVersion: 2018 } }, - { code: "var obj = {\n'k1': 'val1', k2: 'val2', ...{}\n};", options: [{ allowAllPropertiesOnSameLine: true }], parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "var obj = {\n'k1': 'val1', k2: 'val2', ...{}\n};", options: [{ allowAllPropertiesOnSameLine: true }], parserOptions: { ecmaVersion: 2018 } }, { code: "foo({ k1: 'val1', k2: 'val2' });", options: [{ allowAllPropertiesOnSameLine: true }] }, { code: "foo({\nk1: 'val1', k2: 'val2'\n});", options: [{ allowAllPropertiesOnSameLine: true }] }, { code: "foo({ a, b });", options: [{ allowAllPropertiesOnSameLine: true }], parserOptions: { ecmaVersion: 6 } }, { code: "foo({ bar() {}, baz });", options: [{ allowAllPropertiesOnSameLine: true }], parserOptions: { ecmaVersion: 6 } }, { code: "foo({ [bar]: 'baz', baz })", options: [{ allowAllPropertiesOnSameLine: true }], parserOptions: { ecmaVersion: 6 } }, - { code: "foo({ 'k1': 'val1', k2: 'val2', ...{} });", options: [{ allowAllPropertiesOnSameLine: true }], parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "foo({ 'k1': 'val1', k2: 'val2', ...{} });", options: [{ allowAllPropertiesOnSameLine: true }], parserOptions: { ecmaVersion: 2018 } }, - { code: "foo({\n'k1': 'val1', k2: 'val2', ...{}\n});", options: [{ allowAllPropertiesOnSameLine: true }], parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "foo({\n'k1': 'val1', k2: 'val2', ...{}\n});", options: [{ allowAllPropertiesOnSameLine: true }], parserOptions: { ecmaVersion: 2018 } }, { code: "var obj = {k1: ['foo', 'bar'], k2: 'val1', k3: 'val2'};", options: [{ allowAllPropertiesOnSameLine: true }] }, { code: "var obj = {\nk1: ['foo', 'bar'], k2: 'val1', k3: 'val2'\n};", options: [{ allowAllPropertiesOnSameLine: true }] }, @@ -213,19 +203,6 @@ ruleTester.run("object-property-newline", rule, { } ] }, - { - code: "var obj = { k1: 'val1', ...{} };", - output: "var obj = { k1: 'val1',\n...{} };", - parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [ - { - message: "Object properties must go on a new line.", - type: "ObjectExpression", - line: 1, - column: 25 - } - ] - }, { code: "var obj = { k1: 'val1', ...{} };", output: "var obj = { k1: 'val1',\n...{} };", @@ -239,19 +216,6 @@ ruleTester.run("object-property-newline", rule, { } ] }, - { - code: "var obj = {\nk1: 'val1', ...{}\n};", - output: "var obj = {\nk1: 'val1',\n...{}\n};", - parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [ - { - message: "Object properties must go on a new line.", - type: "ObjectExpression", - line: 2, - column: 13 - } - ] - }, { code: "var obj = {\nk1: 'val1', ...{}\n};", output: "var obj = {\nk1: 'val1',\n...{}\n};", @@ -354,19 +318,6 @@ ruleTester.run("object-property-newline", rule, { } ] }, - { - code: "foo({ k1: 'val1', ...{} })", - output: "foo({ k1: 'val1',\n...{} })", - parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [ - { - message: "Object properties must go on a new line.", - type: "ObjectExpression", - line: 1, - column: 19 - } - ] - }, { code: "foo({ k1: 'val1', ...{} })", output: "foo({ k1: 'val1',\n...{} })", @@ -380,19 +331,6 @@ ruleTester.run("object-property-newline", rule, { } ] }, - { - code: "foo({\nk1: 'val1', ...{}\n})", - output: "foo({\nk1: 'val1',\n...{}\n})", - parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [ - { - message: "Object properties must go on a new line.", - type: "ObjectExpression", - line: 2, - column: 13 - } - ] - }, { code: "foo({\nk1: 'val1', ...{}\n})", output: "foo({\nk1: 'val1',\n...{}\n})", @@ -548,20 +486,6 @@ ruleTester.run("object-property-newline", rule, { } ] }, - { - code: "var obj = {\nk1: 'val1',\nk2: 'val2', ...{}\n};", - output: "var obj = {\nk1: 'val1',\nk2: 'val2',\n...{}\n};", - options: [{ allowAllPropertiesOnSameLine: true }], - parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [ - { - message: "Object properties must go on a new line if they aren't all on the same line.", - type: "ObjectExpression", - line: 3, - column: 13 - } - ] - }, { code: "var obj = {\nk1: 'val1',\nk2: 'val2', ...{}\n};", output: "var obj = {\nk1: 'val1',\nk2: 'val2',\n...{}\n};", @@ -576,20 +500,6 @@ ruleTester.run("object-property-newline", rule, { } ] }, - { - code: "var obj = {\n...{},\nk1: 'val1', k2: 'val2'\n};", - output: "var obj = {\n...{},\nk1: 'val1',\nk2: 'val2'\n};", - options: [{ allowAllPropertiesOnSameLine: true }], - parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [ - { - message: "Object properties must go on a new line if they aren't all on the same line.", - type: "ObjectExpression", - line: 3, - column: 13 - } - ] - }, { code: "var obj = {\n...{},\nk1: 'val1', k2: 'val2'\n};", output: "var obj = {\n...{},\nk1: 'val1',\nk2: 'val2'\n};", @@ -618,20 +528,6 @@ ruleTester.run("object-property-newline", rule, { } ] }, - { - code: "foo({\nk1: 'val1',\nk2: 'val2', ...{}\n})", - output: "foo({\nk1: 'val1',\nk2: 'val2',\n...{}\n})", - options: [{ allowAllPropertiesOnSameLine: true }], - parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [ - { - message: "Object properties must go on a new line if they aren't all on the same line.", - type: "ObjectExpression", - line: 3, - column: 13 - } - ] - }, { code: "foo({\nk1: 'val1',\nk2: 'val2', ...{}\n})", output: "foo({\nk1: 'val1',\nk2: 'val2',\n...{}\n})", @@ -646,20 +542,6 @@ ruleTester.run("object-property-newline", rule, { } ] }, - { - code: "foo({\n...{},\nk1: 'val1', k2: 'val2'\n})", - output: "foo({\n...{},\nk1: 'val1',\nk2: 'val2'\n})", - options: [{ allowAllPropertiesOnSameLine: true }], - parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [ - { - message: "Object properties must go on a new line if they aren't all on the same line.", - type: "ObjectExpression", - line: 3, - column: 13 - } - ] - }, { code: "foo({\n...{},\nk1: 'val1', k2: 'val2'\n})", output: "foo({\n...{},\nk1: 'val1',\nk2: 'val2'\n})", diff --git a/tests/lib/rules/object-shorthand.js b/tests/lib/rules/object-shorthand.js index e0b30b99248..31abe8faab6 100644 --- a/tests/lib/rules/object-shorthand.js +++ b/tests/lib/rules/object-shorthand.js @@ -171,11 +171,6 @@ ruleTester.run("object-shorthand", rule, { code: "let {a, b} = o;", options: ["never"] }, - { - code: "var x = {foo: foo, bar: bar, ...baz}", - options: ["never"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "var x = {foo: foo, bar: bar, ...baz}", options: ["never"], @@ -199,41 +194,21 @@ ruleTester.run("object-shorthand", rule, { code: "var x = {a, b, get test() { return 1; }}", options: ["consistent"] }, - { - code: "var x = {...bar}", - options: ["consistent-as-needed"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "var x = {...bar}", options: ["consistent-as-needed"], parserOptions: { ecmaVersion: 2018 } }, - { - code: "var x = {foo, bar, ...baz}", - options: ["consistent"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "var x = {foo, bar, ...baz}", options: ["consistent"], parserOptions: { ecmaVersion: 2018 } }, - { - code: "var x = {bar: baz, ...qux}", - options: ["consistent"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "var x = {bar: baz, ...qux}", options: ["consistent"], parserOptions: { ecmaVersion: 2018 } }, - { - code: "var x = {...foo, bar: bar, baz: baz}", - options: ["consistent"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "var x = {...foo, bar: bar, baz: baz}", options: ["consistent"], @@ -273,31 +248,16 @@ ruleTester.run("object-shorthand", rule, { code: "var x = {[foo]: 'foo'}", options: ["consistent-as-needed"] }, - { - code: "var x = {bar, ...baz}", - options: ["consistent-as-needed"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "var x = {bar, ...baz}", options: ["consistent-as-needed"], parserOptions: { ecmaVersion: 2018 } }, - { - code: "var x = {bar: baz, ...qux}", - options: ["consistent-as-needed"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "var x = {bar: baz, ...qux}", options: ["consistent-as-needed"], parserOptions: { ecmaVersion: 2018 } }, - { - code: "var x = {...foo, bar, baz}", - options: ["consistent-as-needed"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "var x = {...foo, bar, baz}", options: ["consistent-as-needed"], @@ -723,13 +683,6 @@ ruleTester.run("object-shorthand", rule, { options: ["never"], errors: [LONGFORM_METHOD_ERROR] }, - { - code: "var x = {foo: foo, bar: baz, ...qux}", - output: "var x = {foo, bar: baz, ...qux}", - options: ["always"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [PROPERTY_ERROR] - }, { code: "var x = {foo: foo, bar: baz, ...qux}", output: "var x = {foo, bar: baz, ...qux}", @@ -737,13 +690,6 @@ ruleTester.run("object-shorthand", rule, { parserOptions: { ecmaVersion: 2018 }, errors: [PROPERTY_ERROR] }, - { - code: "var x = {foo, bar: baz, ...qux}", - output: "var x = {foo: foo, bar: baz, ...qux}", - options: ["never"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [LONGFORM_PROPERTY_ERROR] - }, { code: "var x = {foo, bar: baz, ...qux}", output: "var x = {foo: foo, bar: baz, ...qux}", @@ -797,13 +743,6 @@ ruleTester.run("object-shorthand", rule, { options: ["consistent"], errors: [MIXED_SHORTHAND_ERROR] }, - { - code: "var x = {foo, bar: baz, ...qux}", - output: null, - options: ["consistent"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [MIXED_SHORTHAND_ERROR] - }, { code: "var x = {foo, bar: baz, ...qux}", output: null, @@ -832,13 +771,6 @@ ruleTester.run("object-shorthand", rule, { options: ["consistent-as-needed"], errors: [ALL_SHORTHAND_ERROR] }, - { - code: "var x = {a: a, b: b, ...baz}", - output: null, - options: ["consistent-as-needed"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [ALL_SHORTHAND_ERROR] - }, { code: "var x = {a: a, b: b, ...baz}", output: null, @@ -846,13 +778,6 @@ ruleTester.run("object-shorthand", rule, { parserOptions: { ecmaVersion: 2018 }, errors: [ALL_SHORTHAND_ERROR] }, - { - code: "var x = {foo, bar: bar, ...qux}", - output: null, - options: ["consistent-as-needed"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [MIXED_SHORTHAND_ERROR] - }, { code: "var x = {foo, bar: bar, ...qux}", output: null, diff --git a/tests/lib/rules/prefer-const.js b/tests/lib/rules/prefer-const.js index a86335c0d60..85916648f49 100644 --- a/tests/lib/rules/prefer-const.js +++ b/tests/lib/rules/prefer-const.js @@ -90,11 +90,6 @@ ruleTester.run("prefer-const", rule, { }, // https://github.com/eslint/eslint/issues/8187 - { - code: "let { name, ...otherStuff } = obj; otherStuff = {};", - options: [{ destructuring: "all" }], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } - }, { code: "let { name, ...otherStuff } = obj; otherStuff = {};", options: [{ destructuring: "all" }], @@ -309,13 +304,6 @@ ruleTester.run("prefer-const", rule, { }, // https://github.com/eslint/eslint/issues/8187 - { - code: "let { name, ...otherStuff } = obj; otherStuff = {};", - output: null, - options: [{ destructuring: "any" }], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ message: "'name' is never reassigned. Use 'const' instead.", type: "Identifier", column: 7 }] - }, { code: "let { name, ...otherStuff } = obj; otherStuff = {};", output: null, diff --git a/tests/lib/rules/quote-props.js b/tests/lib/rules/quote-props.js index 9c87da607cf..6291960d351 100644 --- a/tests/lib/rules/quote-props.js +++ b/tests/lib/rules/quote-props.js @@ -71,11 +71,8 @@ ruleTester.run("quote-props", rule, { { code: "({'1': 1})", options: ["as-needed", { numbers: true }] }, { code: "({1: 1, x: 2})", options: ["consistent", { numbers: true }] }, { code: "({1: 1, x: 2})", options: ["consistent-as-needed", { numbers: true }] }, - { code: "({ ...x })", options: ["as-needed"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "({ ...x })", options: ["as-needed"], parserOptions: { ecmaVersion: 2018 } }, - { code: "({ ...x })", options: ["consistent"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "({ ...x })", options: ["consistent"], parserOptions: { ecmaVersion: 2018 } }, - { code: "({ ...x })", options: ["consistent-as-needed"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "({ ...x })", options: ["consistent-as-needed"], parserOptions: { ecmaVersion: 2018 } } ], invalid: [{ diff --git a/tests/lib/rules/rest-spread-spacing.js b/tests/lib/rules/rest-spread-spacing.js index c7f28aa4a75..a4f93ba88c8 100644 --- a/tests/lib/rules/rest-spread-spacing.js +++ b/tests/lib/rules/rest-spread-spacing.js @@ -35,29 +35,17 @@ ruleTester.run("rest-spread-spacing", rule, { { code: "let [a, b, ... arr] = [1, 2, 3, 4, 5];", options: ["always"] }, { code: "let [a, b, ...\tarr] = [1, 2, 3, 4, 5];", options: ["always"] }, { code: "let [a, b, ...\narr] = [1, 2, 3, 4, 5];", options: ["always"] }, - { code: "let n = { x, y, ...z };", parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "let n = { x, y, ...z };", parserOptions: { ecmaVersion: 2018 } }, - { code: "let n = { x, y, ...(z) };", parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "let n = { x, y, ...(z) };", parserOptions: { ecmaVersion: 2018 } }, - { code: "let n = { x, y, ...( z ) };", parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "let n = { x, y, ...( z ) };", parserOptions: { ecmaVersion: 2018 } }, - { code: "let n = { x, y, ...z };", options: ["never"], parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "let n = { x, y, ...z };", options: ["never"], parserOptions: { ecmaVersion: 2018 } }, - { code: "let n = { x, y, ... z };", options: ["always"], parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "let n = { x, y, ... z };", options: ["always"], parserOptions: { ecmaVersion: 2018 } }, - { code: "let n = { x, y, ...\tz };", options: ["always"], parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "let n = { x, y, ...\tz };", options: ["always"], parserOptions: { ecmaVersion: 2018 } }, - { code: "let n = { x, y, ...\nz };", options: ["always"], parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "let n = { x, y, ...\nz };", options: ["always"], parserOptions: { ecmaVersion: 2018 } }, - { code: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", parserOptions: { ecmaVersion: 2018 } }, - { code: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", options: ["never"], parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", options: ["never"], parserOptions: { ecmaVersion: 2018 } }, - { code: "let { x, y, ... z } = { x: 1, y: 2, a: 3, b: 4 };", options: ["always"], parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "let { x, y, ... z } = { x: 1, y: 2, a: 3, b: 4 };", options: ["always"], parserOptions: { ecmaVersion: 2018 } }, - { code: "let { x, y, ...\tz } = { x: 1, y: 2, a: 3, b: 4 };", options: ["always"], parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "let { x, y, ...\tz } = { x: 1, y: 2, a: 3, b: 4 };", options: ["always"], parserOptions: { ecmaVersion: 2018 } }, - { code: "let { x, y, ...\nz } = { x: 1, y: 2, a: 3, b: 4 };", options: ["always"], parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "let { x, y, ...\nz } = { x: 1, y: 2, a: 3, b: 4 };", options: ["always"], parserOptions: { ecmaVersion: 2018 } } ], @@ -368,17 +356,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "RestElement" }] }, - { - code: "let n = { x, y, ... z };", - output: "let n = { x, y, ...z };", - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 20, - message: "Unexpected whitespace after spread property operator.", - type: "ExperimentalSpreadProperty" - }] - }, { code: "let n = { x, y, ... z };", output: "let n = { x, y, ...z };", @@ -390,17 +367,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "SpreadElement" }] }, - { - code: "let n = { x, y, ...\tz };", - output: "let n = { x, y, ...z };", - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 20, - message: "Unexpected whitespace after spread property operator.", - type: "ExperimentalSpreadProperty" - }] - }, { code: "let n = { x, y, ...\tz };", output: "let n = { x, y, ...z };", @@ -412,17 +378,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "SpreadElement" }] }, - { - code: "let n = { x, y, ...\nz };", - output: "let n = { x, y, ...z };", - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 20, - message: "Unexpected whitespace after spread property operator.", - type: "ExperimentalSpreadProperty" - }] - }, { code: "let n = { x, y, ...\nz };", output: "let n = { x, y, ...z };", @@ -434,18 +389,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "SpreadElement" }] }, - { - code: "let n = { x, y, ... z };", - output: "let n = { x, y, ...z };", - options: ["never"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 20, - message: "Unexpected whitespace after spread property operator.", - type: "ExperimentalSpreadProperty" - }] - }, { code: "let n = { x, y, ... z };", output: "let n = { x, y, ...z };", @@ -458,18 +401,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "SpreadElement" }] }, - { - code: "let n = { x, y, ...\tz };", - output: "let n = { x, y, ...z };", - options: ["never"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 20, - message: "Unexpected whitespace after spread property operator.", - type: "ExperimentalSpreadProperty" - }] - }, { code: "let n = { x, y, ...\tz };", output: "let n = { x, y, ...z };", @@ -482,18 +413,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "SpreadElement" }] }, - { - code: "let n = { x, y, ...\nz };", - output: "let n = { x, y, ...z };", - options: ["never"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 20, - message: "Unexpected whitespace after spread property operator.", - type: "ExperimentalSpreadProperty" - }] - }, { code: "let n = { x, y, ...\nz };", output: "let n = { x, y, ...z };", @@ -506,18 +425,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "SpreadElement" }] }, - { - code: "let n = { x, y, ...z };", - output: "let n = { x, y, ... z };", - options: ["always"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 20, - message: "Expected whitespace after spread property operator.", - type: "ExperimentalSpreadProperty" - }] - }, { code: "let n = { x, y, ...z };", output: "let n = { x, y, ... z };", @@ -530,18 +437,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "SpreadElement" }] }, - { - code: "let n = { x, y, ... (z) };", - output: "let n = { x, y, ...(z) };", - options: ["never"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 20, - message: "Unexpected whitespace after spread property operator.", - type: "ExperimentalSpreadProperty" - }] - }, { code: "let n = { x, y, ... (z) };", output: "let n = { x, y, ...(z) };", @@ -554,18 +449,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "SpreadElement" }] }, - { - code: "let n = { x, y, ... ( z ) };", - output: "let n = { x, y, ...( z ) };", - options: ["never"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 20, - message: "Unexpected whitespace after spread property operator.", - type: "ExperimentalSpreadProperty" - }] - }, { code: "let n = { x, y, ... ( z ) };", output: "let n = { x, y, ...( z ) };", @@ -578,18 +461,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "SpreadElement" }] }, - { - code: "let n = { x, y, ...(z) };", - output: "let n = { x, y, ... (z) };", - options: ["always"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 20, - message: "Expected whitespace after spread property operator.", - type: "ExperimentalSpreadProperty" - }] - }, { code: "let n = { x, y, ...(z) };", output: "let n = { x, y, ... (z) };", @@ -602,18 +473,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "SpreadElement" }] }, - { - code: "let n = { x, y, ...( z ) };", - output: "let n = { x, y, ... ( z ) };", - options: ["always"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 20, - message: "Expected whitespace after spread property operator.", - type: "ExperimentalSpreadProperty" - }] - }, { code: "let n = { x, y, ...( z ) };", output: "let n = { x, y, ... ( z ) };", @@ -626,17 +485,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "SpreadElement" }] }, - { - code: "let { x, y, ... z } = { x: 1, y: 2, a: 3, b: 4 };", - output: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 16, - message: "Unexpected whitespace after rest property operator.", - type: "ExperimentalRestProperty" - }] - }, { code: "let { x, y, ... z } = { x: 1, y: 2, a: 3, b: 4 };", output: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", @@ -648,17 +496,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "RestElement" }] }, - { - code: "let { x, y, ...\tz } = { x: 1, y: 2, a: 3, b: 4 };", - output: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 16, - message: "Unexpected whitespace after rest property operator.", - type: "ExperimentalRestProperty" - }] - }, { code: "let { x, y, ...\tz } = { x: 1, y: 2, a: 3, b: 4 };", output: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", @@ -670,17 +507,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "RestElement" }] }, - { - code: "let { x, y, ...\nz } = { x: 1, y: 2, a: 3, b: 4 };", - output: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 16, - message: "Unexpected whitespace after rest property operator.", - type: "ExperimentalRestProperty" - }] - }, { code: "let { x, y, ...\nz } = { x: 1, y: 2, a: 3, b: 4 };", output: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", @@ -692,18 +518,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "RestElement" }] }, - { - code: "let { x, y, ... z } = { x: 1, y: 2, a: 3, b: 4 };", - output: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", - options: ["never"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 16, - message: "Unexpected whitespace after rest property operator.", - type: "ExperimentalRestProperty" - }] - }, { code: "let { x, y, ... z } = { x: 1, y: 2, a: 3, b: 4 };", output: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", @@ -716,18 +530,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "RestElement" }] }, - { - code: "let { x, y, ...\tz } = { x: 1, y: 2, a: 3, b: 4 };", - output: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", - options: ["never"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 16, - message: "Unexpected whitespace after rest property operator.", - type: "ExperimentalRestProperty" - }] - }, { code: "let { x, y, ...\tz } = { x: 1, y: 2, a: 3, b: 4 };", output: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", @@ -740,18 +542,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "RestElement" }] }, - { - code: "let { x, y, ...\nz } = { x: 1, y: 2, a: 3, b: 4 };", - output: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", - options: ["never"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 16, - message: "Unexpected whitespace after rest property operator.", - type: "ExperimentalRestProperty" - }] - }, { code: "let { x, y, ...\nz } = { x: 1, y: 2, a: 3, b: 4 };", output: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", @@ -764,18 +554,6 @@ ruleTester.run("rest-spread-spacing", rule, { type: "RestElement" }] }, - { - code: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", - output: "let { x, y, ... z } = { x: 1, y: 2, a: 3, b: 4 };", - options: ["always"], - parserOptions: { ecmaFeatures: { experimentalObjectRestSpread: true } }, - errors: [{ - line: 1, - column: 16, - message: "Expected whitespace after rest property operator.", - type: "ExperimentalRestProperty" - }] - }, { code: "let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };", output: "let { x, y, ... z } = { x: 1, y: 2, a: 3, b: 4 };", diff --git a/tests/lib/rules/sort-keys.js b/tests/lib/rules/sort-keys.js index 2a94850a0f7..c7cf8ecf422 100644 --- a/tests/lib/rules/sort-keys.js +++ b/tests/lib/rules/sort-keys.js @@ -34,7 +34,6 @@ ruleTester.run("sort-keys", rule, { { code: "var obj = {a:1, b:3, [a + b]: -1, c:2}", options: [], parserOptions: { ecmaVersion: 6 } }, // ignore spread properties. - { code: "var obj = {a:1, ...z, b:1}", options: [], parserOptions: { ecmaVersion: 6, ecmaFeatures: { experimentalObjectRestSpread: true } } }, { code: "var obj = {a:1, ...z, b:1}", options: [], parserOptions: { ecmaVersion: 2018 } }, // ignore destructuring patterns. @@ -159,16 +158,6 @@ ruleTester.run("sort-keys", rule, { }, // ignore spred properties. - { - code: "var obj = {b:1, ...z, a:1}", - parserOptions: { - ecmaVersion: 6, - ecmaFeatures: { experimentalObjectRestSpread: true } - }, - errors: [ - "Expected object keys to be in ascending order. 'a' should be before 'b'." - ] - }, { code: "var obj = {b:1, ...z, a:1}", parserOptions: {