fix(color): give the LCH hue its full 360 degree range - #3978
Merged
Merged
Conversation
✅ Deploy Preview for fakerjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #3978 +/- ##
==========================================
- Coverage 98.92% 98.91% -0.01%
==========================================
Files 926 926
Lines 3241 3239 -2
Branches 588 588
==========================================
- Hits 3206 3204 -2
Misses 31 31
Partials 4 4
🚀 New features to boost your workflow:
|
8 tasks done
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes faker.color.lch() so the hue component uses its correct angular range (0–360°) instead of being incorrectly capped at 230 (the chroma bound), aligning behavior with LCH semantics and the reported bug in #3956.
Changes:
- Update
ColorModule.lch()to generate hue withmax: 360while keeping chroma capped at230. - Update LCH range assertions in tests to validate distinct bounds for lightness/chroma/hue.
- Refresh seeded snapshots impacted by the corrected hue scaling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/modules/color/module.ts |
Fixes LCH hue generation to use a 0–360 range (while keeping chroma capped at 230). |
test/modules/color.spec.ts |
Updates LCH tests to assert correct per-component bounds and adds a check that hue can exceed 230. |
test/modules/__snapshots__/color.spec.ts.snap |
Updates seeded LCH snapshots reflecting the corrected hue range. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ST-DDT
reviewed
Aug 3, 2026
ST-DDT
approved these changes
Aug 3, 2026
Shinigami92
approved these changes
Aug 8, 2026
kkennethlau12393
pushed a commit
to kkennethlau12393/faker-js__faker
that referenced
this pull request
Sep 3, 2026
kkennethlau12393
pushed a commit
to kkennethlau12393/faker-js__faker
that referenced
this pull request
Sep 5, 2026
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.
Part of #3956 - this one tackles the first of two bugs mentioned, while the alpha fix is in another PR, just like asked.
So here’s the deal: the
lch()function used to cap hue at 230, borrowing chroma’s limit. But hue’s an angle - it should spin the full 0 to 360. Before, you’d never get random hues past 230. Now? Full circle. Old values are scaled up by 360/230 to keep things consistent. Lightness and chroma? No changes there - they’re still playing by the same rules.Tests got a refresh too. The old ones capped everything at 230, which actually mirrored the bug. Now each component has its proper range, and we’ve added a check to make sure hue can definitely go above 230 - no more holding back.
Three seeded snapshots changed, but only in hue - all updated using that same 360/230 multiplier. Draw order? Still totally untouched.
All preflight checks passed: locale sync, docs, formatting, linting, build, full test run, type checks - you name it. Only one test still flakes:
test/docs/versions.spec.ts. It fails trying to read git tags because I cloned with--depth 1, but guess what? It fails the exact same way even without my changes. So yeah, 52,733 tests passing - solid.