refactor: hold the named-parameter rule in the fixtures too - #180
Merged
Conversation
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 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.
Owner
Author
|
🎉 This PR is included in version 1.26.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Description
The named-parameter convention was already documented and already executable here —
docs/docs-consistency.test.tsasserted it. But the assertion excusedsrc/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)andrepoStargazers(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 ofsrc.Type of Change
Related Issue
None.
Changes Made
src/shared/tests/index.ts—MakeRepoInfoParams,MakeSnapshotParams,MakeMultiRepoSnapshotParams,MakeRepoResultParams.makeRepoInfoalone had 100 call sites, all converted in this commit.series,repoTotal,repoStargazers,makeStar,failGitWhen,makeStargazerResponse,publish, plus the two localmakeSnapshot/makeMultiRepoSnapshotinsvg-chart.test.tsthat shadow the shared ones.docs/docs-consistency.test.ts—WalkParams, 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
pnpm verify— 985 passed, 47 of them the docs contract)pnpm verifyends in the bundle)Screenshots (if applicable)
N/A.
Checklist
pnpm verifypasses)CLAUDE.mdmy change affects, in this same PRAdditional Notes
One function was deliberately left positional:
alphabeticallyin the docs contract. It is passed toArray.prototype.sort, which invokes a comparator with two positional arguments — destructuring it would hand itundefinedand break the sort silently. If the convention test is ever tightened further, that one needs an explicit carve-out rather than a conversion.makeHistorykeeps 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.