Description
ESTree just merged the representation for optional chaining.
estree/estree#204
They chose a different representation to babel's representation, which we went with originally (as it was the only representation in the ecosystem).
We now need to update our parser to match this representation.
interface ChainExpression <: Expression {
type: "ChainExpression"
expression: ChainElement
}
interface ChainElement <: Node {
optional: boolean
}
extend interface CallExpression <: ChainElement {}
extend interface MemberExpression <: ChainElement {}
In terms of timelines, we need to track ESLint here, as they will be moving to implement this as well. With it, they will update their lint rules to support it.
- Acorn: add Optional Chaining acornjs/acorn#891
- Espree: Update: support optional chaining eslint/js#446
- ESLint:
This is ofc a breaking change in the AST structure, and will unfortunately be a relatively painful one for consumers of our plugins.
I don't see this as being too painful, however. There will be some new false-negatives in the ecosystem due to the ChainExpression
node, but because everything is now just a Call/MemberExpression
, most of the plugins should "just work".
This is required to support ESLint 7.5.0, which added support to rules for optional chaining.
https://eslint.org/blog/2020/07/eslint-v7.5.0-released