refactor: use object spread instead of Object.assign for new objects#12213
Merged
sushantdhiman merged 1 commit intomasterfrom May 3, 2020
Merged
refactor: use object spread instead of Object.assign for new objects#12213sushantdhiman merged 1 commit intomasterfrom
sushantdhiman merged 1 commit intomasterfrom
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.
|
eseliger
approved these changes
May 2, 2020
Member
eseliger
left a comment
There was a problem hiding this comment.
This codebase becomes more and more modern :)
| options = Object.assign({}, options, { | ||
| scope: false | ||
| }); | ||
| options = { ...options, scope: false }; |
Member
There was a problem hiding this comment.
ideally parameters should be read-only, but that's another problem
Contributor
Author
There was a problem hiding this comment.
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.
sushantdhiman
approved these changes
May 3, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
This replaces most
Object.assignusage 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: