Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: support logical assignment and numeric separators #448

Merged
merged 4 commits into from
Aug 5, 2020
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
38 changes: 8 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ const options = {
// create a top-level tokens array containing all tokens
tokens: false,

// 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), 2019 (same as 10), or 2020 (same as 11) to use the year-based naming.
// Set to 3, 5 (default), 6, 7, 8, 9, 10, 11, or 12 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), 2019 (same as 10), 2020 (same as 11), or 2021 (same as 12) to use the year-based naming.
ecmaVersion: 5,

// specify which type of script you're parsing ("script" or "module")
Expand Down Expand Up @@ -217,38 +217,16 @@ Acorn is a great JavaScript parser that produces an AST that is compatible with

We are building on top of Acorn, however, so that we can contribute back and help make Acorn even better.

### What ECMAScript 6 features do you support?
### What ECMAScript features do you support?

All of them.
Espree supports all ECMAScript 2020 features and partially supports ECMAScript 2021 features.

### What ECMAScript 7/2016 features do you support?
Because ECMAScript 2021 is still under development, we are implementing features as they are finalized. Currently, Espree supports:

There is only one ECMAScript 2016 syntax change: the exponentiation operator. Espree supports this.
* [Logical Assignment Operators](https://github.com/tc39/proposal-logical-assignment)
* [Numeric Separators](https://github.com/tc39/proposal-numeric-separator)

### What ECMAScript 2017 features do you support?

There are two ECMAScript 2017 syntax changes: `async` functions, and trailing commas in function declarations and calls. Espree supports both of them.

### What ECMAScript 2018 features do you support?

There are seven ECMAScript 2018 syntax changes:

* Invalid escape sequences in tagged template literals
* Rest/spread properties
* Async iteration
* RegExp `s` flag
* RegExp named capture groups
* RegExp lookbehind assertions
* 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)
See [finished-proposals.md](https://github.com/tc39/proposals/blob/master/finished-proposals.md) to know what features are finalized.

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

Expand Down
3 changes: 2 additions & 1 deletion lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const SUPPORTED_VERSIONS = [
8,
9,
10,
11
11,
12
];

/**
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": "^7.3.1",
"acorn": "^7.4.0",
"acorn-jsx": "^5.2.0",
"eslint-visitor-keys": "^1.3.0"
},
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/ecma-version/11/bigint/binary.result.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
0,
7
],
"value": null,
"value": 0b0101n,
"raw": "0b0101n",
"bigint": "0b0101"
}
Expand All @@ -74,4 +74,4 @@ module.exports = {
]
}
]
};
};
4 changes: 2 additions & 2 deletions tests/fixtures/ecma-version/11/bigint/decimal.result.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
0,
2
],
"value": null,
"value": 1n,
"raw": "1n",
"bigint": "1"
}
Expand All @@ -74,4 +74,4 @@ module.exports = {
]
}
]
};
};
4 changes: 2 additions & 2 deletions tests/fixtures/ecma-version/11/bigint/hex.result.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
0,
5
],
"value": null,
"value": 0x80n,
"raw": "0x80n",
"bigint": "0x80"
}
Expand All @@ -74,4 +74,4 @@ module.exports = {
]
}
]
};
};
4 changes: 2 additions & 2 deletions tests/fixtures/ecma-version/11/bigint/octal.result.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
0,
6
],
"value": null,
"value": 0o755n,
"raw": "0o755n",
"bigint": "0o755"
}
Expand All @@ -74,4 +74,4 @@ module.exports = {
]
}
]
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
module.exports = {
"type": "Program",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 7
}
},
"range": [
0,
7
],
"body": [
{
"type": "ExpressionStatement",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 7
}
},
"range": [
0,
7
],
"expression": {
"type": "AssignmentExpression",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 7
}
},
"range": [
0,
7
],
"operator": "&&=",
"left": {
"type": "Identifier",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
},
"range": [
0,
1
],
"name": "a"
},
"right": {
"type": "Identifier",
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
}
},
"range": [
6,
7
],
"name": "b"
}
}
}
],
"sourceType": "script",
"tokens": [
{
"type": "Identifier",
"value": "a",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
},
"range": [
0,
1
]
},
{
"type": "Punctuator",
"value": "&&=",
"loc": {
"start": {
"line": 1,
"column": 2
},
"end": {
"line": 1,
"column": 5
}
},
"range": [
2,
5
]
},
{
"type": "Identifier",
"value": "b",
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
}
},
"range": [
6,
7
]
}
]
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a &&= b
Loading