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
Parsing error: Unexpected token => when using eslint --init on post-ES2015 files #10003
Comments
This is happening because we only ask whether the user is using ES6, and we don't supply an option for later ES versions. When the question was added, ES2015 was the latest version. Maybe we should add a list of ES versions to choose from, rather than just asking about ES6. |
Ah, that certainly makes sense. I know tons of people refer to ES6 as "modern" JS, even though it most certainly isn't. Enumeration of options would certainly resolve the issue. |
TSC Summary: When running eslint --init and asking it to inspect source code of files, we ask if users are using ES2015/ES6 features but not if they might be using later ES versions (to allow, e.g., exponentiation or async/await syntax). This causes a parsing error, since we aren't parsing the files with a recent enough ecmaVersion. Probably the best way to resolve this is to change the "Using ES6 features" question in TSC Question: Should we change the "Using ES6 features" question to an ecmaVersion selection question? |
Actually, I was planning to submit a PR to accomplish this. One issue I found is we only have env "es6". So I dug into the issue of the actual "es6" behaviour and the possibility of having different version for parser options and globals. I'm willing to champion this, but we would need to decide on how to proceed. |
There was a discussion about that at #9109. There is a potential issue that if someone uses both I do wonder whether |
Yes, I was refering to that conversation (among others).
One thing we have to decide is what would be the behavior of There was also the problem with the precedence arised in #8291 If we deprecated If we want to move away from the |
What about this approach?
This is kicking the can down the road in terms of globals in later ES versions, but it would allow us to fix the original reported issue. |
@platinumazure What do you mean by "ES6 globals"? |
@fatcerberus I'm referring to globals like We intentionally allow users to set |
|
@alberto Do we have an env configured for those globals yet? I think that might be a separate issue. |
In today's TSC meeting, the TSC accepted this issue. |
* Fix: parse later ES files in `eslint --init` (fixes #10003) * Update: remove question of asking ES2015 globals
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using? Default
Please show your full configuration: N/A
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
Followed by answering prompts as follows:
What did you expect to happen?
.eslint.yaml
generatedWhat actually happened? Please include the actual, raw output from ESLint.
The text was updated successfully, but these errors were encountered: