Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Breaking: make AST match Espree 6 #785

Merged
merged 1 commit into from
Nov 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions lib/babylon-to-espree/convertAST.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,6 @@ const astTransformVisitor = {
exit(path) {
const node = path.node;

if (path.isJSXText()) {
node.type = "Literal";
}

if (
path.isRestElement() &&
path.parent &&
path.parent.type === "ObjectPattern"
) {
node.type = "ExperimentalRestProperty";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsArray{Pattern|Expression} already taken care of?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

it("RestOperator", () => {
parseAndAssertSame("var { a, ...b } = c");
parseAndAssertSame("var [ a, ...b ] = c");
parseAndAssertSame("var a = function (...b) {}");
});
it("SpreadOperator", () => {
parseAndAssertSame("var a = { b, ...c }");
parseAndAssertSame("var a = [ a, ...b ]");
parseAndAssertSame("var a = sum(...b)");
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks - makes sense!

}

if (
path.isSpreadElement() &&
path.parent &&
path.parent.type === "ObjectExpression"
) {
node.type = "ExperimentalSpreadProperty";
}

if (path.isTypeParameter()) {
node.type = "Identifier";
node.typeAnnotation = node.bound;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"eslint-plugin-flowtype": "^3.11.1",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-prettier": "^3.1.0",
"espree": "^3.5.2",
"espree": "^6.0.0",
"husky": "^1.0.0-rc.13",
"lint-staged": "^7.2.2",
"mocha": "^6.1.4",
Expand Down
4 changes: 3 additions & 1 deletion test/specs/babel-eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ describe("babylon-to-espree", () => {
});

it("super outside method", () => {
parseAndAssertSame("function F() { super(); }");
assert.throws(() => {
parseAndAssertSame("function F() { super(); }");
}, /SyntaxError: 'super' keyword outside a method/);
});

it("StringLiteral", () => {
Expand Down
25 changes: 0 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -835,28 +835,11 @@
dependencies:
any-observable "^0.3.0"

acorn-jsx@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b"
integrity sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=
dependencies:
acorn "^3.0.4"

acorn-jsx@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.0.1.tgz#32a064fd925429216a09b141102bfdd185fae40e"
integrity sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg==

acorn@^3.0.4:
version "3.3.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"
integrity sha1-ReN/s56No/JbruP/U2niu18iAXo=

acorn@^5.5.0:
version "5.7.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279"
integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==

acorn@^6.0.7:
version "6.2.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.2.0.tgz#67f0da2fc339d6cfb5d6fb244fd449f33cd8bbe3"
Expand Down Expand Up @@ -1530,14 +1513,6 @@ eslint@^6.0.1:
table "^5.2.3"
text-table "^0.2.0"

espree@^3.5.2:
version "3.5.4"
resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7"
integrity sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==
dependencies:
acorn "^5.5.0"
acorn-jsx "^3.0.0"

espree@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/espree/-/espree-6.0.0.tgz#716fc1f5a245ef5b9a7fdb1d7b0d3f02322e75f6"
Expand Down