Conversation
There was a problem hiding this comment.
Pull Request Overview
Refactors the mergeProps utility function by simplifying conditional logic and removing redundant checks for better maintainability.
- Removes redundant
undefinedcheck in the default case since it's already handled at the loop start - Simplifies style merging by removing null check and relying on spread operator behavior
- Improves code clarity without changing functionality
Comments suppressed due to low confidence (1)
src/utils/mergeProps/mergeProps.ts:53
- The
breakstatement on line 50 creates unreachable code on line 53. WhenmergedFunctionis truthy, the code will exit the switch case and never reach the assignmentprev[key] = curr[key]. Consider restructuring this logic or removing the unreachable code.
const mergedFunction = mergeFunction(prev[key], curr[key]);
if (mergedFunction) {
prev[key] = mergedFunction;
break;
}
prev[key] = curr[key];
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #279 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 37 37
Lines 1093 1092 -1
Branches 324 323 -1
=========================================
- Hits 1093 1092 -1 🚀 New features to boost your workflow:
|
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.
Overview
This PR improves the
mergePropsutility function by:Removing redundant checks for
undefinedin thepushPropfunction.Since the
if (curr[key] === undefined) continue;statement is already handled at the start of the loop, the additionalelse if (curr[key] !== undefined)check inside thedefaultcase is unnecessary and removed for clarity.Simplifying the
mergeStylefunction by removing the null check for the first style argument.In practice,
ais nevernullbut can beundefined.Spreading potentially
undefinedvalues with{ ...a, ...b }safely results in identical behavior without extra branching logic.These changes clean up the code, improve maintainability, and have no effect on the existing behavior or output of the utility.
Checklist
yarn run fixto format and lint the code and docs?yarn run test:coverageto confirm test coverage?