Skip to content

Commit

Permalink
Update: upgrade acorn to support two ES2019 syntax (#380)
Browse files Browse the repository at this point in the history
* Update: upgrade acorn to support two ES2019 syntax

* update generated test results since Node.js doesn't support the syntax

* fix typo
  • Loading branch information
mysticatea authored and platinumazure committed Jun 4, 2018
1 parent 8cb3ceb commit cd9da7e
Show file tree
Hide file tree
Showing 17 changed files with 1,009 additions and 5 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ var ast = espree.parse(code, {
// create a top-level tokens array containing all tokens
tokens: false,

// Set to 3, 5 (default), 6, 7, 8, or 9 to specify the version of ECMAScript syntax you want to use.
// You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), or 2018 (same as 9) to use the year-based naming.
// Set to 3, 5 (default), 6, 7, 8, 9, or 10 to specify the version of ECMAScript syntax you want to use.
// You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), or 2019 (same as 10) to use the year-based naming.
ecmaVersion: 5,

// specify which type of script you're parsing ("script" or "module")
Expand Down Expand Up @@ -143,11 +143,24 @@ There are two ECMAScript 2017 syntax changes: `async` functions, and trailing co

### What ECMAScript 2018 features do you support?

Because ECMAScript 2018 is still under development, we are implementing features as they are finalized. Currently, Espree supports:
There are seven ECMAScript 2018 syntax changes:

* Invalid escape sequences in tagged template literals
* Rest/spread properties
* Async Iteration
* Async iteration
* RegExp `s` flag
* RegExp named capture groups
* RegExp lookhehind assersions
* RegExp unicode property escapes

Espree supports all of them.

### What ECMAScript 2019 features do you support?

Because ECMAScript 2019 is still under development, we are implementing features as they are finalized. Currently, Espree supports:

* Optional `catch` binding
* JSON superset (`\u2028` and `\u2029` in string literals)

### How do you determine which experimental features to support?

Expand Down
1 change: 1 addition & 0 deletions espree.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ function normalizeEcmaVersion(ecmaVersion) {
case 7:
case 8:
case 9:
case 10:
return version;

default:
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": "^5.5.1",
"acorn": "^5.6.0",
"acorn-jsx": "^4.1.1"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
"index": 8,
"lineNumber": 1,
"column": 9,
"message": "Unterminated string constant"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var s = "
"
168 changes: 168 additions & 0 deletions tests/fixtures/ecma-version/10/json-superset/valid-2028.result.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
module.exports = {
"type": "Program",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 11
}
},
"range": [
0,
11
],
"body": [
{
"type": "VariableDeclaration",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 11
}
},
"range": [
0,
11
],
"declarations": [
{
"type": "VariableDeclarator",
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 11
}
},
"range": [
4,
11
],
"id": {
"type": "Identifier",
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
}
},
"range": [
4,
5
],
"name": "s"
},
"init": {
"type": "Literal",
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 11
}
},
"range": [
8,
11
],
"value": "\u2028",
"raw": "\"\u2028\""
}
}
],
"kind": "var"
}
],
"sourceType": "script",
"tokens": [
{
"type": "Keyword",
"value": "var",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
}
},
"range": [
0,
3
]
},
{
"type": "Identifier",
"value": "s",
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
}
},
"range": [
4,
5
]
},
{
"type": "Punctuator",
"value": "=",
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
}
},
"range": [
6,
7
]
},
{
"type": "String",
"value": "\"\u2028\"",
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 11
}
},
"range": [
8,
11
]
}
]
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var s = "
"
Loading

0 comments on commit cd9da7e

Please sign in to comment.