Skip to content

Commit

Permalink
Upgrade: acorn to 5.0.1 (#327)
Browse files Browse the repository at this point in the history
* Upgrade: acorn to 5.0.1

* Remove FunctionExpression conversion logic

* Add tests for parenthesized functions/classes (fixes #302)
  • Loading branch information
not-an-aardvark committed Mar 30, 2017
1 parent 15ef24f commit a3ae0bd
Show file tree
Hide file tree
Showing 7 changed files with 535 additions and 10 deletions.
7 changes: 0 additions & 7 deletions espree.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,6 @@ function esprimaFinishNode(result) {
}
}

// Acorn currently uses expressions instead of declarations in default exports
if (result.type === "ExportDefaultDeclaration") {
if (/^(Class|Function)Expression$/.test(result.declaration.type)) {
result.declaration.type = result.declaration.type.replace("Expression", "Declaration");
}
}

// Acorn uses undefined instead of null, which affects serialization
if (result.type === "Literal" && result.value === undefined) {
result.value = null;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"license": "BSD-2-Clause",
"dependencies": {
"acorn": "^4.0.11",
"acorn": "^5.0.1",
"acorn-jsx": "^3.0.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
module.exports = {
"type": "Program",
"start": 0,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 26
}
},
"range": [
0,
26
],
"body": [
{
"type": "ExportDefaultDeclaration",
"start": 0,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 26
}
},
"range": [
0,
26
],
"declaration": {
"type": "ClassExpression",
"start": 16,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 24
}
},
"range": [
16,
24
],
"id": null,
"superClass": null,
"body": {
"type": "ClassBody",
"start": 22,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 24
}
},
"range": [
22,
24
],
"body": []
}
}
}
],
"sourceType": "module",
"tokens": [
{
"type": "Keyword",
"value": "export",
"start": 0,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 6
}
},
"range": [
0,
6
]
},
{
"type": "Keyword",
"value": "default",
"start": 7,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 14
}
},
"range": [
7,
14
]
},
{
"type": "Punctuator",
"value": "(",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 16
}
},
"range": [
15,
16
]
},
{
"type": "Keyword",
"value": "class",
"start": 16,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 21
}
},
"range": [
16,
21
]
},
{
"type": "Punctuator",
"value": "{",
"start": 22,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 23
}
},
"range": [
22,
23
]
},
{
"type": "Punctuator",
"value": "}",
"start": 23,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 24
}
},
"range": [
23,
24
]
},
{
"type": "Punctuator",
"value": ")",
"start": 24,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 25
}
},
"range": [
24,
25
]
},
{
"type": "Punctuator",
"value": ";",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 26
}
},
"range": [
25,
26
]
}
]
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default (class {});

0 comments on commit a3ae0bd

Please sign in to comment.