Skip to content

fix(lint): apply the review fixes to the six rebuild rules - #342

Merged
BenSheridanEdwards merged 7 commits into
feat/todo-example-appfrom
fix/slop-rules-review
Nov 8, 2026
Merged

BenSheridanEdwards merged 7 commits into
feat/todo-example-appfrom
fix/slop-rules-review

Conversation

@BenSheridanEdwards

Copy link
Copy Markdown
Owner

Why does this feature exist?

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() and unwrap() split (tooling/jest/test-globals.ts): present(value) fails the test on null or undefined only; unwrap(outcome) takes only Success<V> | Failure and fails the test with the failure. application.test.ts uses unwrap() for outcomes, a unit test holds the E2E fixtures copy of present() to the same behaviour, and the Jest setup import moves to the top.
  • Test globals stay out of production types: tsconfig.json and tsconfig.api.json exclude test files and drop the declaration file; two new programs, tsconfig.test.json and tsconfig.api.test.json, check the tests with tooling/types/test-globals.d.ts. pnpm typecheck runs six programs. The showcase inclusion test seeds a production call to each helper and expects TS2304.
  • one-status-from-hooks: counts only roots bound by const x = useQuery | useSuspenseQuery | useInfiniteQuery(...) (or a client's x.useQuery()), reads the status key inside a lookup (LIST_STATES[list.status], r7 and r8), and leaves error and isFetching out of the count.
  • Scope resolution: one-status-from-hooks and keep-rejections resolve each name through sourceCode.getScope instead 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 an x.ok ternary only when its other branch reads x.value…; the message names present() or unwrap() 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 (exported siblingTypes, unit-tested).
  • keep-rejections: the message, ADR and conventions name the sanctioned way to ignore a failure on purpose, void Promise.allSettled([prefetch()]) or Promise.allSettled([save()]).then(([result]) => result?.status === 'fulfilled'); a fixture and a receipt show it passes lint:policy, lint:anti-slop and Biome.
  • Rename: policy/import-types-from-their-owner is now policy/reexport-only-from-index, and the nested-index exemption is removed: only the slice's own index.ts may re-export (no rebuild had a nested barrel).
  • ADR 0124 (number kept): the zero false-positive claim and the pre-commit sentence go; it records r7 and r8, the five shapes review found and the remaining trade-offs.
  • Guarded files: oxlint.config.ts (rule rename) and tooling/oxlint-plugin-policy.js change, so enforcement-approval waits for the maintainer's tick. Nothing is loosened beyond the reviewed false positives.

Behavioural Proof (with video and screenshots)

  • Video: Not applicable: lint rules, test helpers and type-check configuration; the app renders and behaves exactly as on feat: replace the greeting with a to-do reference app #335.
  • Screenshots: Not applicable: nothing user-visible changed, so there is no new screen state to capture.
  • Behaviour tests: red first for each edge case, receipts kept with the run. Final plugin over the reference and eight to-do rebuild clones, hits per rule: one-status-from-hooks r1 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-values r1 11, r2 5, r3 5, r4 7, r5 11, r6 8, r7 9, r8 10; test-imports-the-type r1 1, r4 1, r5 1; message-uses-its-limit r1 2, r4 2, r5 2, r7 1, r8 2; reexport-only-from-index r1 1, r2 1, r4 1, r6 1; keep-rejections r2 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.
  • E2E mapping: unchanged. No E2E spec or fixture changed; all 44 E2E tests pass.

Verification Summary

  • Head commit: 791697c
  • PRDs checked: docs/prd/todos.md
  • PRD impact: No behaviour change: only test helpers, lint rules and one api unit test changed, so every promise and its proof stays as feat: replace the greeting with a to-do reference app #335 left it.
  • North Star commit: 7e6be1216592fc2980d5e4b29fab4ccbf2b3eeaa
  • Commands run (e.g. pnpm verify, pnpm e2e): red runs of jest scripts/oxlint-policy.test.ts, tooling/jest/test-globals.test.ts, scripts/typecheck.test.ts and tooling/trial/inclusion.test.ts before each fix; pnpm typecheck with a seeded production call (TS2304 for present and unwrap); pnpm verify; pnpm e2e; the real pre-push hook (pnpm verify and pnpm e2e, PACT_DIR set) on the push of 791697c.
  • Results: pnpm verify passes in the pre-push hook (79 suites, 2994 Jest tests; contract, integration, changed-file coverage, build and size). pnpm e2e passes 44 tests. pnpm lint:policy command, 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).
  • Definition of Done (.agents/project/PR_QUALITY.md) satisfied, or each gap named: satisfied locally; enforcement-approval waits for the maintainer's tick on the guarded lint files.
  • pnpm verify
  • pnpm e2e
  • Behaviour is covered by the E2E map when user-visible behaviour changed.
  • Logic is unit-tested where logic changed.
  • Accessibility considered and verified for interactive/UI changes.
  • The diff follows .agents/project/ARCHITECTURE.md and CONVENTIONS.md; new decisions recorded as ADRs.
  • No gates were bypassed or weakened.
  • Known risks or skipped checks (with reason, risk, and rollback):
    • Stacked on feat: replace the greeting with a to-do reference app #335: merge feat: replace the greeting with a to-do reference app #335 first; GitHub then retargets this PR to main. Readiness here is measured against feat/todo-example-app.
    • Remaining trade-offs, recorded in ADR 0124: one-status-from-hooks leaves data beside error to review and reads only the returned object; message-uses-its-limit skips JSX attributes, so a placeholder restating a limit passes; test-unwraps-values leaves fallbacks such as ?? 'waiting' to review.
    • docs/NORTH_STAR.md still says strict TypeScript runs over four programs; it is product intent that needs sign-off, so this PR leaves it for the maintainer.
    • The folder scan cache in test-imports-the-type keys 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.
    • Rollback: revert the merge commit; the rules, helpers, type programs and docs go together.

PRD Behaviours to Review

  • docs/prd/todos.md: Shows a loading message until the list arrives. Evidence: todos.spec.ts test "shows a loading message until the list arrives" passes in pnpm e2e at 791697c (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.ts test "starts on the All filter with an empty message when there are no to-dos"; todos.spec.ts test "returns to the All filter when the page reloads" passes in pnpm e2e at 791697c (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.ts test "says so when the list fails to load" passes in pnpm e2e at 791697c (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.ts test "shows only the parts the PRD lists"; todos.spec.ts test "shows a title message and a failure where the PRD puts them" passes in pnpm e2e at 791697c (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.ts test "adds a to-do to the end of the list" passes in pnpm e2e at 791697c (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.ts test "stores and shows a title with its whitespace normalised" passes in pnpm e2e at 791697c (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.ts test "the api normalises a title from any client" passes in pnpm e2e at 791697c (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.ts test "asks for a title and sends nothing when the title is blank"; todos.spec.ts test "rejects a title over 100 characters and sends nothing" passes in pnpm e2e at 791697c (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.ts test "clears the title message once the title is fixed" passes in pnpm e2e at 791697c (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.ts test "accepts a title of exactly 100 characters after normalising" passes in pnpm e2e at 791697c (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.ts test "the api rejects a blank or over-long title as a bad request" passes in pnpm e2e at 791697c (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.ts test "the api lists to-dos oldest first"; todos.spec.ts test "the api answers each change with its result"; todos.spec.ts test "the api answers not found for an unknown to-do" passes in pnpm e2e at 791697c (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.ts test "shows an add only once the api has answered and the list is re-read" passes in pnpm e2e at 791697c (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.ts test "keeps the typed title and says so when adding fails" passes in pnpm e2e at 791697c (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.ts test "marks a to-do done and active again in place" passes in pnpm e2e at 791697c (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.ts test "disables every change control while a change waits" passes in pnpm e2e at 791697c (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.ts test "leaves the to-do unchanged and says so when marking it fails" passes in pnpm e2e at 791697c (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.ts test "edits a title in place and normalises it" passes in pnpm e2e at 791697c (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.ts test "cancels an edit without saving" passes in pnpm e2e at 791697c (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.ts test "checks an edited title like a new one" passes in pnpm e2e at 791697c (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.ts test "edits one to-do at a time" passes in pnpm e2e at 791697c (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.ts test "keeps the edit open with the typed title and says so when saving fails" passes in pnpm e2e at 791697c (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.ts test "deletes a to-do at once" passes in pnpm e2e at 791697c (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.ts test "keeps the to-do and says so when deleting fails" passes in pnpm e2e at 791697c (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.ts test "filters to active or done to-dos and back to all"; todos.spec.ts test "shows the selected filter in the focus colour"; todos.spec.ts test "hides a to-do from the Active filter once it is marked done"; todos.spec.ts test "shows the empty message when a filter matches nothing" passes in pnpm e2e at 791697c (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.ts test "clears every done to-do whatever the filter"; todos.spec.ts test "enables Clear done only while a to-do is done" passes in pnpm e2e at 791697c (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.ts test "keeps the done to-dos and says so when clearing fails" passes in pnpm e2e at 791697c (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.ts test "shows only the latest failure and clears it when the next change starts" passes in pnpm e2e at 791697c (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.ts test "says so when the list fails to load after a change" passes in pnpm e2e at 791697c (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.ts test "reads the list only when the page opens and after a successful change" passes in pnpm e2e at 791697c (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.ts test "the empty to-do page has no detectable WCAG A/AA violations"; accessibility.spec.ts test "the to-do list has no detectable WCAG A/AA violations"; accessibility.spec.ts test "the validation error state has no detectable WCAG A/AA violations"; accessibility.spec.ts test "an open edit has no detectable WCAG A/AA violations" passes in pnpm e2e at 791697c (44 passed); this PR changes no app code or E2E spec, only how one api unit test unwraps outcomes.

PR Proof Law

  • I followed .agents/project/PR_QUALITY.md and .agents/skills/pr-quality-contract/SKILL.md; the PR quality check verifies the proof format.

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
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Enforcement sign-off

Ran at Sunday, the 8th of November, at 11:16 pm on commit 791697c.

This PR changes gated enforcement or product intent, so it needs sign-off.

File What changed How it affects
oxlint.config.ts Turns on the lint rule at error: policy/reexport-only-from-index; Stops configuring the lint rule policy/import-types-from-their-owner (was error) The named lint rules run at the stated severity; warnings and errors block verification
tooling/oxlint-plugin-policy.js Adds the lint rule reexport-only-from-index; Removes the lint rule import-types-from-their-owner Adds rule implementations available to the lint configuration; configured severities decide whether they block

@BenSheridanEdwards: tick to approve.

  • Approve these enforcement changes at 791697c ticked by Ben Sheridan Edwards at Sunday, the 8th of November, at 11:16 pm (@BenSheridanEdwards)

@github-actions github-actions Bot added confidence: red A required gate is failing or pending, or evidence is unavailable. confidence: green Required gates, slice E2E/PRDs, unit line coverage and import blast radius passed. and removed confidence: red A required gate is failing or pending, or evidence is unavailable. labels Nov 8, 2026
@BenSheridanEdwards
BenSheridanEdwards merged commit d10b37f into feat/todo-example-app Nov 8, 2026
20 of 21 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

confidence: green Required gates, slice E2E/PRDs, unit line coverage and import blast radius passed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant