P1B: Refactor (packages/ui/src/theme/v2/avatar.ts): Remove duplicated avatar token definitions - #49
Open
Rashidcmuq wants to merge 2 commits into
Open
Conversation
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.
Issue for this PR
Closes #47
Type of change
What does this PR do?
Qlty reported duplicated code between
V2_AVATAR_LIGHTandV2_AVATAR_DARKinpackages/ui/src/theme/v2/avatar.ts. I refactored the repeated avatar token structure into a shared helper function while keeping the same light and dark color values. This removes the duplication without changing the output of the avatar theme tokens.I also added tests for both the light and dark avatar tokens to make sure the refactor keeps the existing values.
How did you verify your code works?
I ran the tests for the UI package and the new avatar tests passed. I also generated a coverage report, which shows
src/theme/v2/avatar.tsat 100% function and line coverage.I reran Qlty on
packages/ui/src/theme/v2/avatar.tsafter the refactor and the duplicated-code smell is no longer reported.Commands used:
bun test ./src/theme/v2/avatar.test.tsbun testbun test --coverage --coverage-dir=./coverageqlty smells --no-snippets packages/ui/src/theme/v2/avatar.tsScreenshots / recordings
Before Qlty:

After Qlty:

Avatar tests passing:

UI package tests:

Test coverage:

Lint:

Checklist