Repository navigation
fix(lint): apply the review fixes to the six rebuild rules - #342
Merged
Merged
Conversation
present(value) now fails a test on null or undefined only, and the new unwrap(outcome) takes only a success or failure outcome and fails the test with the failure. The api test unwraps its outcomes with unwrap(), a unit test holds the E2E fixtures copy of present() to the Jest global's behaviour, and policy/test-unwraps-values names the helper that fits. Refs #337
The web and api programs now exclude test files, and two test programs, tsconfig.test.json and tsconfig.api.test.json, check them with the present() and unwrap() declarations, so a production module that calls either fails pnpm typecheck with TS2304. The showcase inclusion test seeds that call in a web and an api module to prove it. Refs #337
one-status-from-hooks now counts only roots bound by a const to useQuery, useSuspenseQuery or useInfiniteQuery, reads the status inside a lookup such as LIST_STATES[list.status] (r7 and r8), and leaves error and isFetching out of the count. It and keep-rejections resolve each name through the scope chain instead of a file-wide map, so a same-named binding in another function no longer decides the result. Fixtures cover r7, r8, the four reviewed false positives and shadowed names. Refs #337
The rule now considers module constants named as a limit (MAX, MIN, LIMIT, LENGTH and their kin, in snake or camel case) and matches the number only when a word follows it, in plain or grouped form such as 1,000. It skips JSX attribute values and import sources. Fixtures cover a grouped count, JSX text, and the reviewed false positives: COLUMNS with gap-10, ICON_SIZE with a viewBox, MAX_PERCENT with 100%, PORT in a URL and PAGE_SIZE beside "Ages 20 and over". Refs #337
test-unwraps-values reports an x.ok ternary only when its other branch reads x.value, so response.ok ? 'passed' : 'failed' passes. test-imports-the-type anchors its export pattern to the start of a line, so text in strings and comments no longer counts, and scans each folder once until a module in it changes. Fixtures and a unit test cover both. Refs #337
The rule bans every re-export in a slice module, not only types, so its name now says that. It also stops exempting a nested index file: only the slice's own index.ts is a public surface, as no-restricted-imports already holds, so src/routes/todos/components/index.ts fails too. No rebuild had a nested barrel. The ADR, conventions and architecture rows use the new name. Refs #337
keep-rejections now tells the reader to settle a promise with Promise.allSettled when ignoring its failure is intended, and the ADR and conventions show both forms, which pass lint:policy, lint:anti-slop and Biome. The ADR drops the zero false-positive claim and the note about pre-commit, which PR #340 changes, and records r7 and r8 and the five shapes review found. Refs #337
8 tasks done
Contributor
Enforcement sign-offRan at Sunday, the 8th of November, at 11:16 pm on commit This PR changes gated enforcement or product intent, so it needs sign-off.
@BenSheridanEdwards: tick to approve.
|
BenSheridanEdwards
merged commit Nov 8, 2026
d10b37f
into
feat/todo-example-app
20 of 21 checks passed
This was referenced Nov 8, 2026
BenSheridanEdwards
added a commit
that referenced
this pull request
Nov 10, 2026
* feat(lint): add six policy rules mined from nine agent rebuilds Extracts the rules from #341 and its review fixes (#342 and the follow-ups on feat/todo-example-app) onto main, so #337 closes without the to-do app. - tooling/oxlint-plugin-policy.js: one-status-from-hooks, test-unwraps-values, test-imports-the-type, message-uses-its-limit, reexport-only-from-index and keep-rejections, at error in the result-root override; test-unwraps-values also runs on web/e2e. - present() and unwrap() as Jest test globals typed only for the two new test type programs, and as five-line helpers in e2e/fixtures.ts. - ADR 0124 records the rules, their limits and the fixtures. - The greeting reference had one hit: useGreeting dropped its record rejection with .catch(() => undefined); it now settles the promise with Promise.allSettled. Closes #337 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(lint): apply the first review's findings to the rebuild rules - message-uses-its-limit: a limit after -, / or : is part of a class name, fraction or time, so 'gap-10 px-4' beside MAX_ITEMS = 10 passes. A fixture pins it and fails on the old pattern. - Web contract tests type-check in a new tsconfig.node.test.json that sees the test globals; tsconfig.node.json keeps e2e specs, which run in Playwright, away from them. - The Jest types move from tsconfig.json and tsconfig.api.json to the test programs, so production code cannot call expect or jest. - ADR 0124 records the class-name pass and that test-imports-the-type matches a type by name across the folder. - The docs and North Star name the seven type programs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(lint): apply the second review's findings to the rebuild rules - one-status-from-hooks reads a name destructured from a query (const { data, isError } = useQuery(...)) and an index into a field (list.data?.[0]) as reads of that query; both had passed. - message-uses-its-limit skips a limit after $, so 'Save $10 today' passes; ADR 0124 records that a limit of 10 still matches prose such as 'Step 10 of 12'. - test-imports-the-type skips a broken link or a folder named like a module when it scans a test's folder, instead of throwing. - QUALITY_GATES and test-globals.d.ts say exactly what the test programs alone see: the globals, with no Jest types in web or api. Each new fixture fails on the previous plugin and passes on this one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why does this feature exist?
present()mixed two jobs and leaked into production types,one-status-from-hooksmissed the r7 and r8 lookup variant and flagged four valid shapes,message-uses-its-limitmatched any number, two rules resolved names file-wide, and the ADR overclaimed. feat(lint): add six policy rules mined from nine agent rebuilds #341 was merged intofeat/todo-example-appbefore the fixes landed, so this follow-up carries all twelve review findings (Refs lint: six policy rules mined from nine agent rebuilds #337).feat/todo-example-app, which now holds feat(lint): add six policy rules mined from nine agent rebuilds #341 as9660953). Merge order: feat: replace the greeting with a to-do reference app #335, then this PR, then feat(lint): make Oxlint own all code lint and run every lint gate at pre-commit #340, which renumbers its ADRs to 0125 and 0126.What changed?
One idea above 400 lines: the review fixes for the six rebuild rules, with a red fixture for each new edge case; about 300 of the 722 added lines are lint fixtures in
scripts/oxlint-policy.test.ts, 170 are rule code and 100 are ADR and docs.present()andunwrap()split (tooling/jest/test-globals.ts):present(value)fails the test onnullorundefinedonly;unwrap(outcome)takes onlySuccess<V> | Failureand fails the test with the failure.application.test.tsusesunwrap()for outcomes, a unit test holds the E2E fixtures copy ofpresent()to the same behaviour, and the Jest setup import moves to the top.tsconfig.jsonandtsconfig.api.jsonexclude test files and drop the declaration file; two new programs,tsconfig.test.jsonandtsconfig.api.test.json, check the tests withtooling/types/test-globals.d.ts.pnpm typecheckruns six programs. The showcase inclusion test seeds a production call to each helper and expects TS2304.one-status-from-hooks: counts only roots bound byconst x = useQuery | useSuspenseQuery | useInfiniteQuery(...)(or a client'sx.useQuery()), reads the status key inside a lookup (LIST_STATES[list.status], r7 and r8), and leaveserrorandisFetchingout of the count.one-status-from-hooksandkeep-rejectionsresolve each name throughsourceCode.getScopeinstead of a file-wide map.message-uses-its-limit: only constants named as a limit (MAX,MIN,MAXIMUM,MINIMUM,LIMIT,LENGTH,LEN, snake or camel case); the number must be followed by a word, plain or grouped (1,000); JSX attribute values and import sources are skipped.test-unwraps-values: reports anx.okternary only when its other branch readsx.value…; the message namespresent()orunwrap()as fits.test-imports-the-type: export pattern anchored to the start of a line (/^export…/gm); each folder is scanned once until a module in it changes (exportedsiblingTypes, unit-tested).keep-rejections: the message, ADR and conventions name the sanctioned way to ignore a failure on purpose,void Promise.allSettled([prefetch()])orPromise.allSettled([save()]).then(([result]) => result?.status === 'fulfilled'); a fixture and a receipt show it passeslint:policy,lint:anti-slopand Biome.policy/import-types-from-their-owneris nowpolicy/reexport-only-from-index, and the nested-index exemption is removed: only the slice's ownindex.tsmay re-export (no rebuild had a nested barrel).oxlint.config.ts(rule rename) andtooling/oxlint-plugin-policy.jschange, soenforcement-approvalwaits for the maintainer's tick. Nothing is loosened beyond the reviewed false positives.Behavioural Proof (with video and screenshots)
one-status-from-hooksr1 1, r2 1, r3 1, r4 1, r5 1, r6 1, r7 1, r8 1 (r7 and r8 are the lookup variant, new);test-unwraps-valuesr1 11, r2 5, r3 5, r4 7, r5 11, r6 8, r7 9, r8 10;test-imports-the-typer1 1, r4 1, r5 1;message-uses-its-limitr1 2, r4 2, r5 2, r7 1, r8 2;reexport-only-from-indexr1 1, r2 1, r4 1, r6 1;keep-rejectionsr2 1, r4 2. The r1 to r6 hits match the earlier reviewed receipt line for line (69 of 69), every r7 and r8 hit was read and is the targeted pattern, and the reference (apps/,packages/;showcase/is absent) has zero.Verification Summary
7e6be1216592fc2980d5e4b29fab4ccbf2b3eeaapnpm verify,pnpm e2e): red runs ofjest scripts/oxlint-policy.test.ts,tooling/jest/test-globals.test.ts,scripts/typecheck.test.tsandtooling/trial/inclusion.test.tsbefore each fix;pnpm typecheckwith a seeded production call (TS2304 forpresentandunwrap);pnpm verify;pnpm e2e; the real pre-push hook (pnpm verifyandpnpm e2e,PACT_DIRset) on the push of791697c.pnpm verifypasses in the pre-push hook (79 suites, 2994 Jest tests; contract, integration, changed-file coverage, build and size).pnpm e2epasses 44 tests.pnpm lint:policycommand, median of 15 alternating rounds on the same tree: 0.773 s with feat: replace the greeting with a to-do reference app #335's rules before feat(lint): add six policy rules mined from nine agent rebuilds #341, 0.755 s with feat(lint): add six policy rules mined from nine agent rebuilds #341 as merged, 0.766 s with these fixes (within run-to-run noise)..agents/project/PR_QUALITY.md) satisfied, or each gap named: satisfied locally;enforcement-approvalwaits for the maintainer's tick on the guarded lint files.pnpm verifypnpm e2e.agents/project/ARCHITECTURE.mdandCONVENTIONS.md; new decisions recorded as ADRs.main. Readiness here is measured againstfeat/todo-example-app.one-status-from-hooksleavesdatabesideerrorto review and reads only the returned object;message-uses-its-limitskips JSX attributes, so aplaceholderrestating a limit passes;test-unwraps-valuesleaves fallbacks such as?? 'waiting'to review.docs/NORTH_STAR.mdstill says strict TypeScript runs over four programs; it is product intent that needs sign-off, so this PR leaves it for the maintainer.test-imports-the-typekeys on file names and modification times, so an edit within the same millisecond as the previous scan could read stale exports in a long-lived editor session; a CLI run is unaffected.PRD Behaviours to Review
docs/prd/todos.md: Shows a loading message until the list arrives. Evidence:todos.spec.tstest "shows a loading message until the list arrives" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Opens on the All filter, with an empty message and a disabled Clear done when there are no to-dos. Evidence:todos.spec.tstest "starts on the All filter with an empty message when there are no to-dos";todos.spec.tstest "returns to the All filter when the page reloads" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Says so when the list fails to load. Evidence:todos.spec.tstest "says so when the list fails to load" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Shows only the parts listed above. Evidence:todos.spec.tstest "shows only the parts the PRD lists";todos.spec.tstest "shows a title message and a failure where the PRD puts them" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Adds a to-do to the end of the list. Evidence:todos.spec.tstest "adds a to-do to the end of the list" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Stores and shows each title normalised. Evidence:todos.spec.tstest "stores and shows a title with its whitespace normalised" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: The api normalises every title it receives. Evidence:todos.spec.tstest "the api normalises a title from any client" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Rejects a blank or over-long title and sends nothing. Evidence:todos.spec.tstest "asks for a title and sends nothing when the title is blank";todos.spec.tstest "rejects a title over 100 characters and sends nothing" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Clears the title message once the title is fixed. Evidence:todos.spec.tstest "clears the title message once the title is fixed" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Accepts a title of exactly 100 characters, counted after normalising. Evidence:todos.spec.tstest "accepts a title of exactly 100 characters after normalising" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: The api rejects an invalid title as a bad request. Evidence:todos.spec.tstest "the api rejects a blank or over-long title as a bad request" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: The api answers each procedure as The api table says. Evidence:todos.spec.tstest "the api lists to-dos oldest first";todos.spec.tstest "the api answers each change with its result";todos.spec.tstest "the api answers not found for an unknown to-do" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Shows an add only once the api has answered and the list is re-read. Evidence:todos.spec.tstest "shows an add only once the api has answered and the list is re-read" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Keeps the typed title and says so when adding fails. Evidence:todos.spec.tstest "keeps the typed title and says so when adding fails" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Marks a to-do done and active again, in place. Evidence:todos.spec.tstest "marks a to-do done and active again in place" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Disables every change control while a change waits. Evidence:todos.spec.tstest "disables every change control while a change waits" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Leaves the to-do unchanged and says so when marking it fails. Evidence:todos.spec.tstest "leaves the to-do unchanged and says so when marking it fails" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Edits a title in place, normalised. Evidence:todos.spec.tstest "edits a title in place and normalises it" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Cancels an edit without saving. Evidence:todos.spec.tstest "cancels an edit without saving" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Checks an edited title like a new one. Evidence:todos.spec.tstest "checks an edited title like a new one" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Edits one to-do at a time. Evidence:todos.spec.tstest "edits one to-do at a time" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Keeps the edit open and says so when saving fails. Evidence:todos.spec.tstest "keeps the edit open with the typed title and says so when saving fails" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Deletes a to-do at once. Evidence:todos.spec.tstest "deletes a to-do at once" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Keeps the to-do and says so when deleting fails. Evidence:todos.spec.tstest "keeps the to-do and says so when deleting fails" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Filters to active or done to-dos and back to all, and shows which filter is selected. Evidence:todos.spec.tstest "filters to active or done to-dos and back to all";todos.spec.tstest "shows the selected filter in the focus colour";todos.spec.tstest "hides a to-do from the Active filter once it is marked done";todos.spec.tstest "shows the empty message when a filter matches nothing" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Clears every done to-do, whatever the filter, and only while one is done. Evidence:todos.spec.tstest "clears every done to-do whatever the filter";todos.spec.tstest "enables Clear done only while a to-do is done" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Keeps the done to-dos and says so when clearing fails. Evidence:todos.spec.tstest "keeps the done to-dos and says so when clearing fails" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Shows only the latest failure, until the next change starts. Evidence:todos.spec.tstest "shows only the latest failure and clears it when the next change starts" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Says so when the list fails to load after a change. Evidence:todos.spec.tstest "says so when the list fails to load after a change" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Reads the list when the page opens and after each successful change. Evidence:todos.spec.tstest "reads the list only when the page opens and after a successful change" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.docs/prd/todos.md: Passes the automated WCAG 2.1 A/AA scan. Evidence:accessibility.spec.tstest "the empty to-do page has no detectable WCAG A/AA violations";accessibility.spec.tstest "the to-do list has no detectable WCAG A/AA violations";accessibility.spec.tstest "the validation error state has no detectable WCAG A/AA violations";accessibility.spec.tstest "an open edit has no detectable WCAG A/AA violations" passes inpnpm e2eat791697c(44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.PR Proof Law
.agents/project/PR_QUALITY.mdand.agents/skills/pr-quality-contract/SKILL.md; thePR qualitycheck verifies the proof format.