From a2bdadfc9db7993aeaca469e9fc09faf9ac166ee Mon Sep 17 00:00:00 2001 From: Lucas Duailibe Date: Tue, 9 Jan 2018 02:08:47 -0200 Subject: [PATCH] Fix: Remove "Experimental" from rest and spread (fixes #428) --- lib/ast-node-types.js | 2 - lib/convert.js | 12 +++--- tests/ast-alignment/fixtures-to-test.js | 5 +-- tests/lib/__snapshots__/ecma-features.js.snap | 40 +++++++------------ 4 files changed, 21 insertions(+), 38 deletions(-) diff --git a/lib/ast-node-types.js b/lib/ast-node-types.js index 809404d..5839455 100644 --- a/lib/ast-node-types.js +++ b/lib/ast-node-types.js @@ -42,8 +42,6 @@ module.exports = { Decorator: "Decorator", DoWhileStatement: "DoWhileStatement", EmptyStatement: "EmptyStatement", - ExperimentalRestProperty: "ExperimentalRestProperty", - ExperimentalSpreadProperty: "ExperimentalSpreadProperty", ExportAllDeclaration: "ExportAllDeclaration", ExportDefaultDeclaration: "ExportDefaultDeclaration", ExportNamedDeclaration: "ExportNamedDeclaration", diff --git a/lib/convert.js b/lib/convert.js index 2fa5d34..f178aa7 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -1133,10 +1133,8 @@ module.exports = function convert(config) { if (node.dotDotDotToken) { Object.assign(result, { - type: AST_NODE_TYPES.ExperimentalRestProperty, - argument: convertChild(node.propertyName || node.name), - computed: Boolean(node.propertyName && node.propertyName.kind === SyntaxKind.ComputedPropertyName), - shorthand: !node.propertyName + type: AST_NODE_TYPES.RestElement, + argument: convertChild(node.propertyName || node.name) }); } else { Object.assign(result, { @@ -1283,16 +1281,16 @@ module.exports = function convert(config) { break; } case SyntaxKind.SpreadAssignment: { - let type = AST_NODE_TYPES.ExperimentalSpreadProperty; + let type = AST_NODE_TYPES.SpreadElement; if (node.parent && node.parent.parent && node.parent.parent.kind === SyntaxKind.BinaryExpression ) { if (node.parent.parent.right === node.parent) { - type = AST_NODE_TYPES.ExperimentalSpreadProperty; + type = AST_NODE_TYPES.SpreadElement; } else if (node.parent.parent.left === node.parent) { - type = AST_NODE_TYPES.ExperimentalRestProperty; + type = AST_NODE_TYPES.RestElement; } } diff --git a/tests/ast-alignment/fixtures-to-test.js b/tests/ast-alignment/fixtures-to-test.js index 9af8d16..f9af598 100644 --- a/tests/ast-alignment/fixtures-to-test.js +++ b/tests/ast-alignment/fixtures-to-test.js @@ -105,10 +105,9 @@ let fixturePatternConfigsToTest = [ createFixturePatternConfigFor("ecma-features/experimentalObjectRestSpread", { ignore: [ /** - * "ExperimentalSpreadProperty" in espree/typescript-eslint-parser vs "SpreadElement" in Babylon - * comes up a lot in this section + * Trailing comma is not permitted after a "RestElement" in Babylon */ - "**/*" + "invalid-rest-trailing-comma" ] }), diff --git a/tests/lib/__snapshots__/ecma-features.js.snap b/tests/lib/__snapshots__/ecma-features.js.snap index 150dd17..694c8b4 100644 --- a/tests/lib/__snapshots__/ecma-features.js.snap +++ b/tests/lib/__snapshots__/ecma-features.js.snap @@ -61572,7 +61572,6 @@ Object { ], "type": "Identifier", }, - "computed": false, "loc": Object { "end": Object { "column": 19, @@ -61587,8 +61586,7 @@ Object { 15, 19, ], - "shorthand": true, - "type": "ExperimentalRestProperty", + "type": "RestElement", }, ], "range": Array [ @@ -61949,7 +61947,7 @@ Object { 5, 9, ], - "type": "ExperimentalRestProperty", + "type": "RestElement", }, ], "range": Array [ @@ -62075,7 +62073,7 @@ Object { 17, 21, ], - "type": "ExperimentalSpreadProperty", + "type": "SpreadElement", }, ], "range": Array [ @@ -62479,7 +62477,6 @@ Object { ], "type": "Identifier", }, - "computed": false, "loc": Object { "end": Object { "column": 20, @@ -62494,8 +62491,7 @@ Object { 14, 20, ], - "shorthand": true, - "type": "ExperimentalRestProperty", + "type": "RestElement", }, ], "range": Array [ @@ -62866,7 +62862,6 @@ Object { ], "type": "Identifier", }, - "computed": false, "loc": Object { "end": Object { "column": 16, @@ -62881,8 +62876,7 @@ Object { 12, 16, ], - "shorthand": true, - "type": "ExperimentalRestProperty", + "type": "RestElement", }, ], "range": Array [ @@ -63350,7 +63344,6 @@ Object { ], "type": "Identifier", }, - "computed": false, "loc": Object { "end": Object { "column": 16, @@ -63365,8 +63358,7 @@ Object { 12, 16, ], - "shorthand": true, - "type": "ExperimentalRestProperty", + "type": "RestElement", }, ], "range": Array [ @@ -64533,7 +64525,7 @@ Object { 70, 80, ], - "type": "ExperimentalSpreadProperty", + "type": "SpreadElement", }, ], "range": Array [ @@ -65281,7 +65273,6 @@ Object { ], "type": "Identifier", }, - "computed": false, "loc": Object { "end": Object { "column": 45, @@ -65296,8 +65287,7 @@ Object { 38, 48, ], - "shorthand": true, - "type": "ExperimentalRestProperty", + "type": "RestElement", }, ], "range": Array [ @@ -65936,7 +65926,6 @@ Object { ], "type": "Identifier", }, - "computed": false, "loc": Object { "end": Object { "column": 45, @@ -65951,8 +65940,7 @@ Object { 45, 55, ], - "shorthand": true, - "type": "ExperimentalRestProperty", + "type": "RestElement", }, ], "range": Array [ @@ -66685,7 +66673,7 @@ Object { 60, 66, ], - "type": "ExperimentalSpreadProperty", + "type": "SpreadElement", }, ], "range": Array [ @@ -67403,7 +67391,7 @@ Object { 70, 76, ], - "type": "ExperimentalSpreadProperty", + "type": "SpreadElement", }, ], "range": Array [ @@ -68045,7 +68033,7 @@ Object { 9, 13, ], - "type": "ExperimentalSpreadProperty", + "type": "SpreadElement", }, ], "range": Array [ @@ -68544,7 +68532,7 @@ Object { 56, 62, ], - "type": "ExperimentalSpreadProperty", + "type": "SpreadElement", }, Object { "argument": Object { @@ -68579,7 +68567,7 @@ Object { 68, 74, ], - "type": "ExperimentalSpreadProperty", + "type": "SpreadElement", }, ], "range": Array [