Repository navigation
feat(lint): add six policy rules mined from nine agent rebuilds - #341
Merged
Merged
Conversation
A test that needs a value it cannot prove is there wrote `?? ''` or `x.ok ? x.value.id : ''`, so a missing value turned into a call with an empty string. present() returns a defined value or the value of an ok outcome, and throws otherwise, so the test fails where it read the value. The Jest setup makes it a global, because a unit test in a package imports nothing from outside that package. Refs #337
The api application test and the E2E spec fell back to `''` when an id was missing, so a broken setup sent an empty id on. They now unwrap each id with present(). A showcase copies the reference's e2e folder, so `e2e/fixtures.ts` holds its own present() for defined values rather than reaching into tooling/. The page test restated `Todo`; it imports the type from `./useTodos`, so the fake api follows the real shape. Refs #337
Every rebuild of the reference feature passed every gate and still carried patterns a reviewer rejects. These six recurred and need no type information, so they fail lint now: - one-status-from-hooks: a hook returns one status union, not a query's data and flags as separate fields. - test-unwraps-values: a test unwraps with present(), not `?? ''` or an `x.ok ? ... : ''` stand-in. It also runs on E2E specs. - test-imports-the-type: a test imports a type its folder exports. - message-uses-its-limit: a message interpolates its limit constant. - import-types-from-their-owner: only a slice's index.ts re-exports. - keep-rejections: a .catch or .then handler keeps the rejection instead of returning a literal. Each rule has failing and passing fixtures taken from the rebuilds, runs in every result root, and states its fix in check:docs phrasing. Refs #337
CONVENTIONS.md lists each new rule beside the convention it enforces, and ARCHITECTURE.md adds the slice re-export rule to its rule table. ADR 0124 records why these six, their scopes, the present() helper and the trade-offs that keep their false-positive rate at zero. Refs #337
Contributor
Enforcement sign-offRan at Sunday, the 8th of November, at 10:59 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
9660953
into
feat/todo-example-app
20 of 21 checks passed
8 tasks done
Owner
Author
8 tasks done
BenSheridanEdwards
added a commit
that referenced
this pull request
Nov 8, 2026
…pre-commit (#340) * feat(lint): make Oxlint the only linter and run every lint gate at pre-commit Biome now only formats and orders imports. Oxlint runs native equivalents of Biome's lint rules, a naming plugin for package sources, and the React rules that Biome's React domain never ran here. Pre-commit now runs policy lint, the style check, the suppression ban and the architecture gate, as BulletproofRepository does (ADR 0123, ADR 0124). Refs #336 * docs(adr): record pre-commit step timings with Oxlint owning all lint * docs(adr): renumber the pre-commit and Oxlint ADRs to 0125 and 0126 PRs #335 and #341 merge first and keep ADRs 0123 and 0124, so this branch moves its records to 0125 (pre-commit runs every gate) and 0126 (Oxlint owns all lint) and updates every link and comment to match. * feat(lint): restore Biome's React and test domain rules in Oxlint Biome's React domain ran in apps/web and packages/ui, and its test domain ran under the root package. Add react/no-danger, react/no-children-prop and the jest plugin's no-focused-tests, no-export and no-duplicate-hooks. Match Biome's strength: no-unused-vars checks every argument and catch binding, no-sequences rejects parenthesised commas, and no-empty-function, func-style and no-multi-assign cover the rest of noEmptyBlockStatements, useArrowFunction and noAssignInExpressions. Enable oxc/bad-min-max-func, oxc/approx-constant and oxc/misrefactored-assign-op. Drop the nextjs/google-font-display rule, whose plugin never loaded, and the empty import plugin. The repository has no findings under the new rules. * feat(lint): check every name Biome's naming convention checked The naming plugin covered declarations and parameters only. Add object, class and type members, import and export aliases, catch parameters, destructured, defaulted and rest bindings, function and class expression names, index signature parameters and namespaces. Enum members are PascalCase only, a top-level function may be UPPERCASE, static and readonly members may be CONSTANT_CASE, and catch parameters are camelCase. Mirror Biome's exceptions: quoted keys that are not identifiers, shorthand destructured properties, named imports kept under their own name, override members and declarations inside declare module or declare global. A 60-case Oxlint run asserts each visitor against the names Biome 2.5.1 reports on the same source. * docs(adr): correct the Biome rule inventory and record lint losses Biome's React domain ran six rules in apps/web and packages/ui and its test domain ran three rules under the root package, so ADR 0126 now counts 230 Biome rules, maps the domain rules to their Oxlint replacements and drops the claim that none of the lost rules is a correctness check. Record that noThisInStatic, noImplicitAnyLet and noFlatMapIdentity now run in result sources only, and leave duplicate JSON keys and CSS properties as an open question with two options for the maintainer. State the naming convention's real coverage in CONVENTIONS, the empty-function and caught error rules, and the new pre-commit and lint ownership in QUALITY_GATES, the North Star and an amendment note on ADR 0002. * feat(lint): keep Biome's linter for JSON and CSS files Oxlint cannot parse JSON or CSS, so with Biome's linter fully off nothing reported a duplicate JSON key or a duplicate CSS property. The maintainer chose to keep Biome's recommended rules for .json, .jsonc and .css files through one biome.json override; every other file stays formatter only. The staged pre-commit step and pnpm check run the override, and the tree has no finding under it. Tests seed a duplicate JSON, JSONC and CSS key and a TypeScript file that Biome must leave alone. ADR 0126, TECH_STACK, QUALITY_GATES, PR_QUALITY, the North Star and the hook label record the exception.
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?
feat/todo-example-app). The rules apply to the to-do reference feature that feat: replace the greeting with a to-do reference app #335 introduces, so this PR targets that branch and must merge after feat: replace the greeting with a to-do reference app #335.What changed?
One idea above 400 lines: six policy rules mined from one set of rebuilds, with the fixtures that prove each and the reference fixes they force; about 390 of the 1,004 added lines are lint fixtures in
scripts/oxlint-policy.test.tsand about 420 are the six rules.tooling/oxlint-plugin-policy.js, at error in the result-root override ({apps,packages}/*/src/**,showcase/*/*/src/**) ofoxlint.config.ts:policy/one-status-from-hooks: ause*hook returns onestatusunion instead of a query'sdata,isPending,isErrororstatusas separate fields (follows oneconstbinding, soconst todos = list.data ?? []counts). Non-test files.policy/test-unwraps-values: a test unwraps withpresent();?? ''andx.ok ? … : <literal>fail. Test files, plus a new fourth override for{apps,showcase/*}/web/e2e/**/*.ts.policy/test-imports-the-type: a test redeclares no interface or type alias that a non-test module in its folder exports.policy/message-uses-its-limit: a string, template or JSX text repeats no module-scope numericconstof 10 or more. Non-test files.policy/import-types-from-their-owner: a module undersrc/routes/<slice>/orsrc/features/<slice>/, other thanindex.ts, re-exports nothing, from a source or from an import.policy/keep-rejections: a.catchor second.thenhandler that ignores its error and returns a literal,undefinedor nothing fails (follows oneconstbinding). Non-test files.present()helper intooling/jest/present.ts(withpresent.test.ts): returns a defined value or an ok outcome's value, throws otherwise.tooling/jest/jest.setup.tsmakes it a Jest global, typed bytooling/types/present.d.ts(added totsconfig.jsonandtsconfig.api.json), because a package's unit test may import nothing outside its package. A showcase copies the reference'se2e/folder, soapps/web/e2e/fixtures.tsholds its own five-linepresent()for defined values.apps/api/src/features/todos/application.test.ts(4),apps/web/e2e/todos.spec.ts(5),apps/web/src/routes/todos/TodosPage.test.tsx(the restatedTodo, now imported from./useTodos).scripts/oxlint-policy.test.ts, every new rule seeded in each of the five result roots, a check that each message passescheck:docsphrasing, and the frozen rule sets inscripts/oxlint-rule-set.test.tsandtooling/trial/inclusion.test.ts(21 to 27 policy rules)..agents/project/CONVENTIONS.md, one in.agents/project/ARCHITECTURE.md, and ADR 0124.oxlint.config.tsandtooling/oxlint-plugin-policy.jschange, soenforcement-approvalwaits for the maintainer's tick. The change only adds rules; nothing is loosened.pnpm lint:policyyet (lint: Oxlint owns all linting, Biome only formats, and pre-commit runs every lint gate #336 adds it), so these rules fail at pre-push (pnpm verify) and in CI rather than at commit.Behavioural Proof (with video and screenshots)
one-status-from-hooks9 of 9 (one per rebuild, for example r5useTodos.ts:38data,isErrorfromlist; regenuseGreeting.ts:23);test-unwraps-values6 of 9 (r1 11, r2 5, r3 5, r4 7, r5 11, r6 8, e2e copies included);test-imports-the-type3 of 9 (r1, r4, r5TodosPage.test.tsx:7);message-uses-its-limit3 of 9 (r1, r4, r5, two each indomain.tsandtodoFormSchema.ts);import-types-from-their-owner4 of 9 (r1, r2, r4, r6application.ts);keep-rejections2 of 9 (r2useTodos.ts:17, r4useTodos.ts:42,46). On this branch before the fix,pnpm lint:policyreported exactly the 10 reference hits listed above and nothing else; after it, zero onapps/andpackages/(showcase/is empty here).apps/web/e2e/todos.spec.tsunwraps its ids withpresent()and keeps every test title; all 44 E2E tests pass.Verification Summary
7e6be1216592fc2980d5e4b29fab4ccbf2b3eeaapnpm verify,pnpm e2e): red first (jest scripts/oxlint-policy.test.ts: 49 new cases failing before the rules existed;tooling/jest/present.test.tsfailing before the helper), thenpnpm verify,pnpm e2e, and the real pre-push hook (pnpm verifyandpnpm e2e) on the final push after rebasing ontoa26be0c.pnpm verifypasses atcb68660in the pre-push hook (79 suites, 2962 Jest tests; contract, integration, coverage, build and size; JS and CSS budgets unchanged).pnpm e2epasses 44 tests.pnpm lint:policymedian of 5 interleaved runs of its command: 0.746 s before, 0.872 s after (+0.13 s)..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.test-unwraps-valuesflags only?? ''and.okternaries with a literal fallback; other fallbacks such as?? 'waiting'(a deliberate render fallback in a test) and id helpers like r2's?? 'z'stay with review.one-status-from-hooksreads only the object a hook returns.message-uses-its-limitignores constants under 10.presentis a Jest global rather than an import, because a unit test inside a package may not importtooling/; ADR 0124 records it.pnpm lint:policyuntil lint: Oxlint owns all linting, Biome only formats, and pre-commit runs every lint gate #336 lands, so an agent meets these rules at pre-push and in CI.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.docs/prd/todos.md: Edits a title in place, normalised. Evidence:todos.spec.tstest "edits a title in place and normalises it" passes inpnpm e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.docs/prd/todos.md: Cancels an edit without saving. Evidence:todos.spec.tstest "cancels an edit without saving" passes inpnpm e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.docs/prd/todos.md: Edits one to-do at a time. Evidence:todos.spec.tstest "edits one to-do at a time" passes inpnpm e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.docs/prd/todos.md: Deletes a to-do at once. Evidence:todos.spec.tstest "deletes a to-do at once" passes inpnpm e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.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 e2eatcb68660(44 passed); this PR changes only how the spec unwraps ids.PR Proof Law
.agents/project/PR_QUALITY.mdand.agents/skills/pr-quality-contract/SKILL.md; thePR qualitycheck verifies the proof format.