Skip to content

Report a package in multiple fixed or linked groups only once - #2282

Merged
Andarist merged 1 commit into
changesets:mainfrom
MaxFreedomPollard:report-duplicate-group-package-once
Sep 7, 2026
Merged

Andarist merged 1 commit into
changesets:mainfrom
MaxFreedomPollard:report-duplicate-group-package-once

Conversation

@MaxFreedomPollard

Copy link
Copy Markdown
Contributor

A project with three or more fixed or linked groups gets the "defined in multiple groups" config error printed once for every group that follows the duplicate. With fixed: [["pkg-a"], ["pkg-a"], ["pkg-b"]] the pkg-a message is printed twice, and adding a fourth group prints it three times.

The cause is in packages/config/src/rules.ts. noDuplicateFixedPackages (line 39) and noDuplicateLinkedPackages (line 79) collect duplicates into a duplicatedNames set, but the errors.push(...Array.from(duplicatedNames, ...)) call sits inside the loop over the groups, at line 52 and line 92. Every iteration re-emits a message for every name already in the set, so a name first seen twice while processing group 2 of 4 gets pushed by groups 2, 3 and 4. The two existing cases in packages/config/src/parse.test.ts use two groups, fixed: [["pkg-a"], ["pkg-a"]] and linked: [["pkg-a"], ["pkg-a"]], where the duplicate is in the last group and no later iteration exists to repeat it, and the table harness compares expected substrings positionally without checking how many errors came back, so neither case could catch this.

The fix moves both pushes out of the loop. Each duplicated package now produces exactly one error regardless of how many groups follow it. The set of names collected, the message text, and the early return when the group list is empty are all unchanged.

Two regression tests are added to the rules block of packages/config/src/parse.test.ts, one for fixed and one for linked, each asserting exactly one error for [["pkg-a"], ["pkg-a"], ["pkg-b"]]. Against unmodified rules.ts both fail with AssertionError: expected [ …(2) ] to have a length of 1 but got 2. With the fix, pnpm vitest run packages/config reports Test Files 2 passed (2) and Tests 65 passed (65).

Verified on macOS with Node 22.23.2 and pnpm 11.13.1. pnpm test run --maxWorkers=3 reports Test Files 41 passed (41) and Tests 916 passed | 2 skipped | 2 todo (920) in 130.94s, with no failures. pnpm types:check, pnpm lint and pnpm format each exit 0, with oxfmt --check reporting "All matched files use the correct format" across 298 files.

Changeset included, patch bump for @changesets/config.

`noDuplicateFixedPackages` and `noDuplicateLinkedPackages` in
packages/config/src/rules.ts push an error for every name accumulated in
`duplicatedNames` inside the loop over the groups, so once a name lands in that
set every later group pushes the same message again. A config with
`fixed: [["pkg-a"], ["pkg-a"], ["pkg-b"]]` prints the "pkg-a is defined in
multiple groups of fixed packages" error twice, and one more time for each
additional group. Two groups happened to be the only shape covered by the
tests, and that shape hides the bug because nothing follows the duplicate.

The push now happens after the loop, so each duplicated package produces exactly
one error no matter how many groups follow it.
@netlify

netlify Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for changesets ready!

Name Link
🔨 Latest commit 1aa8890
🔍 Latest deploy log https://app.netlify.com/projects/changesets/deploys/6a9ccdf7b0786b00081d0a2b
😎 Deploy Preview https://deploy-preview-2282--changesets.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@changeset-bot

changeset-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1aa8890

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@changesets/config Patch
@changesets/apply-release-plan Patch
@changesets/cli Patch
@changesets/get-release-plan Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.57%. Comparing base (d7e4a2d) to head (1aa8890).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2282   +/-   ##
=======================================
  Coverage   84.57%   84.57%           
=======================================
  Files          80       80           
  Lines        3177     3177           
  Branches      896      896           
=======================================
  Hits         2687     2687           
  Misses        433      433           
  Partials       57       57           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@43081j 43081j 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.

good catch!

@beeequeue beeequeue left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

while i do not appreciate fully automated prs like this, we don't have a policy against it (yet?) and the change makes sense.

@bluwy @Andarist

@Andarist
Andarist added this pull request to the merge queue Sep 7, 2026
@MaxFreedomPollard

Copy link
Copy Markdown
Contributor Author

How is it fully automated?

@MaxFreedomPollard

Copy link
Copy Markdown
Contributor Author

Not that it's a bad thing, I'm just wondering why you say that. I don't mind either way, it's your repo and I respect it oc

Merged via the queue into changesets:main with commit e522996 Sep 7, 2026
18 checks passed
@bluwy

bluwy commented Sep 7, 2026

Copy link
Copy Markdown
Member

Your PR description is overly verbose, we do not need to know the number of tests passed or what tests you've added. We can see on the GitHub UI and diff.

You've also opened 88 PRs in the last 2 days.

These kinds of contribution patterns just don't give confidence to any OSS maintainers.

@MaxFreedomPollard

MaxFreedomPollard commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor Author

I included that info so it can viewed at a glance. It's your preference, and it's now noted.

As for the large amount of PRs recently - I've only made one PR in this repository. What I do in other repositories, many of which are my own, is not your concern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants