-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
refactor: use object spread instead of Object.assign for new objects #12213
Conversation
Codecov Report
@@ Coverage Diff @@
## master #12213 +/- ##
==========================================
- Coverage 96.34% 96.33% -0.01%
==========================================
Files 95 95
Lines 9183 9169 -14
==========================================
- Hits 8847 8833 -14
Misses 336 336
Continue to review full report at Codecov.
|
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 codebase becomes more and more modern :)
options = Object.assign({}, options, { | ||
scope: false | ||
}); | ||
options = { ...options, scope: false }; |
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.
ideally parameters should be read-only, but that's another problem
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.
Correct, I've seen numerous fixes creeping in over time that end up cloning/deep cloning inputs, but this almost impossible to fix on a greater scale without static analysis.
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.
Totally agree
Pull Request check-list
Please make sure to review and check all of these items:
npm run test
ornpm run test-DIALECT
pass with this change (including linting)?Description of change
This replaces most
Object.assign
usage with the more performant (about 40%) (1) object spread.Object.assign({}, ...)
have been auto refactored by eslint.|| {}
pattern is not needed as{ ...undefined }
yields{}
.val = Object.assign(val, ...)
has been replaced withObject.assign(val, ...)
to avoid confusion and redundant assigns.Notes: