-
-
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🎉 Object Rest/Spread Properties arrived at stage 4 #9885
🎉 Object Rest/Spread Properties arrived at stage 4 #9885
Comments
Any chance we could reopen #7230 now? :-D (Separately, you might want to make 2018, or 2019 if 2018's ship has sailed, a schema error when combined with experimentalObjectRestSpread) |
I made a list awhile ago of things that need to be updated:
|
Duplicate spread elements may not be an error; |
I'm referring to objects like |
In that case, |
const foo = { a: 1, b: 2 };
({
...foo,
...foo
}); ...is effectively doing the same thing as code like this: ({
a: 1, b: 2,
a: 1, b: 2
}) The latter is covered by |
Sure, but you could only do that when |
Even if 1 I suppose there wouldn't be duplicate keys if |
Maybe we could create a new rule (e.g., |
As you said, though, if the object has getters, then duplicate keys might be desired so that it invokes the getter multiple times. |
I don't have a problem with ESLint getting confused if someone is using object spread for the purpose of repeatedly invoking a getter with side-effects, because anyone reading that code will probably be confused too. |
@ljharb A similar argument could be made for |
That's the case for a most of ESLint rules. Getters and setters are just not something that can be statically analyzed, so we choose to not try. A lot of ESLint rules will fail when used with getters that return different values. |
I'm working on this for existing rules. |
First, just a data point on usage: We're all in on eslint now as of Sails v1, and I've really appreciated how specific rules have been, and the continued focus on that for new ES functionality. Bravo! Since Node incorporates this as of Node 8.6, we're going ahead generating new projects with @ljharb 2¢ re: duplicates: I do think you're right about the duplicate spread symbol....thingies. On one hand, I could see someone considering using something like So anyway, it might be worthwhile to call this out with a distinct rule. Besides, for every separate rule eslint contains, the better (and more productive) of an experience developers have when working with eslint integration in their text editor (i.e. because the error messages displayed are more precise and thus helpful) |
It's the time to update our rules to be according to the current ESTree spec.
ecmaVersion:2018
.I think we should keep
ecmaFeatures.experimentalObjectRestSpread
to avoid breaking changes.ecmaVersion:2018
and noecmaFeatures.experimentalObjectRestSpread
, Espree generatesRestElement
/SpreadElement
.ecmaFeatures.experimentalObjectRestSpread:true
, Espree generatesExperimentalRestProperty
/ExperimentalSpreadProperty
as is.The text was updated successfully, but these errors were encountered: