Skip to content
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: parse later ES files in eslint --init (fixes #10003) #10378

Merged
merged 2 commits into from
May 28, 2018
Merged

Fix: parse later ES files in eslint --init (fixes #10003) #10378

merged 2 commits into from
May 28, 2018

Conversation

g-plane
Copy link
Member

@g-plane g-plane commented May 18, 2018

What is the purpose of this pull request? (put an "X" next to item)

[x] Bug fix

close #10003

What changes did you make? (Give an overview)
When running eslint --init, the CLI will ask user the ECMAScript version and whether using es6 globals.
Note that I haven't resolved ES7+ globals. This should be in another PR.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label May 18, 2018
@aladdin-add aladdin-add added cli Relates to ESLint's command-line interface accepted There is consensus among the team that this change meets the criteria for inclusion enhancement This change enhances an existing feature of ESLint and removed triage An ESLint team member will look at this issue soon labels May 19, 2018
Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for contributing!

I'm going to leave this open a little longer so more people can review. Thanks!

Copy link
Member

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I left a few comments.

{
type: "confirm",
name: "es6Globals",
message: "Are you using ES6 globals (such as `Map` and `Set`)?",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Can we call this "ES2015 globals", since it's referred to as "ES2015" in the previous question?

{
type: "confirm",
name: "es6Globals",
message: "Are you using ES6 globals (such as `Map` and `Set`)?",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reword this as "Do you want to enable..." rather than "Are you using..."? It seems like someone might answer "no" because they're currently not using Map and Set, even though they might want to do so in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll will update it. BTW, this sentence is copied, not written by me.

message: "Are you using ES6 globals (such as `Map` and `Set`)?",
default: false,
when(answers) {
return answers.ecmaVersion >= 2015;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning for only asking this question when answers.ecmaVersion >= 2015? If we're giving users the option to enable ES2015 parsing without ES2015 globals, it seems equally plausible that they might want to enable ES2015 globals without ES2015 parsing.

To me, it seems better to either guess the globals option based on the ecmaVersion answer (keeping things simpler for the user), or to always ask both questions. I would slightly prefer the former, since the --init helper is just supposed to address common cases and doesn't need to provide the same level of flexibility as creating a config file manually.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if the user choose "greater or equals to ES2015", skip this question and enable ES2015 globals?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would be my recommendation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I remove this question? I think, if the user choose ES3 or ES5, it shouldn't enable ES2015 globals, and if the user choose "greater or equals to ES2015", enable it by default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I think it would be best to remove the question and do what you just described.

@g-plane
Copy link
Member Author

g-plane commented May 24, 2018

@not-an-aardvark Updated.

@platinumazure
Copy link
Member

@not-an-aardvark Are your concerns addressed in this PR?

Copy link
Member

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@platinumazure platinumazure merged commit 636457d into eslint:master May 28, 2018
@g-plane g-plane deleted the fix-parsing-later-es branch May 29, 2018 04:40
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 26, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Nov 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion cli Relates to ESLint's command-line interface enhancement This change enhances an existing feature of ESLint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parsing error: Unexpected token => when using eslint --init on post-ES2015 files
4 participants