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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Add rest and spread operator changes to migration guide #10416

Merged
merged 3 commits into from
Jun 1, 2018

Conversation

yannickcr
Copy link
Contributor

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

[x] Documentation update

What changes did you make? (Give an overview)

While updating eslint-plugin-react for the upcoming ESLint v5 I noticed some changes that were not addressed in the current migration guide:

  • The spread operators now always have the SpreadElement type, they previously had the ExperimentalSpreadProperty type when the experimentalObjectRestSpread was enabled.
  • The spread operators now always have the RestElement type, they previously had the ExperimentalRestProperty type when the experimentalObjectRestSpread was enabled.

This is due that the backward compatibility is handled by forcing the ecmaVersion in #10230

This change add 2 new migration guides in the "Breaking changes for plugin/custom rule developers" section:

  • When using the default parser, spread operators now have type SpreadElement
  • When using the default parser, rest operators now have type RestElement

Is there anything you'd like reviewers to focus on?

  • Plugin/custom rule developers should already have handled SpreadElement/RestElement in their plugins, but it is not always the case so I think it's worth it to add this in the migration guide.
  • As stated at the top of the migration guide "The lists below are ordered roughly by the number of users each change is expected to affect, where the first items are expected to affect the most users." . I'm not sure how many plugin developers will be affected by this change, so in doubt I placed the new guides just bellow a similar change.
  • English is not my primary language, so any correction is welcome 馃槈

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label May 29, 2018
@platinumazure platinumazure added documentation Relates to ESLint's documentation accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels May 29, 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.

This generally looks great, thanks for adding this! I've left a few inline comments.

I think these sections are generally in the right place, but I assume plugins that use spread/rest operators are slightly more common than plugins that use JSX. So maybe these sections should be moved to immediately above the JSX section? But that's not critical and shouldn't block this from being merged.

@@ -194,6 +196,22 @@ When parsing JSX code like `<a>foo</a>`, the default parser will now give the `f

**To address:** If you have written a custom rule that relies on text nodes in JSX elements having the `Literal` type, you should update it to also work with nodes that have the `JSXText` type.

## <a name="spread-operators"></a> When using the default parser, spread operators now have type `SpreadElement`

Previously, when parsing JS code like `const foo = {...data}` with the `experimentalObjectRestSpread` option enabled the default parser would set the `...data` AST node the `ExperimentalSpreadProperty` type.
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a comma after "with the experimentalObjectRestSpread option enabled" (after the word "enabled")?

And I think the second half of the sentence might read more naturally like this:

the default parser would generate an `ExperimentalSpreadProperty` node type for the `...data` spread element.

(But I may be wrong here.)


Previously, when parsing JS code like `const foo = {...data}` with the `experimentalObjectRestSpread` option enabled the default parser would set the `...data` AST node the `ExperimentalSpreadProperty` type.

In ESLint v5, the default parser will now always give the `...data` AST node the `SpreadElement` type, even if the [now deprecated]](#experimental-object-rest-spread) `experimentalObjectRestSpread` option was enabled. This makes the AST compliant with the current ESTree spec.
Copy link
Member

Choose a reason for hiding this comment

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

Should this say:

[[now deprecated] `experimentalObjectRestSpread`](#experimental-object-rest-spread)

Or maybe:

\[now deprecated\] [`experimentalObjectRestSpread`](#experimental-object-rest-spread)

Or for that matter, we could use parentheses to make this simpler.

Also: I think instead of "option was enabled", let's use "option is enabled" (to be consistent with present/future tense of this paragraph).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I left a spare ]. It was:

[now deprecated](#experimental-object-rest-spread) `experimentalObjectRestSpread`

As you suggest I will use parentheses instead.


## <a name="rest-operators"></a> When using the default parser, rest operators now have type `RestElement`

Previously, when parsing JS code like `const {foo, ...rest} = data` with the `experimentalObjectRestSpread` option enabled the default parser would set the `...data` AST node the `ExperimentalRestProperty` type.
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a comma after "with the experimentalObjectRestSpread option enabled" (after the word "enabled")?

And I think the second half of the sentence might read more naturally like this:

the default parser would generate an `ExperimentalRestProperty` node type for the `...data` rest element.

(But I may be wrong here.)


Previously, when parsing JS code like `const {foo, ...rest} = data` with the `experimentalObjectRestSpread` option enabled the default parser would set the `...data` AST node the `ExperimentalRestProperty` type.

In ESLint v5, the default parser will now always give the `...data` AST node the `RestElement` type, even if the [now deprecated]](#experimental-object-rest-spread) `experimentalObjectRestSpread` option was enabled. This makes the AST compliant with the current ESTree spec.
Copy link
Member

Choose a reason for hiding this comment

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

Should this say:

[[now deprecated] `experimentalObjectRestSpread`](#experimental-object-rest-spread)

Or maybe:

\[now deprecated\] [`experimentalObjectRestSpread`](#experimental-object-rest-spread)

Or for that matter, we could use parentheses to make this simpler.

Also: I think instead of "option was enabled", let's use "option is enabled" (to be consistent with present/future tense of this paragraph).

@yannickcr
Copy link
Contributor Author

I made the changes you requested, I hope I did not miss any 馃槂

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!

Waiting for another set of eyes before merging.

Copy link
Member

@kaicataldo kaicataldo 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!

@platinumazure platinumazure merged commit 400d4b5 into eslint:master Jun 1, 2018
@platinumazure
Copy link
Member

Merged, thanks so much @yannickcr for contributing!

@yannickcr yannickcr deleted the rest-spread-migration-guide branch June 2, 2018 12:47
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 30, 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 30, 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 documentation Relates to ESLint's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants