-
-
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
Fix: prefer-object-spread duplicated comma (fixes #10512, fixes #10532) #10524
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.
LGTM, thanks!
I'd like one more set of eyes on this 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!
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 to ESLint! |
What is the purpose of this pull request? (put an "X" next to item)
[X] Bug fix: fixes #10512, fixes #10532
What changes did you make? (Give an overview)
This PR fixes
prefer-object-spread
rule to generate valid code in autofix.This PR is massive because it's hard to handle code correctly in text-based way.
The new way is token-based. Basically, it finds unnecessary tokens and removes those.
Object.assign
).(
→{
,)
→}
).ObjectExpression
node, remove braces (and enclosing parentheses), and remove trailing comma if exists....
before the argument.I tried to make close formatting to the original, but there are some difference in spacing.
Is there anything you'd like reviewers to focus on?
It passes existing test cases, but tell me if you want to see other cases.