-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Possible bug, but at least unclarity in ecmaVersion documentation. #2898
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
Comments
I can see how one might misinterpret the docs here. Here we declare that
But in the section on the option, it for clarity of concepts it is written with the typescript-eslint/packages/parser/README.md Lines 99 to 100 in 9f7ec66
I can see how this can be interpreted as meaning Change your value to |
Thanks @bradzacher! A clarification in the docs was exactly what I was hoping for. I am curious if @typescript-eslint/parser could support |
It could easily be wired up for our parser/scope analyser - but the problem is that the rest of the ESLint ecosystem expects this to be a number. |
Gotcha. That makes sense. Thanks for the clarification there! I appreciate the super-fast response! |
Context
There is at least an issue of unclarity in the documentation around
ecmaVersion
. I was running into aTypeError
which seemed to be a clash witheslint-plugin-react
, but ultimately turned out to be an issue of @typescript-eslint/parser evaluating to an unexpectedecmaVersion
.This comment describing the problem lays out exactly what we discovered, but in short: I expected a string like
es2020
to work as an appropriateecmaVersion
value because the examples in the docs seem to indicate that this is an appropriate value, but ultimately this results in a realecmaVersion
ofes5
because the code is expecting a number and not a string.I can, of course, simply use a number and move on, but I am curious how someone might use
esnext
as a floating point, or if that's even a desired behavior. The way the code works now, one might just use a number like5000
and expect that the parser will always use theesnext
version (at least in my lifetime), but that's certainly a hack more than a solution.Repro
If you'd like to see the error happen, you can clone this repo which reproduces the problem.
Expected Result
@typescript-eslint/parser uses the
es2020
ecmaVersion
and does not end up causing errors in rules from other plugins.Actual Result
@typescript-eslint/parser ultimately uses the
es5
ecmaVersion
and causes errors in rules fromeslint-plugin-react
.Additional Info
This is the exception I ultimately see thrown (as can be seen in the linked repo above):
Here's the output with the --debug flag:
Versions
@typescript-eslint/parser
4.11.0
TypeScript
4.1.3
ESLint
7.16.0
node
15.4.0
The text was updated successfully, but these errors were encountered: