-
Notifications
You must be signed in to change notification settings - Fork 23
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
[FIX] Switch from esprima to espree #615
Conversation
9c88240
to
e7bef3b
Compare
As discussed earlier today, we should always parse the latest ECMAScript version (just like browsers do). Projects should use linters to enforce specific versions. To make this part of a non-major UI5 Tooling release we would need to use espree v6 as all later versions require Node.js >10. |
Still better than nothing, right? So maybe go with v6 for now and upgrade to v8 with UI5 Tooling 3.0? |
A new module lib/lbt/utils/parseJS is introduced that exposes a parseJS function and a Syntax object with all AST node types. The new module is used in all places where JavaSCript code is parsed (incl. tests). The module uses espree v6 for parsing instead of esprima. This is the maximum version that can be used without introducing breaking changes to the tooling (higher versions of espree require higher node versions than documented in our package.json). The set of allowed parser options is limited to ease a later migration to another parser. Fixes SAP/ui5-tooling#354 .
e7bef3b
to
68557a0
Compare
Validated 7ea1a69 successfully in a smoke test run and locally by building the webc libraries 👍 |
Are you okay with the
|
Yeah, parseUtil seems to be a better name for the module |
I'll do the rename |
Decided on parseUtils to align it with the already existing ASTUtils. What about |
Reg. |
Well there is already Anything left here? |
I think we're good to go... |
Meanwhile, there is already Espree 9.0 and Node.js 17.0, perhaps it is better to not stick with already outdated versions but go forward directly to the latest available versions, perhaps even towards late beta/RC versions. This will ensure the support of cutting edge features. |
According to the package.json, Espree 9.0 still supports all active Node.js versions. So it shouldn't be a problem to upgrade directly to 9.0 with our next major. |
This is work in progress and can't be submitted as the used espree
version (8.0.0-beta) is not a release version and it requires a newer
NodeJS min version than the tooling.
espree 8.0.0-beta was chosen as it switches the default for the
ecmaVersion option from 5 (7.3.1) to latest.
Before submitting, it also should be decided whether all parsing code
should be routed through some helper utility, to simplify future updates
/ changes of the parser. At the same time, we should decide about the
use of the sourceType and the ecmaVersion options. Should we expose them
in ui5.yaml? Or should we rather leave that to the linting step?
Fixes SAP/ui5-tooling#354 .
Thank you for your contribution! 🙌
To get it merged faster, kindly review the checklist below:
Pull Request Checklist