diff --git a/.agents/decisions/0002-quality-gates-as-code.md b/.agents/decisions/0002-quality-gates-as-code.md index 470d3132..e79eb395 100644 --- a/.agents/decisions/0002-quality-gates-as-code.md +++ b/.agents/decisions/0002-quality-gates-as-code.md @@ -1,6 +1,6 @@ # 2. Quality gates are code, enforced locally and in CI -- **Status:** Accepted, amended by [0028](0028-pre-push-runs-the-full-local-gate-suite.md) and [0062](0062-pre-commit-steps-stay-under-30-seconds.md) +- **Status:** Accepted, amended by [0028](0028-pre-push-runs-the-full-local-gate-suite.md), [0062](0062-pre-commit-steps-stay-under-30-seconds.md) and [0126](0126-oxlint-owns-all-lint-biome-only-formats.md) - **Date:** 2026-06-17 - **Superseded in part by:** [ADR 0073](0073-adopt-the-typescript-toolchain-standard.md) for Biome lint ownership; implementation follows in separate PRs. @@ -25,6 +25,10 @@ earliest point it can fail: - **CI:** all of the above re-run on a clean checkout, plus dependency + secret security audit. +Amended by [ADR 0126](0126-oxlint-owns-all-lint-biome-only-formats.md): the +pre-commit Biome step now formats, orders imports and lints JSON and CSS +only, and Oxlint (`pnpm lint:policy`) owns the rest of lint. + The local hooks and CI run the *same* checks, so "passes on my machine" and "passes in CI" converge. `pnpm verify` is the single local command that mirrors the gate suite. diff --git a/.agents/decisions/0010-lint-engine-ownership.md b/.agents/decisions/0010-lint-engine-ownership.md index c083753a..61b1a87c 100644 --- a/.agents/decisions/0010-lint-engine-ownership.md +++ b/.agents/decisions/0010-lint-engine-ownership.md @@ -1,7 +1,8 @@ # 10. Lint engines own disjoint concerns -- **Status:** Accepted; Superseded in part by ADR 0103 (lint engine); amended - by [0098](0098-oxlint-replaces-eslint.md) +- **Status:** Superseded by [0126](0126-oxlint-owns-all-lint-biome-only-formats.md); + earlier superseded in part by ADR 0103 (lint engine) and amended by + [0098](0098-oxlint-replaces-eslint.md) - **Date:** 2026-10-15 - **Superseded in part by:** [ADR 0073](0073-adopt-the-typescript-toolchain-standard.md) for Biome lint ownership; implementation follows in separate PRs. diff --git a/.agents/decisions/0103-eslint-is-retired.md b/.agents/decisions/0103-eslint-is-retired.md index 5eef20ad..5891d849 100644 --- a/.agents/decisions/0103-eslint-is-retired.md +++ b/.agents/decisions/0103-eslint-is-retired.md @@ -1,6 +1,8 @@ # 103. ESLint is retired; Oxlint is the only policy lint engine -- **Status:** Accepted (merged in #284) +- **Status:** Accepted (merged in #284); amended by + [0126](0126-oxlint-owns-all-lint-biome-only-formats.md), which makes Oxlint the + only lint engine - **Date:** 2026-11-01 - **Replaces:** ADR 0015 (deleted), whose React Doctor CLI split now lives in [0102](0102-react-doctor-rules-run-as-an-oxlint-plugin.md), and, with diff --git a/.agents/decisions/0125-pre-commit-runs-every-lint-style-and-architecture-gate.md b/.agents/decisions/0125-pre-commit-runs-every-lint-style-and-architecture-gate.md new file mode 100644 index 00000000..f2b8cfbe --- /dev/null +++ b/.agents/decisions/0125-pre-commit-runs-every-lint-style-and-architecture-gate.md @@ -0,0 +1,84 @@ +# 125. Pre-commit runs every lint, style and architecture gate + +- **Status:** Proposed (the maintainer accepts it by approving the PR) +- **Date:** 2026-11-08 +- **Amends:** [0062](0062-pre-commit-steps-stay-under-30-seconds.md) for the + list of pre-commit steps + +## Context + +The factory writes coding standards, conventions and architecture boundaries +as lint rules. Those rules pay off when the agent hears about a mistake inside +its own loop, seconds after making it. Before this change `.husky/pre-commit` +ran typecheck, staged Biome, `pnpm lint:anti-slop`, `pnpm fallow:audit` and +`pnpm secret-scan`. Four gates ran only at push and in CI: + +- `pnpm lint:policy`: Oxlint with `oxlint.config.ts`, which from + [ADR 0126](0126-oxlint-owns-all-lint-biome-only-formats.md) holds every lint + rule except the anti-slop set. +- `pnpm lint:styles`: the style-token check over CSS and `index.html` + ([ADR 0114](0114-tailwind-on-the-ui-design-tokens.md)). Its TypeScript twin, + `policy/no-arbitrary-styles`, lives in `pnpm lint:policy`. +- `pnpm check:suppressions`: the ban on inline lint and coverage suppressions. + Without it at commit, an `oxlint-disable` comment passed pre-commit. +- `pnpm arch:gate`: Fallow architecture zones, the folder structure check and + the role diagram check. + +BulletproofRepository made this change first, in its ADRs 0123 and 0127. This +record brings the same hook layout upstream. + +[ADR 0062](0062-pre-commit-steps-stay-under-30-seconds.md) lets a step into +pre-commit only when it finishes in under 30 seconds, with timings recorded. +On 8 November 2026, on one Apple M2 Max with load averages of 5 to 24 from +other work, the median of five wall-clock runs of each step, with +[ADR 0126](0126-oxlint-owns-all-lint-biome-only-formats.md) applied, on the +whole repository and after a one-file staged change, was: + +| Step | Whole repository | One staged file | +| --- | --- | --- | +| `pnpm typecheck` | 0.84 s | 0.90 s | +| staged Biome | 0.14 s | 0.10 s | +| `pnpm lint:policy` | 1.40 s | 1.44 s | +| `pnpm lint:styles` | 0.66 s | 0.67 s | +| `pnpm lint:anti-slop` | 1.05 s | 1.03 s | +| `pnpm check:suppressions` | 1.14 s | 1.18 s | +| `pnpm arch:gate` | 1.86 s | 1.93 s | +| `pnpm fallow:audit` | 2.82 s | 1.55 s | +| `pnpm secret-scan` | 1.18 s | 1.56 s | + +The whole hook takes about 11 seconds. The slowest step takes under +3 seconds, a tenth of the budget. + +## Decision + +- `.husky/pre-commit` runs, in order: `pnpm typecheck`, staged Biome, + `pnpm lint:policy`, `pnpm lint:styles`, `pnpm lint:anti-slop`, + `pnpm check:suppressions`, `pnpm arch:gate`, `pnpm fallow:audit` and + `pnpm secret-scan`. The architecture gate runs before the Fallow audit so a + boundary violation is reported by the gate that owns boundaries. +- React Doctor's project scan stays in `pnpm verify` and CI. It calls a + third-party score API, and a commit must not depend on one. +- Every new hook step keeps its CI twin: `lint:policy`, `lint:styles` and + `check:suppressions` in the `quality` job, `arch:gate` in the `fallow` job. + The contract in `scripts/required-gates.mjs` names `.husky/pre-commit` as a + source for each, and `docs/required-gates.md` is regenerated. +- This change tightens enforcement. It loosens no rule, threshold or allowlist. + +## Consequences + +Pre-commit takes about 5 seconds longer. Each step stays well inside the +ADR 0062 budget. A lint error, a style-token break, an inline suppression or +an architecture boundary violation now stops `git commit` with the rule name, +file and line. Push and CI still run the same commands, so a bypassed hook is +caught later. + +Policy lint, the style check, anti-slop lint, the suppression scan and the +architecture gate read the files on disk, like typecheck, not the staged +snapshot. Biome and gitleaks read staged content. So a staged violation whose +working-tree copy is fixed but unstaged can pass at commit; pre-push and CI +run the same commands on the pushed tree and fail it there. An untracked file +with a finding also stops a commit that does not include it: stage, stash or +delete it. + +Revert the hook lines, the contract sources and the regenerated inventory +together to restore the previous hook. diff --git a/.agents/decisions/0126-oxlint-owns-all-lint-biome-only-formats.md b/.agents/decisions/0126-oxlint-owns-all-lint-biome-only-formats.md new file mode 100644 index 00000000..a2823b22 --- /dev/null +++ b/.agents/decisions/0126-oxlint-owns-all-lint-biome-only-formats.md @@ -0,0 +1,149 @@ +# 126. Oxlint owns all code lint; Biome formats and lints JSON and CSS + +- **Status:** Proposed (the maintainer accepts it by approving the PR) +- **Date:** 2026-11-08 +- **Supersedes:** [0010](0010-lint-engine-ownership.md) +- **Implements:** [0073](0073-adopt-the-typescript-toolchain-standard.md) + tasks T16 (Oxlint as main linter) and T17 (Biome formatting only) +- **Amends:** [0103](0103-eslint-is-retired.md) for the engine list, and + [0002](0002-quality-gates-as-code.md) for the pre-commit lint engine + +## Context + +Two engines linted this repository. Biome ran 230 rules: 219 from its +recommended preset and `biome.json` at the root, two naming rules in package +sources, and nine domain rules that `biome rage` does not list. Biome turns a +domain on for every file under a `package.json` that lists the domain's +dependency. The React domain ran six rules in `apps/web` and `packages/ui` +(`useJsxKeyInIterable`, `noArrayIndexKey`, `noChildrenProp`, +`noDangerouslySetInnerHtml`, `noDangerouslySetInnerHtmlWithChildren`, +`noRenderReturnValue`); its other two recommended rules, +`useExhaustiveDependencies` and `useHookAtTopLevel`, are off in `biome.json` +because Oxlint's React hooks rules own them. The test domain ran +`noFocusedTests`, `noExportsInTest` and `noDuplicateTestHooks` in files under +the root package, which lists Jest. Biome also linted JSON and CSS. + +Oxlint ran `oxlint.config.ts` (policy, React hooks and Compiler, Tailwind and +349 React Doctor rules) and `.oxlintrc.json` (anti-slop). Each rule had one +owner, but an agent had to know which engine reported which concern, and +`oxlint.config.ts` excluded 47 React Doctor rules because Biome owned them. +ADR 0073 already chose Oxlint for general lint and Biome for formatting; this +record carries that out. + +The spike behind this record (8 November 2026, Oxlint 1.89.0, Biome 2.5.1) +mapped every Biome rule that ran on `main` to a native Oxlint rule: + +| Biome category | Rules | Exact or close native rule | Covered elsewhere | No equivalent | Not applicable | +| --- | --- | --- | --- | --- | --- | +| a11y | 37 | 35 | 0 | 2 | 0 | +| complexity | 34 | 27 | 3 | 4 | 0 | +| correctness | 55 | 34 | 1 | 14 | 6 | +| performance | 2 | 1 | 0 | 1 | 0 | +| security | 5 | 5 | 0 | 0 | 0 | +| style | 16 | 14 | 0 | 1 | 1 | +| suspicious | 81 | 61 | 4 | 11 | 5 | + +"Covered elsewhere" means the parser, `tsc` or an existing policy rule +already rejects the code. "Not applicable" is GraphQL rules, rules about +Biome's own suppression comments, and `useGoogleFontDisplay`, a Next.js rule. +Of the 33 rules with no equivalent, 26 lint CSS or HTML, which Oxlint does not +parse; this repository has two CSS files and one HTML file, and +`pnpm lint:styles` owns their token policy. The other seven are +`noStringCaseMismatch`, `noSuspiciousSemicolonInJsx`, `noSvgWithoutTitle`, +`noEmptyTypeParameters` (which `tsc` rejects), `noDynamicNamespaceImportAccess` +and two cosmetic rules (`noUselessStringRaw`, `useSimpleNumberKeys`). +Four close rules stay off. Three need type-aware linting (`useLiteralKeys`, +`useOptionalChain`, `useExportType`) until this repository runs +`oxlint --type-aware`. `unicorn/no-useless-undefined` is broader than +`noUselessUndefinedInitialization` and reports 32 places Biome accepted. +`useNamingConvention` has no Oxlint rule, so `tooling/oxlint-plugin-naming.js` +ports it. On the same source it reports the same names as Biome in 60 cases +across every selector the repository uses. + +Timed on the same machine, median of seven interleaved runs, the lint step +did not get slower: + +| Lint step | Whole repository | One staged file | +| --- | --- | --- | +| Before: staged Biome (lint, format, imports) + `pnpm lint:policy` | 0.95 s | 1.89 s | +| After: staged Biome (format, imports) + `pnpm lint:policy` with general rules | 0.96 s | 1.88 s | + +Loading the JavaScript plugins dominates `pnpm lint:policy`; the native +general rules add about 50 ms. Biome's formatter alone checks the repository +in about 0.14 s, so no faster formatter would change the commit loop. +Oxfmt 0.77 (beta) formats the TypeScript identically except `it.each` tables +in 26 test files; dprint differed on 120 files. Biome stays the formatter. + +The candidate config found one issue on the repository: `react/button-has-type` +on `packages/ui/src/Button.tsx`, which forwarded `type` from a prop. The +button now sets `type="button"` before spreading props, so a caller's `type` +still wins. + +## Decision + +- Oxlint owns every lint rule for JavaScript and TypeScript. + `pnpm lint:policy` runs `oxlint.config.ts`, + which spreads `tooling/oxlint-general-rules.ts` into its root rules: 170 + native rules, each naming the Biome rule it replaces, including the React + and test domain rules. They run in every linted file, not only where Biome's + domains applied. `pnpm lint` runs the same command. `pnpm lint:anti-slop` + keeps the vendored anti-slop rules. +- The general rules match Biome's strength where an option allows it: + `no-unused-vars` checks every argument and caught error (an `_` prefix + opts out), `no-sequences` rejects a parenthesised comma, and + `no-empty-function`, `func-style` and `no-multi-assign` cover the parts of + `noEmptyBlockStatements`, `useArrowFunction` and `noAssignInExpressions` + that their closest rules miss. +- `oxlint.config.ts` enables the `typescript`, `jsx-a11y`, `oxc` and `jest` + plugins. Package sources get `naming/naming-convention` and + `unicorn/filename-case`, the ports of Biome's naming override. +- The 47 React Doctor rules that Biome owned stay excluded; each now names + the native Oxlint rule that owns its check. +- `biome.json` sets `linter.enabled` to `false`, then turns Biome's + recommended rules back on for `.json`, `.jsonc` and `.css` files only, + through one override. Oxlint cannot parse JSON or CSS, so Biome keeps the + checks for those files: duplicate JSON keys (`noDuplicateObjectKeys`) and + the 25 CSS rules, such as duplicate, unknown or overridden properties and + unknown units. Biome formats every file and orders imports. The staged + pre-commit step (`biome check --staged`) and `pnpm check` in `pnpm verify` + and CI run both. No JavaScript or TypeScript file gets a Biome lint rule. +- `scripts/lint-usage.mjs` records `pnpm lint:policy` findings at each + pre-commit attempt as well as Biome and anti-slop findings + ([ADR 0100](0100-record-per-rule-lint-failures-on-every-pre-commit.md)). + +## Consequences + +An agent reads every finding in JavaScript and TypeScript from one engine and +one config, and every finding in JSON and CSS from Biome. Of the 33 rules with +no Oxlint equivalent, the 25 CSS rules keep running in Biome. The other eight +stop running: the seven JavaScript rules listed above and +`noDuplicateAttributes`, the one HTML rule, which applies to +`apps/web/index.html` only. Some are correctness checks, such as +`noStringCaseMismatch`; tests, `tsc`, `pnpm lint:styles` and review are the +remaining defence. Turning Biome's linter off is a loosening +that the enforcement gate reports, so this change needs the approver's +sign-off. + +Three checks now run in result sources only, where `policy/no-classes`, +`policy/no-let` and `unicorn/prefer-array-flat` cover them: `noThisInStatic`, +`noImplicitAnyLet` and `noFlatMapIdentity`. Scripts and tooling lose them. +This is an accepted loss: scripts and tooling hold no classes with static +members, `tsc` strict mode reports most implicit `any` from an untyped `let`, +and `flatMap((x) => x)` is a style slip, not a fault. + +### JSON and CSS stay with Biome + +With Biome's linter fully off, nothing reported a duplicate JSON key or a +duplicate CSS property: a probe with one of each passed `biome check`, +`pnpm lint:policy` and `pnpm lint:styles`. A duplicate key in `package.json`, +a `tsconfig` or a lint config silently keeps the last value. The maintainer +chose to keep Biome's linter for the 30 tracked JSON and JSONC files and the +two CSS files over writing a duplicate-key script, because Oxlint cannot +parse either format and Biome already ships the checks. This is the one +exception to Oxlint owning lint. `scripts/general-lint.test.ts` holds it: +Biome rejects a duplicate JSON, JSONC and CSS key, and reports nothing on a +TypeScript file. The current tree has no finding under the override. + +To revert, set `linter.enabled` back to `true` in `biome.json`, replace the +JSON and CSS override with the previous rule blocks and naming override, and +remove the general rules spread and the naming plugin from `oxlint.config.ts`. diff --git a/.agents/project/CONVENTIONS.md b/.agents/project/CONVENTIONS.md index 3212b364..dba10263 100644 --- a/.agents/project/CONVENTIONS.md +++ b/.agents/project/CONVENTIONS.md @@ -4,7 +4,7 @@ Use [AGENTS.md's rule table](../../AGENTS.md#rules-and-what-enforces-them) for s ## Enforced conventions -The Oxlint rules and Biome naming override run on `{apps,packages}/*/src/**` and `showcase/*/*/src/**`; package Oxlint policy and React rules cover `.ts` and `.tsx`. +The Oxlint policy and naming rules run on `{apps,packages}/*/src/**` and `showcase/*/*/src/**`; package Oxlint policy and React rules cover `.ts` and `.tsx`. | Convention | Enforced by | | --- | --- | @@ -13,8 +13,8 @@ The Oxlint rules and Biome naming override run on `{apps,packages}/*/src/**` and | Folders under a package `src/` are kebab-case (`name-input`). | Oxlint `policy/folder-names` | | Each folder under a package `src/` is named for its role (`name-input`, `api-client`). Code in a catch-all folder (`utils`, `helpers`, `lib`, `common`, `shared`, `misc`) moves into the slice that uses it, or into `@repo/ui` when it is a shared UI primitive. | Oxlint `policy/role-named-folders` | | Each test sits beside its subject as `.test.ts(x)` or `..test.ts(x)` (`GreetingPage.a11y.test.tsx` beside `GreetingPage.tsx`), outside any `__tests__/` folder. A source file with no test is fine; coverage thresholds decide what is tested. | Oxlint `policy/test-beside-subject` | -| Identifiers: `camelCase` functions and variables, `PascalCase` types and components, `SCREAMING_SNAKE_CASE` for true configuration constants. | Biome `style/useNamingConvention` | -| File names are camelCase, PascalCase, or the name of their export. | Biome `style/useFilenamingConvention` | +| Identifiers in package sources: `camelCase` variables, parameters, functions, object, class and type members, and import or export aliases; `PascalCase` components, types, type parameters and enum members; `CONSTANT_CASE` only for top-level constants, static class properties and getters, and readonly type members; a top-level function may be `UPPERCASE` (`GET`); catch parameters are `camelCase`. Destructured, defaulted and rest bindings and namespaces follow the same rules. A leading or trailing `_` or `$` is ignored. Quoted keys that are not identifiers (`'Content-Type'`), shorthand destructured properties, named imports kept under their own name, `override` members and names declared in `declare module` or `declare global` are exempt. | Oxlint `naming/naming-convention` | +| File names are camelCase, PascalCase, or the name of their export. | Oxlint `unicorn/filename-case` and `policy/file-matches-export` | | A component or hook lives in the file of the same name (`GreetingForm.tsx`, `useGreeting.ts`). | Oxlint `policy/file-matches-export` | | Keep block nesting to four levels. | Oxlint `max-depth` | | Return early without else, including else if. | Oxlint `no-else-return` in every file | @@ -22,7 +22,7 @@ The Oxlint rules and Biome naming override run on `{apps,packages}/*/src/**` and | Transform collections without array forEach, sort or reverse in result roots. | Oxlint `unicorn/no-array-for-each`, `unicorn/no-array-sort`, `unicorn/no-array-reverse` | | Use find, some, flat and Object.fromEntries for matching collection transforms in result roots. | Oxlint `unicorn/prefer-array-find`, `unicorn/prefer-array-some`, `unicorn/prefer-array-flat`, `unicorn/prefer-object-from-entries` | | Access document and window only in web src/main.tsx. | Oxlint `no-restricted-globals` in result roots | -| Bind with `const` unless the name is reassigned. | Biome `style/useConst` | +| Bind with `const` unless the name is reassigned. | Oxlint `eslint/prefer-const` | | Components and hooks leave props, state, hook values and globals unchanged during render. | Oxlint `react/immutability`, `react/globals`, `react/purity` | | Use `@repo/ui` Button and TextField for native buttons and inputs; checkbox/radio inputs use native elements until dedicated primitives exist. UI definitions and test harnesses may use native controls. | Oxlint `policy/use-ui-primitives` | | Style with Tailwind utility classes on the theme scale and the `@repo/ui` tokens (`bg-surface`, `text-ink`, `border-line`, `rounded-lg`, `p-6`, `max-w-160`). Use no arbitrary value, property or variant (`w-[13px]`, `bg-[#fff]`, `[mask:none]`, `w-(--x)`), no inline `style` prop and no hex or `rgb()` colour literal in a `className` value or a const it names. | Oxlint `policy/no-arbitrary-styles` in web and `@repo/ui` sources ([ADR 0114](../decisions/0114-tailwind-on-the-ui-design-tokens.md)) | @@ -44,13 +44,13 @@ The Oxlint rules and Biome naming override run on `{apps,packages}/*/src/**` and | Api code uses only erasable TypeScript syntax and sees no DOM; web code has the DOM and no Node globals. | `pnpm typecheck` (`tsconfig.api.json` with `erasableSyntaxOnly`; `tsconfig.json` with the DOM libs and no Node types) | | Banned imports, calls and effects per role. | Fallow rule pack, reported as `contract/` (`pnpm arch:gate`, `pnpm fallow:audit`) | | `strict` TypeScript with `noUncheckedIndexedAccess` and `noUnusedLocals`. | `pnpm typecheck`; review of the diff catches a loosened `tsconfig.base.json` ([ADR 0023](../decisions/0023-protect-only-the-files-that-run-the-gates.md)) | -| `unknown` and narrowing in place of `any`. | Biome `suspicious/noExplicitAny` | -| `import type` for type-only imports. | Biome `style/useImportType`, `verbatimModuleSyntax` | -| `interface` for object shapes, `type` for unions and aliases. | Biome `style/useConsistentTypeDefinitions` | +| `unknown` and narrowing in place of `any`. | Oxlint `typescript/no-explicit-any` | +| `import type` for type-only imports. | Oxlint `typescript/consistent-type-imports`, `verbatimModuleSyntax` | +| `interface` for object shapes, `type` for unions and aliases. | Oxlint `typescript/consistent-type-definitions` | | Import order. | Biome `organizeImports` | -| Every block has a body; a handled error does something observable. | Biome `suspicious/noEmptyBlockStatements` | +| Every block and function has a body; a caught error is used or named with a leading `_`. | Oxlint `eslint/no-empty`, `eslint/no-empty-function`, `eslint/no-unused-vars` (`caughtErrors: 'all'`) | | Use no `fallow-ignore` comment. | `pnpm check:suppressions`; the structure check also rejects this directive in result roots. | -| Accessible, labelled controls and status regions. | Biome `a11y/*`, jest-axe, `@axe-core/playwright`, Lighthouse | +| Accessible, labelled controls and status regions. | Oxlint `jsx-a11y/*`, jest-axe, `@axe-core/playwright`, Lighthouse | | Bind with const. | Oxlint `policy/no-let` in result roots | | Build new values; keep mutable state in integrations. | Oxlint `policy/no-mutation` in result roots | | Use functions; subclass a framework base when needed. | Oxlint `policy/no-classes` in result roots | diff --git a/.agents/project/PR_QUALITY.md b/.agents/project/PR_QUALITY.md index 50423ef9..a9bf9647 100644 --- a/.agents/project/PR_QUALITY.md +++ b/.agents/project/PR_QUALITY.md @@ -10,7 +10,7 @@ A change is done when every checklist item holds and deterministic evidence veri - [ ] Behaviour is specified. New or changed behaviour is covered by a spec in the result's `web/e2e/` folder (the behaviour map), such as `apps/web/e2e/greeting.spec.ts`. The product's contract is explicit. - [ ] Logic is unit-tested. Domain, application and procedures have `api` Jest tests; hooks and pages have `web` Jest tests that render through `TestApiProvider`. Coverage stays at/above the threshold in `jest.config.ts` (80%). - [ ] Types check. `pnpm typecheck` passes its four programs, `tsconfig.json` (web and ui), `tsconfig.node.json` (configs and e2e), `tsconfig.api.json` (api) and `tsconfig.domain.json` (api domain, no Node), with no `any` and no weakened config. -- [ ] Lint + format clean. `pnpm check` (Biome), `pnpm lint:policy` (Oxlint), `pnpm lint:anti-slop` (Oxlint anti-slop rules), and `pnpm react-doctor` pass; every disabled rule carries a written reason. +- [ ] Lint + format clean. `pnpm check` (Biome formatting, imports and JSON and CSS lint), `pnpm lint:policy` (Oxlint, every other lint rule), `pnpm lint:anti-slop` (Oxlint anti-slop rules), and `pnpm react-doctor` pass; every disabled rule carries a written reason. - [ ] Code intelligence clean. `pnpm fallow:audit` reports no dead code, circular dependency, complexity, architecture or `contract/` finding in any file the change touches. - [ ] Architecture checks pass. `pnpm arch:check` passes: every file sits in a role, no forbidden import, every result passes the structure check, `docs/architecture/roles.mmd` and each result's `architecture.mmd` match `pnpm arch:diagram`, and every package's `etc/*.api.md` matches the code (`pnpm api:report` after an intended export change). - [ ] Build succeeds. `pnpm build` produces a clean production bundle. @@ -24,7 +24,7 @@ A change is done when every checklist item holds and deterministic evidence veri ## The one-command proof ```bash -pnpm verify # typecheck → biome → oxlint → fallow → architecture → unit tests → build → size +pnpm verify # typecheck → biome format → oxlint lint → fallow → architecture → unit tests → build → size pnpm e2e # every result's behaviour map + axe accessibility scan ``` diff --git a/.agents/project/QUALITY_GATES.md b/.agents/project/QUALITY_GATES.md index c79ce94d..926d6bfe 100644 --- a/.agents/project/QUALITY_GATES.md +++ b/.agents/project/QUALITY_GATES.md @@ -33,12 +33,12 @@ rules live in [AGENTS.md](../../AGENTS.md); proof requirements live in | --- | --- | --- | --- | | Claude Code, trusted Codex Bash sessions and Cursor agents | `.agents/hooks/block-gate-bypass.sh` (Cursor uses `.agents/hooks/cursor-gate-bypass.sh`) | Common hook bypasses are refused; scope and gaps are in [ADR 0027](../decisions/0027-block-common-hook-bypasses.md) and [Cursor runs the gate-bypass hook](../decisions/0090-cursor-runs-the-gate-bypass-hook.md). | Command guard; see ADR 0027 for gaps | | Commit message | `.husky/commit-msg` | Conventional Commits via commitlint. | commitlint via commit-msg | -| Pre-commit | `.husky/pre-commit` | `pnpm typecheck` (TypeScript 7.0.2 by path), staged Biome (lint + format + imports), `pnpm lint:anti-slop`, `pnpm fallow:audit` (including complexity in touched files), `pnpm secret-scan` (staged gitleaks). Each step must finish in under 30 seconds; review holds this budget ([ADR 0062](../decisions/0062-pre-commit-steps-stay-under-30-seconds.md)). | Run the hook commands below | +| Pre-commit | `.husky/pre-commit` | `pnpm typecheck` (TypeScript 7.0.2 by path), staged Biome (format, imports, JSON and CSS lint), `pnpm lint:policy` (every Oxlint rule), `pnpm lint:styles`, `pnpm lint:anti-slop`, `pnpm check:suppressions`, `pnpm arch:gate`, `pnpm fallow:audit` (including complexity in touched files), `pnpm secret-scan` (staged gitleaks) ([ADR 0125](../decisions/0125-pre-commit-runs-every-lint-style-and-architecture-gate.md)). Each step must finish in under 30 seconds; review holds this budget ([ADR 0062](../decisions/0062-pre-commit-steps-stay-under-30-seconds.md)). | Run the hook commands below | | Pre-push | `.husky/pre-push` | Every pushed branch contains freshly fetched origin/main (the one local up-to-date check), then `pnpm verify` (the full local gate suite, including the production build) and `pnpm e2e` (Playwright E2E and axe scan for every result). A clean merge from main skips pre-commit, so this is where it gets checked. | `pnpm verify` + `pnpm e2e` | -| Local proof | `pnpm verify` + `pnpm e2e` | Context layer, suppression policy, positive doc phrasing, PRD links, required-gate contract, dependency ADR check, typecheck, Biome, Oxlint policy lint, style check, vendored anti-slop rules (Oxlint), React Doctor, Fallow, architecture checks (`pnpm arch:check`), coverage per result and changed source, Web-API contract, API integration, slice E2E mapping, build, size, E2E. Local verify runs contract after coverage and before integration; CI unit, contract, integration and E2E lanes run in parallel, and `Required gates` needs all four. A console warning or error fails a Jest test or a Playwright page ([ADR 0086](../decisions/0086-console-warnings-fail-tests.md)). | `pnpm verify` + `pnpm e2e` | +| Local proof | `pnpm verify` + `pnpm e2e` | Context layer, suppression policy, positive doc phrasing, PRD links, required-gate contract, dependency ADR check, typecheck, Biome formatting and JSON and CSS lint, Oxlint lint, style check, vendored anti-slop rules (Oxlint), React Doctor, Fallow, architecture checks (`pnpm arch:check`), coverage per result and changed source, Web-API contract, API integration, slice E2E mapping, build, size, E2E. Local verify runs contract after coverage and before integration; CI unit, contract, integration and E2E lanes run in parallel, and `Required gates` needs all four. A console warning or error fails a Jest test or a Playwright page ([ADR 0086](../decisions/0086-console-warnings-fail-tests.md)). | `pnpm verify` + `pnpm e2e` | | Vendored anti-slop | `.oxlintrc.json` (`pnpm lint:anti-slop`) | Clean generic and Effect tag rules at `error`, with `--deny-warnings`, in pre-commit, `pnpm verify` and the existing CI quality job. `pnpm check:suppressions` rejects every inline suppression and coverage pragma; an exception lives in `ALLOWED_SUPPRESSIONS` in `scripts/check-suppressions.mjs`, which needs sign-off. | `pnpm lint:anti-slop` | | Context layer | `scripts/check-context-layer.mjs` (`pnpm check:context`) | Operating contract, harness wiring, project docs, house skills, ADR naming and unique context sections. | `pnpm check:context` | -| CI quality | `.github/workflows/ci.yml` | Full-history checkouts in up-to-date, quality, fallow and coverage use `filter: blob:none`; security fetches every blob for gitleaks. PR head contains main, context layer, suppression policy, positive doc phrasing, PRD links, dependency ADR check, typecheck, Biome, Oxlint policy lint, style check, vendored anti-slop rules (Oxlint), React Doctor, Fallow, architecture gate, role diagram and API report freshness, tests, changed-file coverage and slice E2E mapping, build, security. `Required gates` judges every lane and checks the contract. Unit, contract, integration and E2E lanes run in parallel; `Required gates` needs all four. Three weighted tooling shards also run independently ([API integration tests run as their own required lane](../decisions/0094-api-integration-tests-run-as-their-own-required-lane.md)). | `pnpm verify` + `pnpm e2e`; security audit is hosted | +| CI quality | `.github/workflows/ci.yml` | Full-history checkouts in up-to-date, quality, fallow and coverage use `filter: blob:none`; security fetches every blob for gitleaks. PR head contains main, context layer, suppression policy, positive doc phrasing, PRD links, dependency ADR check, typecheck, Biome formatting and JSON and CSS lint, Oxlint lint, style check, vendored anti-slop rules (Oxlint), React Doctor, Fallow, architecture gate, role diagram and API report freshness, tests, changed-file coverage and slice E2E mapping, build, security. `Required gates` judges every lane and checks the contract. Unit, contract, integration and E2E lanes run in parallel; `Required gates` needs all four. Three weighted tooling shards also run independently ([API integration tests run as their own required lane](../decisions/0094-api-integration-tests-run-as-their-own-required-lane.md)). | `pnpm verify` + `pnpm e2e`; security audit is hosted | | CI security | `.github/workflows/codeql.yml` | CodeQL JavaScript/TypeScript analysis. | Hosted only | | CI nonfunctional | `.github/workflows/lighthouse.yml` | Lighthouse budgets (median of three runs) on PRs that touch UI-relevant files, as decided by the tested `scripts/lighthouse-scope.mjs`; other PRs report the same check green with audits skipped. | `pnpm lhci` on request | | PR contract | `.github/workflows/pr-quality.yml` (`scripts/validate-pr-body.mjs`) | Template proof, title, branch and portable paths; [PR quality](PR_QUALITY.md) owns the body requirements. | `pnpm validate:pr` with PR environment fields | @@ -62,20 +62,24 @@ Pre-commit runs these steps in order: 1. `pnpm typecheck` runs `bun check --no-script` over each program through `scripts/typecheck.mjs`. 2. `pnpm exec biome check --error-on-warnings --staged --no-errors-on-unmatched .` -3. `pnpm lint:anti-slop` -4. `pnpm fallow:audit` -5. `pnpm secret-scan` +3. `pnpm lint:policy` +4. `pnpm lint:styles` +5. `pnpm lint:anti-slop` +6. `pnpm check:suppressions` +7. `pnpm arch:gate` +8. `pnpm fallow:audit` +9. `pnpm secret-scan` An EXIT trap records each attempt in `.cache/factory-usage/lint-runs.jsonl`, -including failed attempts. It reruns staged Biome and the configured anti-slop +including failed attempts. It reruns staged Biome, `pnpm lint:policy` and the configured anti-slop command with JSON reporters and records per-rule counts and unique file paths, UTC time, branch, staged tree, HEAD, optional agent/model metadata and hook status. Set `FACTORY_USAGE_LOG=0` to turn it off. Collection is local telemetry, not a gate: logger errors leave the hook result intact. See [Record per-rule lint failures on every pre-commit](../decisions/0100-record-per-rule-lint-failures-on-every-pre-commit.md). -Biome and gitleaks read staged content. Typecheck covers the project; Oxlint -covers its configured sources. Fallow audits touched files against the last +Biome and gitleaks read staged content. Typecheck, Oxlint, the style check, the +suppression scan and the architecture gate read the files on disk. Fallow audits touched files against the last fetched `origin/main`, falling back to local `main` when the remote ref is absent. Keep each pre-commit step under 30 seconds and record its timing in the PR ([ADR 0062](../decisions/0062-pre-commit-steps-stay-under-30-seconds.md)). @@ -88,9 +92,14 @@ See [ADR 0028](../decisions/0028-pre-push-runs-the-full-local-gate-suite.md). ## Tool ownership -- Biome owns formatting, import ordering, and general JavaScript/TypeScript - lint. -- Oxlint owns core and repository policy (`pnpm lint:policy`) through +- Biome owns formatting and import ordering. Its linter runs on `.json`, + `.jsonc` and `.css` files only, the formats Oxlint does not parse + ([ADR 0126](../decisions/0126-oxlint-owns-all-lint-biome-only-formats.md)). +- Oxlint owns every other lint rule. `pnpm lint:policy` runs the 170 general rules + in `tooling/oxlint-general-rules.ts` in every linted file (the native + replacements for Biome's rules, including its React and test domain rules), + naming rules in package sources through + `tooling/oxlint-plugin-naming.js`, and core and repository policy through `tooling/oxlint-plugin-policy.js`, native hooks and Compiler rules (`react/*`), and 349 React Doctor rules through `oxlint-plugin-react-doctor` with curated settings ([ADR 0103](../decisions/0103-eslint-is-retired.md)). @@ -170,7 +179,7 @@ step of `verify` to the required lane and CI step that repeats its check. Add the CI step and its mapping together when adding a local gate. A missing mapping, CI step or required lane fails the check ([CI re-runs every local hook step](../decisions/0087-ci-re-runs-every-local-hook-step.md)). -Staged Biome maps to the full-tree check, staged secrets to the history scan, +Staged Biome maps to the full-tree format check, staged secrets to the history scan, and commitlint to PR-title validation because the title becomes the squash commit message. `verify` runs across the aggregate's lanes; each child step has its own mapping. diff --git a/.agents/project/TECH_STACK.md b/.agents/project/TECH_STACK.md index afaba0f0..623dd385 100644 --- a/.agents/project/TECH_STACK.md +++ b/.agents/project/TECH_STACK.md @@ -19,8 +19,8 @@ tool needs an ADR. [QUALITY_GATES.md](QUALITY_GATES.md) lists where each runs. | Validation and schemas | **Effect 4 Schema** (`effect`, pinned `^4.0.5`) | Procedure inputs (`Schema.toStandardSchemaV1`), form schemas, and environment parsing. | | Unit / component / contract / integration tests | **Jest + React Testing Library + Pact 17.1.4** | Five projects: `web` (jsdom), `api` (node), `tooling`, `contract` (Pact consumer/provider), and `integration` (node, real HTTP server). Unit and coverage commands select `web api tooling`; `pnpm test:integration` runs the HTTP tests once in `verify` and in its own required CI lane. | | End-to-end tests | **Playwright** | The behaviour map: one Chromium project per result, running its api and web servers. | -| Format, import order, general lint | **Biome** | The one formatter and the general-purpose linter. | -| Policy, React hooks, React Compiler, and React Doctor lint rules | **Oxlint** (`pnpm lint:policy`) | Oxlint runs repository policy, native hooks and Compiler rules (`react/*`), and React Doctor rules through `oxlint-plugin-react-doctor`. Core mutation and loop checks cover all sources; depth and public surfaces cover result sources, including showcase. See [React Doctor rules run as an Oxlint plugin](../decisions/0102-react-doctor-rules-run-as-an-oxlint-plugin.md). | +| Format, import order, JSON and CSS lint | **Biome** (`pnpm check`) | The one formatter. Its linter runs on `.json`, `.jsonc` and `.css` files only, the formats Oxlint does not parse ([ADR 0126](../decisions/0126-oxlint-owns-all-lint-biome-only-formats.md)). | +| All lint: general, naming, policy, React hooks, React Compiler, Tailwind and React Doctor rules | **Oxlint** (`pnpm lint:policy`) | Oxlint runs the general rules in `tooling/oxlint-general-rules.ts` on every source, naming rules on package sources, repository policy, native hooks and Compiler rules (`react/*`), and React Doctor rules through `oxlint-plugin-react-doctor`. Core mutation and loop checks cover all sources; depth and public surfaces cover result sources, including showcase. See [React Doctor rules run as an Oxlint plugin](../decisions/0102-react-doctor-rules-run-as-an-oxlint-plugin.md). | | React Doctor project checks | **React Doctor CLI** (`pnpm react-doctor`) | The cross-file and project checks outside the per-file plugins. | | Low-evidence TypeScript patterns (anti-slop rules) | **Oxlint** with the vendored plugin in `vendor/anti-slop/` (`pnpm lint:anti-slop`) | The anti-slop config runs only vendored plugins and includes showcase results, as the policy config does ([ADR 0118](../decisions/0118-anti-slop-lints-showcase-results.md)). | | Commit format | **commitlint** | Conventional Commits on `commit-msg`. | @@ -46,7 +46,7 @@ tool needs an ADR. [QUALITY_GATES.md](QUALITY_GATES.md) lists where each runs. ## Boundaries to respect -- Each lint rule has one owner. Biome owns formatting and general lint; Oxlint owns policy, React hooks, Compiler and React Doctor rules; the React Doctor CLI owns project checks ([ADR 0010](../decisions/0010-lint-engine-ownership.md), [ADR 0102](../decisions/0102-react-doctor-rules-run-as-an-oxlint-plugin.md), [ADR 0103](../decisions/0103-eslint-is-retired.md)). Biome is the only formatter. +- Each lint rule has one owner. Oxlint owns every lint rule for JavaScript and TypeScript; Biome owns formatting, import order and JSON and CSS lint; the React Doctor CLI owns project checks ([ADR 0126](../decisions/0126-oxlint-owns-all-lint-biome-only-formats.md), [ADR 0102](../decisions/0102-react-doctor-rules-run-as-an-oxlint-plugin.md), [ADR 0103](../decisions/0103-eslint-is-retired.md)). Biome is the only formatter. - Use Jest for unit tests and Playwright for E2E. A new runner needs an ADR (`pnpm check:adr`). Unit tests assert behaviour and stub stylesheets through `tooling/jest/jest.style-stub.cjs`. - Keep server state in TanStack Query, form state in React Hook Form, validation in Effect Schema, transport in tRPC, and primitives in `@repo/ui`. - A router library, global store, second schema library (such as zod), second data-fetching library, database client, ORM, auth library or TypeScript runner (`tsx`, `ts-node` for the api) each needs an ADR first. A result keeps its data in memory in the feature's `integrations.ts`. diff --git a/.agents/skills/adopt-the-factory/SKILL.md b/.agents/skills/adopt-the-factory/SKILL.md index 63479a11..f1a3581d 100644 --- a/.agents/skills/adopt-the-factory/SKILL.md +++ b/.agents/skills/adopt-the-factory/SKILL.md @@ -42,8 +42,9 @@ Reuse the target's tools with one owner per concern, following [`.agents/project/QUALITY_GATES.md`](../../../.agents/project/QUALITY_GATES.md). Justify new tools for owned concerns in an ADR. - Commit message: enforce Conventional Commits. -- Pre-commit: typecheck, staged Biome, anti-slop, Fallow audit including - complexity, and staged gitleaks. Measure each step against the 30-second +- Pre-commit: typecheck, staged Biome formatting, Oxlint lint, the style + check, anti-slop, the suppression ban, the architecture gate, Fallow audit + including complexity, and staged gitleaks. Measure each step against the 30-second budget; review slower steps for pre-push. - Pre-push: check the branch contains current main, then run the full local suite, production build, and E2E map. This catches clean merges, where Git skips pre-commit. diff --git a/.claude/skills/adopt-the-factory/SKILL.md b/.claude/skills/adopt-the-factory/SKILL.md index 63479a11..f1a3581d 100644 --- a/.claude/skills/adopt-the-factory/SKILL.md +++ b/.claude/skills/adopt-the-factory/SKILL.md @@ -42,8 +42,9 @@ Reuse the target's tools with one owner per concern, following [`.agents/project/QUALITY_GATES.md`](../../../.agents/project/QUALITY_GATES.md). Justify new tools for owned concerns in an ADR. - Commit message: enforce Conventional Commits. -- Pre-commit: typecheck, staged Biome, anti-slop, Fallow audit including - complexity, and staged gitleaks. Measure each step against the 30-second +- Pre-commit: typecheck, staged Biome formatting, Oxlint lint, the style + check, anti-slop, the suppression ban, the architecture gate, Fallow audit + including complexity, and staged gitleaks. Measure each step against the 30-second budget; review slower steps for pre-push. - Pre-push: check the branch contains current main, then run the full local suite, production build, and E2E map. This catches clean merges, where Git skips pre-commit. diff --git a/.husky/pre-commit b/.husky/pre-commit index 159a454d..d1a64f1f 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,19 +2,32 @@ set -e trap 'status=$?; node scripts/lint-usage.mjs --hook-exit "$status" || true; exit "$status"' EXIT -# Pre-commit = the FAST gates; each step finishes in under 30 seconds (ADR 0062). -# The up-to-date-with-main check runs on pre-push with the slower suite. See -# `.agents/decisions/0002-quality-gates-as-code.md`. +# Pre-commit = every lint, style and architecture gate, so an agent hears about a +# rule break seconds after making it. Each step finishes in under 30 seconds +# (ADR 0062, ADR 0125). The up-to-date-with-main check runs on pre-push with the +# slower suite. See `.agents/decisions/0002-quality-gates-as-code.md`. echo "› typecheck" pnpm typecheck -echo "› biome (lint + format + imports, staged only)" +echo "› biome (format, import order, JSON and CSS lint, staged only)" pnpm exec biome check --error-on-warnings --staged --no-errors-on-unmatched . +echo "› oxlint (all lint: general, policy, naming, React, Tailwind and React Doctor rules)" +pnpm lint:policy + +echo "› style tokens (CSS and index.html on the @repo/ui design tokens)" +pnpm lint:styles + echo "› anti-slop (vendored Oxlint rules)" pnpm lint:anti-slop +echo "› suppression ban (no inline lint or coverage suppressions)" +pnpm check:suppressions + +echo "› architecture gate (fallow zones, folder structure, role diagram)" +pnpm arch:gate + echo "› fallow (code intelligence: dead code, cycles, complexity)" pnpm fallow:audit diff --git a/biome.json b/biome.json index f0a7f0b0..f073bc82 100644 --- a/biome.json +++ b/biome.json @@ -44,51 +44,15 @@ } }, "linter": { - "enabled": true, - "rules": { - "preset": "recommended", - "correctness": { - "noUnusedImports": "error", - "noUnusedVariables": "error", - "useExhaustiveDependencies": "off", - "useHookAtTopLevel": "off" - }, - "style": { - "useImportType": "error", - "useConst": "error", - "noNonNullAssertion": "error", - "noIncrementDecrement": "error", - "useConsistentTypeDefinitions": "error" - }, - "suspicious": { - "noExplicitAny": "error", - "noVar": "error", - "noEmptyBlockStatements": "error" - } - } + "enabled": false }, "overrides": [ { - "includes": ["apps/*/src/**", "packages/*/src/**", "showcase/*/*/src/**"], + "includes": ["**/*.json", "**/*.jsonc", "**/*.css"], "linter": { + "enabled": true, "rules": { - "style": { - "useNamingConvention": { - "level": "error", - "options": { - "strictCase": true, - "requireAscii": true - } - }, - "useFilenamingConvention": { - "level": "error", - "options": { - "strictCase": true, - "requireAscii": true, - "filenameCases": ["camelCase", "PascalCase", "export"] - } - } - } + "preset": "recommended" } } } diff --git a/docs/NORTH_STAR.md b/docs/NORTH_STAR.md index f8824864..908eb55f 100644 --- a/docs/NORTH_STAR.md +++ b/docs/NORTH_STAR.md @@ -137,7 +137,8 @@ skills ship with the agent. The toolchain combines Biome, Oxlint, strict TypeScript over four programs, Fallow boundaries and `contract/` rules, structure checks, and unit and E2E tests. [Quality gates](../.agents/project/QUALITY_GATES.md) defines the hook sequence: pre-commit checks types, staged -formatting/lint, changed-file Fallow complexity and secrets; pre-push requires freshly fetched +formatting, every lint, style and suppression rule, the architecture gate, changed-file Fallow complexity and +secrets; pre-push requires freshly fetched `origin/main`, `pnpm verify` and `pnpm e2e`. CI repeats every gate on a clean checkout. Each pre-commit step must take under 30 seconds on a realistic change; record measurements and review slower steps for a move to pre-push. Timing is held by review. Running every convention check before every commit remains a target @@ -163,7 +164,8 @@ allowlist ([ADR 0084](../.agents/decisions/0084-reject-every-inline-suppression. Label standards without gates as targets. Close aliases, re-exports, inline disables and config edits around a rule before calling it finished. Changes that loosen or rewrite enforcement need the approver's sign-off on the exact commit ([ADR 0024](../.agents/decisions/0024-sign-off-only-loosening-enforcement-changes.md)). Biome -owns format and general lint; Oxlint owns policy, hooks, Compiler and React Doctor rules; the React Doctor CLI owns project checks. +owns formatting, import order and JSON and CSS lint; Oxlint owns every other lint rule, including general, policy, +hooks, Compiler and React Doctor rules; the React Doctor CLI owns project checks. ### 2. Layers import downward, slices stand alone, decisions live in ADRs @@ -214,8 +216,8 @@ merges and deploys. Write transforms over `const` with `map`, `filter`, `flatMap`, `some`, `every`, `find`, `reduce` and `Object.fromEntries` instead of loops, `let` accumulators, `push` or in-place mutation. Use `reduce` for one -value; build arrays and objects with `map`, `flatMap` and `Object.fromEntries`. Biome rejects accumulating -spread. Biome `style/useConst` and React Hooks immutability, globals and purity rules cover single-assignment +value; build arrays and objects with `map`, `flatMap` and `Object.fromEntries`. Oxlint rejects accumulating +spread. Oxlint `eslint/prefer-const` and React Hooks immutability, globals and purity rules cover single-assignment bindings and mutation during render in package TypeScript. Oxlint rejects loops (`policy/no-loops`) and parameter reassignment, including parameter property mutation ([ADR 0079](../.agents/decisions/0079-no-advisory-lint.md)). Oxlint also rejects redundant else after return everywhere; result roots reject nested ternaries, lonely if, array forEach, sort and reverse, diff --git a/docs/required-gates.md b/docs/required-gates.md index c64af7f9..6a7f60fd 100644 --- a/docs/required-gates.md +++ b/docs/required-gates.md @@ -39,16 +39,19 @@ Action pins are read from the workflows and composite actions, so a Dependabot b | `package.json verify` | `pnpm test:integration` | `ci.yml` `integration` | `pnpm test:integration` | | `package.json verify` | `pnpm check:lockfile` | `ci.yml` `quality` | `pnpm check:lockfile` | | `package.json verify` | `pnpm check:context` | `ci.yml` `quality` | `pnpm check:context` | -| `package.json verify` | `pnpm check:suppressions` | `ci.yml` `quality` | `pnpm check:suppressions` | | `package.json verify` | `pnpm check:docs` | `ci.yml` `quality` | `pnpm check:docs` | | `package.json verify` | `pnpm check:adr` | `ci.yml` `quality` | `pnpm check:adr` | -| `package.json verify` | `pnpm lint:policy` | `ci.yml` `quality` | `pnpm lint:policy` | -| `package.json verify` | `pnpm lint:styles` | `ci.yml` `quality` | `pnpm lint:styles` | | `package.json verify` | `pnpm react-doctor` | `ci.yml` `quality` | `pnpm react-doctor` | | `.husky/pre-commit` | `pnpm typecheck` | `ci.yml` `quality` | `pnpm typecheck` | | `package.json verify` | `pnpm typecheck` | `ci.yml` `quality` | `pnpm typecheck` | +| `.husky/pre-commit` | `pnpm lint:policy` | `ci.yml` `quality` | `pnpm lint:policy` | +| `package.json verify` | `pnpm lint:policy` | `ci.yml` `quality` | `pnpm lint:policy` | +| `.husky/pre-commit` | `pnpm lint:styles` | `ci.yml` `quality` | `pnpm lint:styles` | +| `package.json verify` | `pnpm lint:styles` | `ci.yml` `quality` | `pnpm lint:styles` | | `.husky/pre-commit` | `pnpm lint:anti-slop` | `ci.yml` `quality` | `pnpm lint:anti-slop` | | `package.json verify` | `pnpm lint:anti-slop` | `ci.yml` `quality` | `pnpm lint:anti-slop` | +| `.husky/pre-commit` | `pnpm check:suppressions` | `ci.yml` `quality` | `pnpm check:suppressions` | +| `package.json verify` | `pnpm check:suppressions` | `ci.yml` `quality` | `pnpm check:suppressions` | | `.husky/pre-commit` | `pnpm exec biome check --error-on-warnings --staged --no-errors-on-unmatched .` | `ci.yml` `quality` | `pnpm check` | | `package.json verify` | `pnpm check` | `ci.yml` `quality` | `pnpm check` | | `.husky/pre-commit` | `pnpm fallow:audit` | `ci.yml` `fallow` | `fallow-rs/fallow with.command: audit` | @@ -59,6 +62,7 @@ Action pins are read from the workflows and composite actions, so a Dependabot b | `.husky/pre-push` | `pnpm e2e` | `ci.yml` `e2e` | `pnpm e2e` | | `.husky/commit-msg` | `pnpm exec commitlint --edit "$1"` | `pr-quality.yml` `pr-body` | `node scripts/validate-pr-body.mjs` | | `package.json verify` | `pnpm gates:check` | `ci.yml` `required-gates` | `node scripts/required-gates.mjs --check` | +| `.husky/pre-commit` | `pnpm arch:gate` | `ci.yml` `fallow` | `pnpm arch:gate` | | `package.json verify` | `pnpm arch:check` | `ci.yml` `fallow` | `pnpm arch:gate`
`pnpm arch:diagram && git diff --exit-code docs/architecture/roles.mmd`
`pnpm api:check` | | `package.json verify` | `pnpm coverage:changed` | `ci.yml` `coverage` | `changed="$(git -c core.quotePath=false diff --name-only HEAD^1..."$HEAD_SHA")" && CHANGED="$changed" node scripts/confidence-label.mjs --coverage-gate` | | `package.json verify` | `pnpm test:coverage` | `ci.yml` `test` | `pnpm test:coverage:app` | diff --git a/oxlint.config.ts b/oxlint.config.ts index 85377642..1929e83c 100644 --- a/oxlint.config.ts +++ b/oxlint.config.ts @@ -1,56 +1,57 @@ import { fileURLToPath } from 'node:url'; import { RECOMMENDED_RULES } from 'oxlint-plugin-react-doctor'; +import { generalRules } from './tooling/oxlint-general-rules.ts'; import doctor from './tooling/oxlint-plugin-react-doctor.js'; -// Each excluded rule repeats a check owned by the engine named beside it. +// Each excluded rule repeats a check owned by the native rule named beside it. const singleOwnerRules = { - 'react-doctor/alt-text': true, // Biome a11y/useAltText - 'react-doctor/anchor-ambiguous-text': true, // Biome a11y/noAmbiguousAnchorText - 'react-doctor/anchor-has-content': true, // Biome a11y/useAnchorContent - 'react-doctor/anchor-is-valid': true, // Biome a11y/useValidAnchor - 'react-doctor/aria-activedescendant-has-tabindex': true, // Biome a11y/useAriaActivedescendantWithTabindex - 'react-doctor/aria-props': true, // Biome a11y/useValidAriaProps - 'react-doctor/aria-proptypes': true, // Biome a11y/useValidAriaValues - 'react-doctor/aria-role': true, // Biome a11y/useValidAriaRole - 'react-doctor/aria-unsupported-elements': true, // Biome a11y/noAriaUnsupportedElements - 'react-doctor/autocomplete-valid': true, // Biome a11y/useValidAutocomplete - 'react-doctor/button-has-type': true, // Biome a11y/useButtonType - 'react-doctor/click-events-have-key-events': true, // Biome a11y/useKeyWithClickEvents - 'react-doctor/heading-has-content': true, // Biome a11y/useHeadingContent - 'react-doctor/html-has-lang': true, // Biome a11y/useHtmlLang - 'react-doctor/iframe-has-title': true, // Biome a11y/useIframeTitle - 'react-doctor/img-redundant-alt': true, // Biome a11y/noRedundantAlt - 'react-doctor/interactive-supports-focus': true, // Biome a11y/useFocusableInteractive - 'react-doctor/label-has-associated-control': true, // Biome a11y/noLabelWithoutControl - 'react-doctor/lang': true, // Biome a11y/useValidLang - 'react-doctor/media-has-caption': true, // Biome a11y/useMediaCaption - 'react-doctor/mouse-events-have-key-events': true, // Biome a11y/useKeyWithMouseEvents - 'react-doctor/no-access-key': true, // Biome a11y/noAccessKey - 'react-doctor/no-aria-hidden-on-focusable': true, // Biome a11y/noAriaHiddenOnFocusable - 'react-doctor/no-autofocus': true, // Biome a11y/noAutofocus - 'react-doctor/no-distracting-elements': true, // Biome a11y/noDistractingElements - 'react-doctor/no-interactive-element-to-noninteractive-role': true, // Biome a11y/noInteractiveElementToNoninteractiveRole - 'react-doctor/no-noninteractive-element-to-interactive-role': true, // Biome a11y/noNoninteractiveElementToInteractiveRole - 'react-doctor/no-noninteractive-tabindex': true, // Biome a11y/noNoninteractiveTabindex - 'react-doctor/no-redundant-roles': true, // Biome a11y/noRedundantRoles - 'react-doctor/no-static-element-interactions': true, // Biome a11y/noStaticElementInteractions - 'react-doctor/prefer-tag-over-role': true, // Biome a11y/useSemanticElements - 'react-doctor/role-has-required-aria-props': true, // Biome a11y/useAriaPropsForRole - 'react-doctor/role-supports-aria-props': true, // Biome a11y/useAriaPropsSupportedByRole - 'react-doctor/scope': true, // Biome a11y/noHeaderScope - 'react-doctor/tabindex-no-positive': true, // Biome a11y/noPositiveTabindex - 'react-doctor/jsx-key': true, // Biome correctness/useJsxKeyInIterable - 'react-doctor/no-render-return-value': true, // Biome correctness/noRenderReturnValue - 'react-doctor/void-dom-elements-no-children': true, // Biome correctness/noVoidElementsWithChildren - 'react-doctor/no-spread-accumulator-in-reduce': true, // Biome performance/noAccumulatingSpread - 'react-doctor/jsx-no-script-url': true, // Biome security/noScriptUrl - 'react-doctor/jsx-no-target-blank': true, // Biome security/noBlankTarget - 'react-doctor/no-danger-with-children': true, // Biome security/noDangerouslySetInnerHtmlWithChildren - 'react-doctor/no-eval': true, // Biome security/noGlobalEval - 'react-doctor/no-non-null-assertion-on-maybe-undefined-result': true, // Biome style/noNonNullAssertion - 'react-doctor/jsx-no-comment-textnodes': true, // Biome suspicious/noCommentText - 'react-doctor/jsx-no-duplicate-props': true, // Biome suspicious/noDuplicateJsxProps - 'react-doctor/no-array-index-as-key': true, // Biome suspicious/noArrayIndexKey + 'react-doctor/alt-text': true, // jsx-a11y/alt-text + 'react-doctor/anchor-ambiguous-text': true, // jsx-a11y/anchor-ambiguous-text + 'react-doctor/anchor-has-content': true, // jsx-a11y/anchor-has-content + 'react-doctor/anchor-is-valid': true, // jsx-a11y/anchor-is-valid + 'react-doctor/aria-activedescendant-has-tabindex': true, // jsx-a11y/aria-activedescendant-has-tabindex + 'react-doctor/aria-props': true, // jsx-a11y/aria-props + 'react-doctor/aria-proptypes': true, // jsx-a11y/aria-proptypes + 'react-doctor/aria-role': true, // jsx-a11y/aria-role + 'react-doctor/aria-unsupported-elements': true, // jsx-a11y/aria-unsupported-elements + 'react-doctor/autocomplete-valid': true, // jsx-a11y/autocomplete-valid + 'react-doctor/button-has-type': true, // react/button-has-type + 'react-doctor/click-events-have-key-events': true, // jsx-a11y/click-events-have-key-events + 'react-doctor/heading-has-content': true, // jsx-a11y/heading-has-content + 'react-doctor/html-has-lang': true, // jsx-a11y/html-has-lang + 'react-doctor/iframe-has-title': true, // jsx-a11y/iframe-has-title + 'react-doctor/img-redundant-alt': true, // jsx-a11y/img-redundant-alt + 'react-doctor/interactive-supports-focus': true, // jsx-a11y/interactive-supports-focus + 'react-doctor/label-has-associated-control': true, // jsx-a11y/label-has-associated-control + 'react-doctor/lang': true, // jsx-a11y/lang + 'react-doctor/media-has-caption': true, // jsx-a11y/media-has-caption + 'react-doctor/mouse-events-have-key-events': true, // jsx-a11y/mouse-events-have-key-events + 'react-doctor/no-access-key': true, // jsx-a11y/no-access-key + 'react-doctor/no-aria-hidden-on-focusable': true, // jsx-a11y/no-aria-hidden-on-focusable + 'react-doctor/no-autofocus': true, // jsx-a11y/no-autofocus + 'react-doctor/no-distracting-elements': true, // jsx-a11y/no-distracting-elements + 'react-doctor/no-interactive-element-to-noninteractive-role': true, // jsx-a11y/no-interactive-element-to-noninteractive-role + 'react-doctor/no-noninteractive-element-to-interactive-role': true, // jsx-a11y/no-noninteractive-element-to-interactive-role + 'react-doctor/no-noninteractive-tabindex': true, // jsx-a11y/no-noninteractive-tabindex + 'react-doctor/no-redundant-roles': true, // jsx-a11y/no-redundant-roles + 'react-doctor/no-static-element-interactions': true, // jsx-a11y/no-static-element-interactions + 'react-doctor/prefer-tag-over-role': true, // jsx-a11y/prefer-tag-over-role + 'react-doctor/role-has-required-aria-props': true, // jsx-a11y/role-has-required-aria-props + 'react-doctor/role-supports-aria-props': true, // jsx-a11y/role-supports-aria-props + 'react-doctor/scope': true, // jsx-a11y/scope + 'react-doctor/tabindex-no-positive': true, // jsx-a11y/tabindex-no-positive + 'react-doctor/jsx-key': true, // react/jsx-key + 'react-doctor/no-render-return-value': true, // react/no-render-return-value + 'react-doctor/void-dom-elements-no-children': true, // react/void-dom-elements-no-children + 'react-doctor/no-spread-accumulator-in-reduce': true, // oxc/no-accumulating-spread + 'react-doctor/jsx-no-script-url': true, // react/jsx-no-script-url + 'react-doctor/jsx-no-target-blank': true, // react/jsx-no-target-blank + 'react-doctor/no-danger-with-children': true, // react/no-danger-with-children + 'react-doctor/no-eval': true, // eslint/no-eval + 'react-doctor/no-non-null-assertion-on-maybe-undefined-result': true, // typescript/no-non-null-assertion + 'react-doctor/jsx-no-comment-textnodes': true, // react/jsx-no-comment-textnodes + 'react-doctor/jsx-no-duplicate-props': true, // react/jsx-no-duplicate-props + 'react-doctor/no-array-index-as-key': true, // react/no-array-index-key 'react-doctor/rules-of-hooks': true, // react-hooks/rules-of-hooks 'react-doctor/exhaustive-deps': true, // react-hooks/exhaustive-deps 'react-doctor/no-set-state-in-render': true, // react-hooks/set-state-in-render @@ -111,7 +112,7 @@ export default { restriction: 'off', nursery: 'off', }, - plugins: ['react', 'unicorn'], + plugins: ['react', 'unicorn', 'typescript', 'jsx-a11y', 'oxc', 'jest'], options: { respectEslintDisableDirectives: false }, jsPlugins: [ { @@ -119,6 +120,7 @@ export default { specifier: import.meta.resolve('eslint-plugin-better-tailwindcss'), }, fileURLToPath(new URL('./tooling/oxlint-plugin-policy.js', import.meta.url)), + fileURLToPath(new URL('./tooling/oxlint-plugin-naming.js', import.meta.url)), { name: doctor.meta.name, specifier: fileURLToPath(new URL('./tooling/oxlint-plugin-react-doctor.js', import.meta.url)), @@ -140,6 +142,7 @@ export default { '.cache/**', ], rules: { + ...generalRules, 'no-else-return': ['error', { allowElseIf: false }], 'no-param-reassign': ['error', { props: true }], 'policy/no-loops': 'error', @@ -238,5 +241,13 @@ export default { excludeFiles: ['{apps,showcase/*}/web/src/main.tsx'], rules: { 'no-restricted-globals': ['error', 'document', 'window'] }, }, + { + // Naming and file names, ported from Biome's override (ADR 0126). + files: ['{apps,packages}/*/src/**', 'showcase/*/*/src/**'], + rules: { + 'naming/naming-convention': 'error', + 'unicorn/filename-case': ['error', { cases: { camelCase: true, pascalCase: true } }], + }, + }, ], }; diff --git a/package.json b/package.json index 0651b48e..63fbaf46 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "build": "pnpm -r build", "preview": "pnpm --filter @repo/web preview", "typecheck": "node scripts/typecheck.mjs", - "lint": "biome lint --error-on-warnings .", + "lint": "pnpm lint:policy", "format": "biome format --write .", "check": "biome check --error-on-warnings .", "lint:policy": "env -u NAPI_RS_NATIVE_LIBRARY_PATH -u VP_VERSION -u OXLINT_TSGOLINT_PATH oxlint --no-ignore --config oxlint.config.ts --deny-warnings", diff --git a/packages/ui/src/Button.tsx b/packages/ui/src/Button.tsx index e2f68bd2..dd2fff2d 100644 --- a/packages/ui/src/Button.tsx +++ b/packages/ui/src/Button.tsx @@ -7,6 +7,6 @@ const BUTTON_CLASSES = cn( 'cursor-pointer rounded-lg border border-line bg-raised px-4 py-2 text-base font-semibold text-ink transition-colors hover:border-line-strong hover:bg-raised-hover focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus', ); -export function Button({ type = 'button', className, ...props }: ButtonProps) { - return