Repository navigation
feat(lint): add six policy rules mined from nine agent rebuilds - #345
Merged
Merged
Conversation
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>
- 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>
- 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>
Contributor
Enforcement sign-offRan at Tuesday, the 10th of November, at 12:30 pm on commit This PR changes gated enforcement or product intent, so it needs sign-off.
@BenSheridanEdwards: tick to approve.
|
8 tasks done
This was referenced Nov 10, 2026
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-appbranch (feat: replace the greeting with a to-do reference app #335), notmain. This PR extracts only the rules onto currentmain, where the reference is still the greeting app, so lint: six policy rules mined from nine agent rebuilds #337 closes without the to-do app.What changed?
One idea above 400 lines: six policy rules mined from one set of rebuilds, with the fixtures that prove each and the type programs their test helpers need. About 780 of the 1,701 added lines are lint fixtures in
scripts/oxlint-policy.test.ts, and about 550 are the six rules.tooling/oxlint-plugin-policy.js, at error in the result-root override ofoxlint.config.ts. They are the feat(lint): add six policy rules mined from nine agent rebuilds #341 rules with the fix(lint): apply the review fixes to the six rebuild rules #342 review fixes and the later follow-ups from the to-do branch:policy/one-status-from-hooks: ause*hook returns onestatusunion, not a query'sdata,isPending,isErrororstatusas separate fields. It reads throughconst list = useQuery(…),const { data, isError } = useQuery(…)andlist.data?.[0].policy/test-unwraps-values: a test unwraps withpresent()orunwrap().?? ''fails, and so doesx.ok ? x.value… : <literal>. It also runs on each result'sweb/e2e/**/*.ts, in a new override.policy/test-imports-the-type: a test redeclares no type its folder already exports.policy/message-uses-its-limit: a message interpolates its limit constant instead of hard-coding the number.policy/reexport-only-from-index: this is the issue'spolicy/import-types-from-their-owner, renamed in fix(lint): apply the review fixes to the six rebuild rules #342 review because it covers values as well as types. A slice re-exports only from its ownindex.ts.policy/keep-rejections: no.catch(() => undefined)or.then(ok, () => false)that throws the error away.present()andunwrap()live intooling/jest/test-globals.ts, with a test. The Jest setup makes them globals, because a package's unit test may import nothing outside its package.tooling/types/test-globals.d.tstypes them.apps/web/e2e/fixtures.tsholds its own five-line copies, and a unit test holds those to the same behaviour.tsconfig.test.json,tsconfig.api.test.json, and the newtsconfig.node.test.jsonfor web contract tests) alone see thepresentandunwrapglobals.tsconfig.json,tsconfig.api.jsonandtsconfig.node.jsonexclude tests, so production code or an E2E spec that calls either failspnpm typecheck. The Jest types also move out of the web and api programs, so web and api source cannot callexpectorjest.tsconfig.node.jsonkeeps them because it checksjest.setup.tsandjest.config.ts.pnpm typechecknow checks seven programs.mainthe rules find one hit.apps/web/src/routes/greeting/useGreeting.tsdropped the fire-and-forget record's rejection with.catch(() => undefined). It now settles the promise withvoid Promise.allSettled([...]), the form ADR 0124 prescribes. The failure is still ignored on purpose, and the rejection stays in the settled result. This is not a rewrite to dodge the rule.todos/application.test.ts,e2e/todos.spec.ts,TodosPage.test.tsx), thetodoswording inno-restricted-importsand the to-do probe paths. The lint fixtures keep the to-do rebuild samples they were mined from, as synthetic paths in a temporary tree.CONVENTIONS.md, rows inARCHITECTURE.md, the program list inQUALITY_GATES.mdandPR_QUALITY.md, and the program count indocs/NORTH_STAR.md.oxlint.config.ts,tooling/oxlint-plugin-policy.jsanddocs/NORTH_STAR.mdchange, soenforcement-approvalwaits for the maintainer's tick. The change only adds rules and corrects a count; nothing is loosened.Behavioural Proof (with video and screenshots)
one-status-from-hooks9 of 9,test-unwraps-values6 of 9,test-imports-the-type3 of 9,message-uses-its-limit3 of 9,reexport-only-from-index4 of 9,keep-rejections2 of 9. Those samples, such as r5'suseTodosanddomain.ts, are invalid fixtures inscripts/oxlint-policy.test.ts, and each fails with its rule's message.useGreeting.tsfix,pnpm lint:policyreported exactly one finding:useGreeting.ts:38:12 policy(keep-rejections). After the fix it reports none.useGreeting.test.tsxpasses, including "keeps the greeting visible when recording fails".gap-10/$10fixture, the destructured-query and indexed-read fixtures (useDestructured.ts,useFirst.ts) and the broken-link scan test each fail on the plugin before the fix (4 failed, 509 passed) and pass after it (513 passed).apps/web/e2e/recent-greetings.spec.ts"shows the names greeted on the page, newest first" covers the record call thatuseGreetingmakes.Verification Summary
f1a8fa0d55e77874b9a4c4613a50b6c1fa25265cpnpm verify,pnpm e2e):pnpm lint:anti-slop,pnpm verify,pnpm e2e, and the real pre-commit and pre-push hooks, on the final head.pnpm verifypasses at310a0e1in the real pre-push hook (85 suites, 3,103 Jest tests; contract, integration, changed-file coverage, build and size), andpnpm e2epasses 15 tests.pnpm typecheckpasses all seven programs.pnpm lint:anti-sloppasses on the clean tracked tree.310a0e1merges main atc74604d(fix: close audit findings in the UI, api and gate scripts #347 and docs: bring guidance in line with the current gates #348) into the reviewedc3b27acwith no conflict; the PR's own changes are unchanged. The first pre-push attempt at310a0e1failed only on load timeouts (tooling/trial/review.test.ts5-second limits and a killedscripts/bench/run.test.tschild) at load average 225, and the retry passed unchanged..agents/project/PR_QUALITY.md) satisfied, or each gap named: satisfied locally;enforcement-approvalwaits for the maintainer's tick on the guarded files.pnpm verifypnpm e2e.agents/project/ARCHITECTURE.mdandCONVENTIONS.md; new decisions recorded as ADRs.message-uses-its-limitstill matches prose such asStep 10 of 12when a limit is exactly 10, andtest-imports-the-typematches a type by name across the folder.tsconfig.json, so an editor's TypeScript server may open a test file in an inferred project.pnpm typecheckis the source of truth. A solution-style tsconfig can follow if that hurts.$TMPDIR/art-pact. A run on another branch can leave interactions there that this branch's provider rejects.PACT_DIRset to a private folder avoids it, and CI is unaffected. The to-do branch fixes this separately.reexport-only-from-indexmissesexport defaultof an imported name and anexport { x }above its import;one-status-from-hooksmisses an object built insideuseMemo;keep-rejectionsflags any method named.catchor.then, andvoid Promise.allSettled([p])ignores a failure on purpose the same way the banned form does, so the rule bans the form rather than the behaviour;isSpecFileoverlapsisTestFile; the tsconfig comments call two programs "the Node program".useGreetingchange go together.PRD Behaviours to Review
docs/prd/greeting.md: Greets the visitor by name. Evidence:greeting.spec.tstests "greets a name through the api" and "collapses runs of inner whitespace in the name" pass inpnpm e2e.docs/prd/greeting.md: Asks for a name before it calls the api. Evidence:greeting.spec.tstest "asks for a name and sends no request when the name is blank" passes inpnpm e2e.docs/prd/greeting.md: The api rejects a blank name. Evidence:greeting.spec.tstest "the api rejects a blank name as a bad request" passes inpnpm e2e; the api is unchanged.docs/prd/greeting.md: Says so when the api fails. Evidence:greeting.spec.tstest "says so when the api fails" passes inpnpm e2e.docs/prd/greeting.md: Works for every visitor. Evidence: the threeaccessibility.spec.tsgreeting tests pass inpnpm e2e; no markup changed.docs/prd/recent-greetings.md: Shows the names greeted on the page, newest first. Evidence:recent-greetings.spec.tstest "shows the names greeted on the page, newest first" passes inpnpm e2eand exercises the changed record call.docs/prd/recent-greetings.md: Stays closed until asked. Evidence:recent-greetings.spec.tstest "stays closed until asked" passes inpnpm e2e.docs/prd/recent-greetings.md: Records each greeted name. Evidence:recent-greetings.spec.tstest "records each greeted name with surrounding whitespace trimmed" passes inpnpm e2e.docs/prd/recent-greetings.md: Lists the newest name first, at most ten. Evidence:recent-greetings.spec.tstest "lists the newest name first and keeps at most ten names" passes inpnpm e2e.docs/prd/recent-greetings.md: The api rejects a blank name. Evidence:recent-greetings.spec.tstest "rejects a blank recent greeting name as a bad request" passes inpnpm e2e; the api is unchanged.PR Proof Law
.agents/project/PR_QUALITY.mdand.agents/skills/pr-quality-contract/SKILL.md; thePR qualitycheck verifies the proof format.🤖 Generated with Claude Code