Skip to content

Commit

Permalink
Update: Upgrade Acorn to support ES2017 (fixes #287)
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Sep 8, 2016
1 parent 8d9767d commit dba2493
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var ast = espree.parse(code, {
// create a top-level tokens array containing all tokens
tokens: true,

// specify the language version (3, 5, 6, or 7, default is 5)
// specify the language version (3, 5, 6, 7, or 8, default is 5)
ecmaVersion: 5,

// specify which type of script you're parsing (script or module, default is script)
Expand Down Expand Up @@ -130,10 +130,17 @@ We are building on top of Acorn, however, so that we can contribute back and hel

All of them.

### What ECMAScript 7 features do you support?
### What ECMAScript 7/2016 features do you support?

There is only one ECMAScript 7 syntax change: the exponentiation operator. Espree supports this.

### What ECMAScript 2017 features do you support?

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

* `async` functions
* Trailing commas in function declarations and calls (including arrow functions and concise methods)

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

In general, we do not support experimental JavaScript features. We may make exceptions from time to time depending on the maturity of the features.
6 changes: 4 additions & 2 deletions espree.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,13 @@ function tokenize(code, options) {
case 5:
case 6:
case 7:
case 8:
acornOptions.ecmaVersion = options.ecmaVersion;
extra.ecmaVersion = options.ecmaVersion;
break;

default:
throw new Error("ecmaVersion must be 3, 5, 6, or 7.");
throw new Error("ecmaVersion must be 3, 5, 6, 7, or 8.");
}
}

Expand Down Expand Up @@ -643,12 +644,13 @@ function parse(code, options) {
case 5:
case 6:
case 7:
case 8:
acornOptions.ecmaVersion = options.ecmaVersion;
extra.ecmaVersion = options.ecmaVersion;
break;

default:
throw new Error("ecmaVersion must be 3, 5, 6, or 7.");
throw new Error("ecmaVersion must be 3, 5, 6, 7, or 8.");
}
}

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": "^3.3.0",
"acorn": "^4.0.1",
"acorn-jsx": "^3.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit dba2493

Please sign in to comment.