Skip to content

fix(color): give the LCH hue its full 360 degree range - #3978

Merged
ST-DDT merged 4 commits into
faker-js:nextfrom
UlikGames:fix/3956-lch-hue-range
Aug 9, 2026
Merged

ST-DDT merged 4 commits into
faker-js:nextfrom
UlikGames:fix/3956-lch-hue-range

Conversation

@UlikGames

Copy link
Copy Markdown
Contributor

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.

@UlikGames
UlikGames requested a review from a team as a code owner August 3, 2026 18:35
@netlify

netlify Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for fakerjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit a7992b9
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/6a775ae3979a260008e3a800
😎 Deploy Preview https://deploy-preview-3978.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.91%. Comparing base (d4b35a4) to head (a7992b9).

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              
Files with missing lines Coverage Δ
src/modules/color/module.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@ST-DDT ST-DDT added c: bug Something isn't working p: 1-normal Nothing urgent m: color Something is referring to the color module labels Aug 3, 2026
@ST-DDT ST-DDT added this to the v10.x milestone Aug 3, 2026
@ST-DDT ST-DDT linked an issue Aug 3, 2026 that may be closed by this pull request
8 tasks done
@ST-DDT
ST-DDT requested a review from Copilot August 3, 2026 19:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with max: 360 while keeping chroma capped at 230.
  • 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.

Comment thread src/modules/color/module.ts
Comment thread test/modules/color.spec.ts Outdated
@ST-DDT
ST-DDT added this pull request to the merge queue Aug 9, 2026
Merged via the queue into faker-js:next with commit 1ce5994 Aug 9, 2026
23 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: bug Something isn't working m: color Something is referring to the color module p: 1-normal Nothing urgent

4 participants