Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

Commit

Permalink
Fix: Remove "Experimental" from rest and spread (fixes #428)
Browse files Browse the repository at this point in the history
  • Loading branch information
duailibe committed Jun 27, 2018
1 parent 42f29a1 commit a2bdadf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 38 deletions.
2 changes: 0 additions & 2 deletions lib/ast-node-types.js
Expand Up @@ -42,8 +42,6 @@ module.exports = {
Decorator: "Decorator",
DoWhileStatement: "DoWhileStatement",
EmptyStatement: "EmptyStatement",
ExperimentalRestProperty: "ExperimentalRestProperty",
ExperimentalSpreadProperty: "ExperimentalSpreadProperty",
ExportAllDeclaration: "ExportAllDeclaration",
ExportDefaultDeclaration: "ExportDefaultDeclaration",
ExportNamedDeclaration: "ExportNamedDeclaration",
Expand Down
12 changes: 5 additions & 7 deletions lib/convert.js
Expand Up @@ -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, {
Expand Down Expand Up @@ -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;
}
}

Expand Down
5 changes: 2 additions & 3 deletions tests/ast-alignment/fixtures-to-test.js
Expand Up @@ -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"
]
}),

Expand Down
40 changes: 14 additions & 26 deletions tests/lib/__snapshots__/ecma-features.js.snap
Expand Up @@ -61572,7 +61572,6 @@ Object {
],
"type": "Identifier",
},
"computed": false,
"loc": Object {
"end": Object {
"column": 19,
Expand All @@ -61587,8 +61586,7 @@ Object {
15,
19,
],
"shorthand": true,
"type": "ExperimentalRestProperty",
"type": "RestElement",
},
],
"range": Array [
Expand Down Expand Up @@ -61949,7 +61947,7 @@ Object {
5,
9,
],
"type": "ExperimentalRestProperty",
"type": "RestElement",
},
],
"range": Array [
Expand Down Expand Up @@ -62075,7 +62073,7 @@ Object {
17,
21,
],
"type": "ExperimentalSpreadProperty",
"type": "SpreadElement",
},
],
"range": Array [
Expand Down Expand Up @@ -62479,7 +62477,6 @@ Object {
],
"type": "Identifier",
},
"computed": false,
"loc": Object {
"end": Object {
"column": 20,
Expand All @@ -62494,8 +62491,7 @@ Object {
14,
20,
],
"shorthand": true,
"type": "ExperimentalRestProperty",
"type": "RestElement",
},
],
"range": Array [
Expand Down Expand Up @@ -62866,7 +62862,6 @@ Object {
],
"type": "Identifier",
},
"computed": false,
"loc": Object {
"end": Object {
"column": 16,
Expand All @@ -62881,8 +62876,7 @@ Object {
12,
16,
],
"shorthand": true,
"type": "ExperimentalRestProperty",
"type": "RestElement",
},
],
"range": Array [
Expand Down Expand Up @@ -63350,7 +63344,6 @@ Object {
],
"type": "Identifier",
},
"computed": false,
"loc": Object {
"end": Object {
"column": 16,
Expand All @@ -63365,8 +63358,7 @@ Object {
12,
16,
],
"shorthand": true,
"type": "ExperimentalRestProperty",
"type": "RestElement",
},
],
"range": Array [
Expand Down Expand Up @@ -64533,7 +64525,7 @@ Object {
70,
80,
],
"type": "ExperimentalSpreadProperty",
"type": "SpreadElement",
},
],
"range": Array [
Expand Down Expand Up @@ -65281,7 +65273,6 @@ Object {
],
"type": "Identifier",
},
"computed": false,
"loc": Object {
"end": Object {
"column": 45,
Expand All @@ -65296,8 +65287,7 @@ Object {
38,
48,
],
"shorthand": true,
"type": "ExperimentalRestProperty",
"type": "RestElement",
},
],
"range": Array [
Expand Down Expand Up @@ -65936,7 +65926,6 @@ Object {
],
"type": "Identifier",
},
"computed": false,
"loc": Object {
"end": Object {
"column": 45,
Expand All @@ -65951,8 +65940,7 @@ Object {
45,
55,
],
"shorthand": true,
"type": "ExperimentalRestProperty",
"type": "RestElement",
},
],
"range": Array [
Expand Down Expand Up @@ -66685,7 +66673,7 @@ Object {
60,
66,
],
"type": "ExperimentalSpreadProperty",
"type": "SpreadElement",
},
],
"range": Array [
Expand Down Expand Up @@ -67403,7 +67391,7 @@ Object {
70,
76,
],
"type": "ExperimentalSpreadProperty",
"type": "SpreadElement",
},
],
"range": Array [
Expand Down Expand Up @@ -68045,7 +68033,7 @@ Object {
9,
13,
],
"type": "ExperimentalSpreadProperty",
"type": "SpreadElement",
},
],
"range": Array [
Expand Down Expand Up @@ -68544,7 +68532,7 @@ Object {
56,
62,
],
"type": "ExperimentalSpreadProperty",
"type": "SpreadElement",
},
Object {
"argument": Object {
Expand Down Expand Up @@ -68579,7 +68567,7 @@ Object {
68,
74,
],
"type": "ExperimentalSpreadProperty",
"type": "SpreadElement",
},
],
"range": Array [
Expand Down

0 comments on commit a2bdadf

Please sign in to comment.