-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Docs: Add rest and spread operator changes to migration guide #10416
Conversation
There was a problem hiding this 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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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).
I made the changes you requested, I hope I did not miss any 馃槂 |
There was a problem hiding this 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.
There was a problem hiding this 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!
Merged, thanks so much @yannickcr for contributing! |
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:SpreadElement
type, they previously had theExperimentalSpreadProperty
type when theexperimentalObjectRestSpread
was enabled.RestElement
type, they previously had theExperimentalRestProperty
type when theexperimentalObjectRestSpread
was enabled.This is due that the backward compatibility is handled by forcing the
ecmaVersion
in #10230This change add 2 new migration guides in the "Breaking changes for plugin/custom rule developers" section:
SpreadElement
RestElement
Is there anything you'd like reviewers to focus on?
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.