Skip to content

refactor: hold the named-parameter rule in the fixtures too - #180

Merged
fbuireu merged 3 commits into
mainfrom
refactor/named-parameters
Aug 23, 2026
Merged

refactor: hold the named-parameter rule in the fixtures too#180
fbuireu merged 3 commits into
mainfrom
refactor/named-parameters

Conversation

@fbuireu

@fbuireu fbuireu commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Description

The named-parameter convention was already documented and already executable here — docs/docs-consistency.test.ts asserted it. But the assertion excused src/shared/tests/ and every co-located .test.ts, and that exemption is exactly where the rule had drifted.

That is the wrong half to excuse. makeRepoInfo(name, stars, overrides) and repoStargazers(fullName, dates, sampled) are precisely the shapes a caller transposes without the compiler noticing, and a fixture factory is the code a reader copies from when writing the next test.

Fourteen helpers now take one destructured object typed as Params, and the exemption is gone from the test, so the rule now covers all of src.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation update
  • 🔧 Configuration change
  • ♻️ Code refactoring
  • ⚡ Performance improvement
  • ✅ Test update

Related Issue

None.

Changes Made

  • src/shared/tests/index.tsMakeRepoInfoParams, MakeSnapshotParams, MakeMultiRepoSnapshotParams, MakeRepoResultParams. makeRepoInfo alone had 100 call sites, all converted in this commit.
  • Nine co-located helpersseries, repoTotal, repoStargazers, makeStar, failGitWhen, makeStargazerResponse, publish, plus the two local makeSnapshot / makeMultiRepoSnapshot in svg-chart.test.ts that shadow the shared ones.
  • docs/docs-consistency.test.tsWalkParams, and the convention test drops its .test.ts / src/shared/tests/ exemption.
  • CLAUDE.md — the bullet no longer calls the fixtures a sanctioned exception, because they no longer are.

Testing

  • Existing unit tests pass (pnpm verify — 985 passed, 47 of them the docs contract)
  • Added new tests for changes
  • Manually tested in browser
  • Build passes (pnpm verify ends in the bundle)

Screenshots (if applicable)

N/A.

Checklist

  • My code follows the style guidelines of this project (pnpm verify passes)
  • I have performed a self-review of my own code
  • My change carries no inline comments
  • I updated any CLAUDE.md my change affects, in this same PR
  • My changes generate no new warnings or errors
  • New and existing unit tests pass locally with my changes

Additional Notes

One function was deliberately left positional: alphabetically in the docs contract. It is passed to Array.prototype.sort, which invokes a comparator with two positional arguments — destructuring it would hand it undefined and break the sort silently. If the convention test is ever tightened further, that one needs an explicit carve-out rather than a conversion.

makeHistory keeps its (starCounts, { startMs, stepDays }) hybrid: the first argument is the subject and the second is an options bag it already names. Converting it is defensible under a strict reading of the rule — flagging it rather than deciding it here.

No behaviour changes anywhere; every converted declaration has its call sites converted in the same commit, which is why the suite passing is the proof.

The convention was already asserted, but the assertion excused
src/shared/tests and every co-located .test.ts — which is where it had
drifted. makeRepoInfo(name, stars, overrides) and repoStargazers(fullName,
dates, sampled) are precisely the shapes a caller transposes without the
compiler noticing, and a fixture is the code a reader copies from.

Fourteen helpers now take one destructured object typed as
<FunctionName>Params, with their call sites converted in the same commit
— makeRepoInfo alone had 100. The exemption is gone from the test, so
the rule now covers all of src.

alphabetically stays positional on purpose: Array.prototype.sort calls a
comparator with two arguments and would hand it undefined otherwise.
@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…tures demanding a rebuild

CLAUDE.md already said the object is 'typed by an interface' and the
conversion used type aliases, so the code contradicted its own guide on
the very rule it was enforcing. All fourteen are interfaces now, and
CONTRIBUTING states the rule with the comparator exception rather than
one line saying 2+ parameters should be destructured.

The dist staleness check counted src/shared/tests as a bundled source.
It is not: nothing there is reachable from src/index.ts, which a rebuild
proves — the bundle is byte-identical after this change. Editing a
fixture therefore failed a PR by demanding a rebuild that could not
produce a diff. It is now excluded alongside *.test.ts, and both guides
say so.
Same rule, same words, and the same shape of example — the positional
one-argument case beside the object one, with the interface named after
the function rather than the concept. The contract also asserts the
guide states it, so deleting the bullet fails a pull request instead of
leaving an assertion policing a rule nobody wrote down.
@fbuireu
fbuireu merged commit f42cb6c into main Aug 23, 2026
12 checks passed
@fbuireu
fbuireu deleted the refactor/named-parameters branch August 23, 2026 08:05
@fbuireu

fbuireu commented Aug 23, 2026

Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 1.26.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant