esprima-python
esprima-python copied to clipboard
Optional chaining
Hi All,
This PR is a port of the following PR from the main esprima
project:
https://github.com/jquery/esprima/pull/2048
I've hit a bit of a wall when running unit tests getting the added optional
parameter to get serialized when toDict
is called. Any help you can provide to fix that and get this merged would be great!
An example is:
test/fixtures/declaration/function/migrated_0006.js
The expected output has this in the output: https://github.com/Kronuz/esprima-python/blob/2e108bf41d66a4c4517405d5d398225b250207f8/test/fixtures/declaration/function/migrated_0006.tree.json#L70
Where the actual just doesn't have optional
as a member of the CallExpression
object:
"expression": {
"arguments": [],
"callee": {
"loc": {
"end": {
"column": 25,
"line": 1
},
"start": {
"column": 20,
"line": 1
}
},
"name": "sayHi",
"range": [
20,
25
],
"type": "Identifier"
},
"loc": {
"end": {
"column": 27,
"line": 1
},
"start": {
"column": 20,
"line": 1
}
},
"optional": false,
"range": [
20,
27
],
"type": "CallExpression"
}
Update: I was using the pip
installed version while running tests
Removed unsupported tests. I plan on pulling in the following PRs in the near future:
https://github.com/jquery/esprima/pull/1190 https://github.com/jquery/esprima/issues/2032 https://github.com/jquery/esprima/issues/2039
Only two problems left to fix
@Kronuz : spent a bit more time but I'm not sure how to where the last errors are coming from. On test/fixtures/expression/primary/literal/regular-expression/u-flag-surrogate-pair.js
I get
"init": {
"loc": {
"end": {
"column": 41,
"line": 1
},
"start": {
"column": 8,
"line": 1
}
},
"range": [
8,
41
],
"raw": "/[\\uD834\\uDF06-\\uD834\\uDF08a-z]/u",
"regex": {
"flags": "u",
"pattern": "[\\uD834\\uDF06-\\uD834\\uDF08a-z]"
},
"type": "Literal",
"value": {}
}
I'm not sure where "value": {}
is coming from given the changes made for this feature.
Any help you can provide would be appreciated
Any idea when this is going to be done and merged?
@djn3m0 I dropped this work since I changed positions, sorry. IIRC we changed from esprima-python
to using https://github.com/eslint/espree directly