From 6ed10aa67cbe14b1b20e4b1c34cf4ebc465bdc4f Mon Sep 17 00:00:00 2001 From: Ben Sheridan-Edwards Date: Sun, 8 Nov 2026 21:54:25 +0000 Subject: [PATCH 1/7] 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 --- .../decisions/0010-lint-engine-ownership.md | 5 +- .agents/decisions/0103-eslint-is-retired.md | 4 +- ...-every-lint-style-and-architecture-gate.md | 83 ++++++++ ...oxlint-owns-all-lint-biome-only-formats.md | 102 ++++++++++ .agents/project/CONVENTIONS.md | 18 +- .agents/project/PR_QUALITY.md | 4 +- .agents/project/QUALITY_GATES.md | 33 ++-- .agents/project/TECH_STACK.md | 6 +- .agents/skills/adopt-the-factory/SKILL.md | 5 +- .claude/skills/adopt-the-factory/SKILL.md | 5 +- .husky/pre-commit | 21 +- biome.json | 51 +---- docs/NORTH_STAR.md | 4 +- docs/required-gates.md | 10 +- oxlint.config.ts | 109 +++++----- package.json | 2 +- packages/ui/src/Button.tsx | 4 +- scripts/biome-overrides.test.ts | 66 ------- .../fixtures/lint-usage/oxlint-policy.json | 9 + scripts/general-lint.test.ts | 105 ++++++++++ scripts/lint-usage.mjs | 12 +- scripts/lint-usage.test.ts | 31 +-- scripts/oxlint-policy.test.ts | 9 +- scripts/oxlint-rule-set.test.ts | 15 +- scripts/required-gates.mjs | 48 ++--- tooling/oxlint-general-rules.ts | 186 ++++++++++++++++++ tooling/oxlint-plugin-naming.js | 87 ++++++++ tooling/oxlint-plugin-naming.test.ts | 100 ++++++++++ tooling/trial/inclusion.test.ts | 9 +- 29 files changed, 885 insertions(+), 258 deletions(-) create mode 100644 .agents/decisions/0123-pre-commit-runs-every-lint-style-and-architecture-gate.md create mode 100644 .agents/decisions/0124-oxlint-owns-all-lint-biome-only-formats.md delete mode 100644 scripts/biome-overrides.test.ts create mode 100644 scripts/fixtures/lint-usage/oxlint-policy.json create mode 100644 scripts/general-lint.test.ts create mode 100644 tooling/oxlint-general-rules.ts create mode 100644 tooling/oxlint-plugin-naming.js create mode 100644 tooling/oxlint-plugin-naming.test.ts diff --git a/.agents/decisions/0010-lint-engine-ownership.md b/.agents/decisions/0010-lint-engine-ownership.md index c083753a..77cf4bbf 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 [0124](0124-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..4fff802b 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 + [0124](0124-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/0123-pre-commit-runs-every-lint-style-and-architecture-gate.md b/.agents/decisions/0123-pre-commit-runs-every-lint-style-and-architecture-gate.md new file mode 100644 index 00000000..556a2c8d --- /dev/null +++ b/.agents/decisions/0123-pre-commit-runs-every-lint-style-and-architecture-gate.md @@ -0,0 +1,83 @@ +# 123. 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 0124](0124-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 8 to 24 from +other work, the median of five wall-clock runs of each step on this +repository, before and after a one-file staged change, was: + +| Step | Whole repository | One staged file | +| --- | --- | --- | +| `pnpm typecheck` | 0.90 s | 0.83 s | +| staged Biome | 0.21 s | 0.11 s | +| `pnpm lint:policy` | 1.42 s | 1.34 s | +| `pnpm lint:styles` | 0.69 s | 0.66 s | +| `pnpm lint:anti-slop` | 1.00 s | 1.02 s | +| `pnpm check:suppressions` | 1.11 s | 1.13 s | +| `pnpm arch:gate` | 1.88 s | 1.78 s | +| `pnpm fallow:audit` | 1.12 s | 1.47 s | +| `pnpm secret-scan` | 0.66 s | 0.63 s | + +The whole hook takes about 9 seconds. The slowest step, `pnpm arch:gate`, +takes under 2 seconds. + +## 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/0124-oxlint-owns-all-lint-biome-only-formats.md b/.agents/decisions/0124-oxlint-owns-all-lint-biome-only-formats.md new file mode 100644 index 00000000..e0858dfd --- /dev/null +++ b/.agents/decisions/0124-oxlint-owns-all-lint-biome-only-formats.md @@ -0,0 +1,102 @@ +# 124. Oxlint owns all lint; Biome only formats + +- **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 + +## Context + +Two engines linted this repository. Biome ran 219 rules from its recommended +preset and `biome.json`, plus two naming rules in package sources. 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. + +Biome's React rules were not running at all. Biome enables its React domain +from a React dependency in the root `package.json`, which has none, so +`useJsxKeyInIterable`, `noArrayIndexKey`, `noRenderReturnValue` and +`noDangerouslySetInnerHtmlWithChildren` were off while `oxlint.config.ts` +excluded their React Doctor twins as Biome-owned. + +The spike behind this record (8 November 2026, Oxlint 1.89.0, Biome 2.5.1) +mapped every enabled Biome rule 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 | 52 | 30 | 1 | 15 | 6 | +| performance | 2 | 1 | 0 | 1 | 0 | +| security | 3 | 3 | 0 | 0 | 0 | +| style | 16 | 13 | 0 | 2 | 1 | +| suspicious | 77 | 56 | 4 | 13 | 4 | + +"Covered elsewhere" means the parser, `tsc` or an existing policy rule +already rejects the code. "Not applicable" is GraphQL rules and rules about +Biome's own suppression comments. Of the 37 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` already owns their policy. The rest +are rare logic slips (`noConstantMathMinMaxClamp`, `noStringCaseMismatch`, +`noApproximativeNumericConstant`, `noMisrefactoredShorthandAssign`, +`noSuspiciousSemicolonInJsx`), cosmetic rules (`noUselessStringRaw`, +`useSimpleNumberKeys`), `noSvgWithoutTitle`, `noEmptyTypeParameters` (which +`tsc` rejects) and `noDynamicNamespaceImportAccess`. Three close rules need +type-aware linting (`useLiteralKeys`, `useOptionalChain`, `useExportType`); +they stay off until this repository runs `oxlint --type-aware`. +`useNamingConvention` has no Oxlint rule, so `tooling/oxlint-plugin-naming.js` +ports it. + +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 160 native +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. `pnpm lint:policy` runs `oxlint.config.ts`, + which spreads `tooling/oxlint-general-rules.ts` into its root rules: one + native rule per Biome rule it replaces, named beside it, plus the four + React rules above. `pnpm lint` runs the same command. `pnpm lint:anti-slop` + keeps the vendored anti-slop rules. +- `oxlint.config.ts` enables the `typescript`, `jsx-a11y`, `import` and `oxc` + 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`. Biome formats and orders + imports through `pnpm check` and the staged pre-commit step. +- `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 lint finding from one engine and one config. The +rules listed above as having no equivalent stop running; none is a correctness +check that tests, `tsc` or review would miss in agent-written TypeScript. +Turning Biome's linter off is a loosening that the enforcement gate reports, +so this change needs the approver's sign-off. + +To revert, set `linter.enabled` back to `true` in `biome.json`, restore its +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..aec7194a 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: `camelCase` functions and variables, `PascalCase` types and components, `SCREAMING_SNAKE_CASE` for true configuration constants. | 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 has a body; a handled error does something observable. | Oxlint `eslint/no-empty` | | 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..1d08b272 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 and imports), `pnpm lint:policy` (Oxlint, every 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..c8f2ad39 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), `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 0123](../decisions/0123-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, 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, 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,12 @@ 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 is off + ([ADR 0124](../decisions/0124-oxlint-owns-all-lint-biome-only-formats.md)). +- Oxlint owns every lint rule. `pnpm lint:policy` runs the general rules in + `tooling/oxlint-general-rules.ts` (one native rule per Biome rule it + replaced), 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 +177,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..bfd491d3 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 and import order | **Biome** (`pnpm check`) | The one formatter; its linter is off ([ADR 0124](../decisions/0124-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; Biome owns formatting and import order; the React Doctor CLI owns project checks ([ADR 0124](../decisions/0124-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..99e6efb5 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 0123). 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, 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..39c05ba2 100644 --- a/biome.json +++ b/biome.json @@ -44,53 +44,6 @@ } }, "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" - } - } - }, - "overrides": [ - { - "includes": ["apps/*/src/**", "packages/*/src/**", "showcase/*/*/src/**"], - "linter": { - "rules": { - "style": { - "useNamingConvention": { - "level": "error", - "options": { - "strictCase": true, - "requireAscii": true - } - }, - "useFilenamingConvention": { - "level": "error", - "options": { - "strictCase": true, - "requireAscii": true, - "filenameCases": ["camelCase", "PascalCase", "export"] - } - } - } - } - } - } - ] + "enabled": false + } } diff --git a/docs/NORTH_STAR.md b/docs/NORTH_STAR.md index f8824864..4b0d78a1 100644 --- a/docs/NORTH_STAR.md +++ b/docs/NORTH_STAR.md @@ -214,8 +214,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..d8fff765 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', 'import', 'oxc'], 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 0124). + 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