Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Run the remaining ok-rules self-tests in the uncached tier (#5201)

Nick Gomez107a3fd420dc
diff --git a/AGENTS.md b/AGENTS.md
index 78979a35b..7d998831c 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -28,6 +28,8 @@ pnpm run test
For routine local Turbo runs, use an absolute `TURBO_CACHE_DIR` inside this worktree; use `TURBO_FORCE=true` only for a deliberate fresh run.
+A test that reads files outside its own package's Turbo inputs is named `*.uncached.test.ts` (or `.tsx`, `.mjs`, matching the file's language); `pnpm run test:uncached` runs those on every call, and no cached tier does.
+
Run local apps:
```bash
diff --git a/lint-plugins/ok-rules/README.md b/lint-plugins/ok-rules/README.md
index d58dc09a3..19b493cce 100644
--- a/lint-plugins/ok-rules/README.md
+++ b/lint-plugins/ok-rules/README.md
@@ -8,7 +8,7 @@ One plugin holding every rule is deliberate: oxlint walks the AST once and dispa
## Convention
-**All custom lint enforcement uses oxlint JS-plugin rules** — [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42). Add a module under `rules/` + a fixture-file test. The fixture-file test is non-negotiable: it preserves the mutation-self-test property by asserting an exact diagnostic count on a fixture pairing positive cases with negative cases.
+**All custom lint enforcement uses oxlint JS-plugin rules** — [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42). Add a module under `rules/` + a fixture-file test. The fixture-file test is non-negotiable: it preserves the mutation-self-test property by asserting the exact position of every diagnostic, filtered by the rule's own code, on a fixture pairing positive cases with negative cases.
**Rule modules carry no prose comments.** These are `.mjs` files, so the [no-comments policy](../no-comments/README.md) applies to them — unlike the `.grit` files they replaced, which sat outside it and carried long rationale headers. That rationale lives here instead, in the rule's section below. When you write a rule, budget for writing its README section in the same change; there is nowhere else for the reasoning to go.
@@ -34,13 +34,13 @@ The rule does NOT catch:
- `…` in CLI strings (`process.stderr.write('Cloning…')`) — uncaught gap; review discipline covers the small CLI surface.
- `…` in JSX expression-child string literals (`<span>{'Loading…'}</span>`) — uncaught gap; zero occurrences in the codebase today (developers write `<span>Loading…</span>` directly). If a realistic case emerges, add a `jsx_expression` pattern matching `string` literal children rather than retrofit ad-hoc.
-Rule: [`lint-plugins/ok-rules/rules/microcopy-ellipsis.mjs`](rules/microcopy-ellipsis.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/microcopy-ellipsis.fixture.tsx`](__fixtures__/microcopy-ellipsis.fixture.tsx). Test: [`packages/app/tests/integration/microcopy-ellipsis.test.ts`](../../packages/app/tests/integration/microcopy-ellipsis.test.ts).
+Rule: [`lint-plugins/ok-rules/rules/microcopy-ellipsis.mjs`](rules/microcopy-ellipsis.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/microcopy-ellipsis.fixture.tsx`](__fixtures__/microcopy-ellipsis.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/microcopy-ellipsis.uncached.test.mjs`](tests/microcopy-ellipsis.uncached.test.mjs).
### `no-loosely-typed-webcontents-ipc`
IPC discipline enforcement. Forbids direct electron IPC primitives (`webContents.send`, `ipcMain.handle/on`, `ipcRenderer.invoke/on/once`) outside the typed-wrapper files. Consumers must route through `createInvoker` / `createHandler` / `sendToRenderer` from `packages/desktop/src/shared/ipc-*.ts`. See [PRECEDENTS.md #14](../../PRECEDENTS.md) for the IPC discipline rationale.
-Rule: [`lint-plugins/ok-rules/rules/no-loosely-typed-webcontents-ipc.mjs`](rules/no-loosely-typed-webcontents-ipc.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-loosely-typed-webcontents-ipc.fixture.tsx`](__fixtures__/no-loosely-typed-webcontents-ipc.fixture.tsx). Test: [`packages/desktop/tests/integration/no-loosely-typed-webcontents-ipc.test.ts`](../../packages/desktop/tests/integration/no-loosely-typed-webcontents-ipc.test.ts).
+Rule: [`lint-plugins/ok-rules/rules/no-loosely-typed-webcontents-ipc.mjs`](rules/no-loosely-typed-webcontents-ipc.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-loosely-typed-webcontents-ipc.fixture.tsx`](__fixtures__/no-loosely-typed-webcontents-ipc.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-loosely-typed-webcontents-ipc.uncached.test.mjs`](tests/no-loosely-typed-webcontents-ipc.uncached.test.mjs).
### `no-raw-html-interactive-element`
@@ -64,7 +64,7 @@ The rule does NOT catch:
Included: `packages/app/src/**/*.tsx`, `packages/desktop/src/**/*.tsx`, `packages/plugin/src/**/*.tsx`, `lint-plugins/ok-rules/__fixtures__/no-raw-html-interactive-element.fixture.tsx`. Excluded: `packages/app/src/editor/**`, `packages/app/src/components/ui/**`, `**/*.test.tsx`, `**/*.dom.test.tsx`, `**/*.test-helper.tsx`.
-Rule: [`lint-plugins/ok-rules/rules/no-raw-html-interactive-element.mjs`](rules/no-raw-html-interactive-element.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-raw-html-interactive-element.fixture.tsx`](__fixtures__/no-raw-html-interactive-element.fixture.tsx). Test: [`packages/app/tests/lint-plugins/no-raw-html-interactive-element.test.ts`](../../packages/app/tests/lint-plugins/no-raw-html-interactive-element.test.ts). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
+Rule: [`lint-plugins/ok-rules/rules/no-raw-html-interactive-element.mjs`](rules/no-raw-html-interactive-element.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-raw-html-interactive-element.fixture.tsx`](__fixtures__/no-raw-html-interactive-element.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-raw-html-interactive-element.uncached.test.mjs`](tests/no-raw-html-interactive-element.uncached.test.mjs). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
### `no-themeless-pierre-diff`
@@ -87,7 +87,7 @@ Runtime complement: `packages/app/src/components/ActivityPanelDiffView.dom.test.
Included: `packages/app/src/**/*.tsx`, `lint-plugins/ok-rules/__fixtures__/no-themeless-pierre-diff.fixture.tsx`. Excluded: `**/*.test.tsx`, `**/*.dom.test.tsx`, `**/*.test-helper.tsx`.
-Rule: [`lint-plugins/ok-rules/rules/no-themeless-pierre-diff.mjs`](rules/no-themeless-pierre-diff.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-themeless-pierre-diff.fixture.tsx`](__fixtures__/no-themeless-pierre-diff.fixture.tsx). Test: [`packages/app/tests/lint-plugins/no-themeless-pierre-diff.test.ts`](../../packages/app/tests/lint-plugins/no-themeless-pierre-diff.test.ts).
+Rule: [`lint-plugins/ok-rules/rules/no-themeless-pierre-diff.mjs`](rules/no-themeless-pierre-diff.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-themeless-pierre-diff.fixture.tsx`](__fixtures__/no-themeless-pierre-diff.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-themeless-pierre-diff.uncached.test.mjs`](tests/no-themeless-pierre-diff.uncached.test.mjs).
### `no-resolved-value-theme-source`
@@ -98,7 +98,7 @@ Detection patterns (call expressions only — type-declarations are naturally ex
- `setThemeSource($arg)` where `$arg` contains both `'light'` and `'dark'` string literals (likely a ternary, either order)
- Matches both bare-call and member-call shapes (`obj.setThemeSource(...)`)
-Rule: [`lint-plugins/ok-rules/rules/no-resolved-value-theme-source.mjs`](rules/no-resolved-value-theme-source.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-resolved-value-theme-source.fixture.tsx`](__fixtures__/no-resolved-value-theme-source.fixture.tsx). Test: [`packages/desktop/tests/integration/no-resolved-value-theme-source.test.ts`](../../packages/desktop/tests/integration/no-resolved-value-theme-source.test.ts).
+Rule: [`lint-plugins/ok-rules/rules/no-resolved-value-theme-source.mjs`](rules/no-resolved-value-theme-source.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-resolved-value-theme-source.fixture.tsx`](__fixtures__/no-resolved-value-theme-source.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-resolved-value-theme-source.uncached.test.mjs`](tests/no-resolved-value-theme-source.uncached.test.mjs).
### `no-split-suggestion-dispatch`
@@ -117,7 +117,7 @@ The rule does NOT catch:
Runtime complement: `packages/app/src/editor/extensions/suggestion-atomicity.dom.test.tsx` + `slash-command-atomicity.dom.test.tsx` drive every registered suggestion surface through a real Enter and assert exactly one doc-changing transaction — they catch the delegated-dispatch shapes the lint can't.
-Rule: [`lint-plugins/ok-rules/rules/no-split-suggestion-dispatch.mjs`](rules/no-split-suggestion-dispatch.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-split-suggestion-dispatch.fixture.tsx`](__fixtures__/no-split-suggestion-dispatch.fixture.tsx). Test: [`packages/app/tests/lint-plugins/no-split-suggestion-dispatch.test.ts`](../../packages/app/tests/lint-plugins/no-split-suggestion-dispatch.test.ts).
+Rule: [`lint-plugins/ok-rules/rules/no-split-suggestion-dispatch.mjs`](rules/no-split-suggestion-dispatch.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-split-suggestion-dispatch.fixture.tsx`](__fixtures__/no-split-suggestion-dispatch.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-split-suggestion-dispatch.uncached.test.mjs`](tests/no-split-suggestion-dispatch.uncached.test.mjs).
### `no-unportaled-editor-content`
@@ -134,7 +134,7 @@ createPortal(
);
```
-Rule: [`lint-plugins/ok-rules/rules/no-unportaled-editor-content.mjs`](rules/no-unportaled-editor-content.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-unportaled-editor-content.fixture.tsx`](__fixtures__/no-unportaled-editor-content.fixture.tsx). Test: [`packages/app/tests/integration/no-unportaled-editor-content.test.ts`](../../packages/app/tests/integration/no-unportaled-editor-content.test.ts). See [PRECEDENTS.md #44](../../PRECEDENTS.md) for the H6 cross-doc DOM bleed contract and [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
+Rule: [`lint-plugins/ok-rules/rules/no-unportaled-editor-content.mjs`](rules/no-unportaled-editor-content.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-unportaled-editor-content.fixture.tsx`](__fixtures__/no-unportaled-editor-content.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-unportaled-editor-content.uncached.test.mjs`](tests/no-unportaled-editor-content.uncached.test.mjs). See [PRECEDENTS.md #44](../../PRECEDENTS.md) for the H6 cross-doc DOM bleed contract and [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
### `no-uninstall-forbidden-import`
@@ -150,7 +150,7 @@ This rule is **shallow, first-hop feedback only**. The authoritative gate is the
Included: `packages/app/src/uninstall/**/*.ts`, `packages/app/src/uninstall/**/*.tsx`, `lint-plugins/ok-rules/__fixtures__/no-uninstall-forbidden-import.fixture.tsx`. Excluded: `packages/app/src/uninstall/**/*.test.ts`, `packages/app/src/uninstall/**/*.test.tsx`, `packages/app/src/uninstall/**/*.dom.test.tsx`.
-Rule: [`lint-plugins/ok-rules/rules/no-uninstall-forbidden-import.mjs`](rules/no-uninstall-forbidden-import.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-uninstall-forbidden-import.fixture.tsx`](__fixtures__/no-uninstall-forbidden-import.fixture.tsx). Test: [`packages/desktop/tests/integration/no-uninstall-forbidden-import.test.ts`](../../packages/desktop/tests/integration/no-uninstall-forbidden-import.test.ts). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
+Rule: [`lint-plugins/ok-rules/rules/no-uninstall-forbidden-import.mjs`](rules/no-uninstall-forbidden-import.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-uninstall-forbidden-import.fixture.tsx`](__fixtures__/no-uninstall-forbidden-import.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-uninstall-forbidden-import.uncached.test.mjs`](tests/no-uninstall-forbidden-import.uncached.test.mjs). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
### `path-conditional-map-driven-origin`
@@ -188,7 +188,7 @@ The rule does NOT catch:
Included: `packages/md-conformance/src/substrates/*/handlers/**/*.ts`, `lint-plugins/ok-rules/__fixtures__/cst-pm-handler-todo-stub.fixture.tsx`.
-Rule: [`lint-plugins/ok-rules/rules/cst-pm-handler-todo-stub.mjs`](rules/cst-pm-handler-todo-stub.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/cst-pm-handler-todo-stub.fixture.tsx`](__fixtures__/cst-pm-handler-todo-stub.fixture.tsx). Test: [`packages/md-conformance/src/lint-plugins/cst-pm-handler-todo-stub.test.ts`](../../packages/md-conformance/src/lint-plugins/cst-pm-handler-todo-stub.test.ts).
+Rule: [`lint-plugins/ok-rules/rules/cst-pm-handler-todo-stub.mjs`](rules/cst-pm-handler-todo-stub.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/cst-pm-handler-todo-stub.fixture.tsx`](__fixtures__/cst-pm-handler-todo-stub.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/cst-pm-handler-todo-stub.uncached.test.mjs`](tests/cst-pm-handler-todo-stub.uncached.test.mjs).
### `class-proof-registration-discipline`
@@ -206,11 +206,11 @@ The rule does NOT catch:
- Functions with similar names (`myDefineClassProofVariant`) — pattern matches the exact function name
- Type references to `defineClassProof` — pattern scopes to call expressions
-**Scope** (`RULE_SCOPES['class-proof-registration-discipline']` in [`scope.mjs`](scope.mjs)). Class-proof DSL registration discipline: registrations MUST live in the canonical proofs/ dir (one manifest as the single source of truth) and EVERY registration MUST pass `predicate` + `proof` options. The scope entry EXCLUDES the canonical dir — inside it, the TypeScript signature is the missing-args backstop; outside it, any `defineClassProof(...)` call fires (= wrong location), and missing args fire an additional diagnostic.
+**Scope** (`RULE_SCOPES['class-proof-registration-discipline']` in [`scope.mjs`](scope.mjs)). Class-proof DSL registration discipline: registrations MUST live in the canonical proofs/ dir (one manifest as the single source of truth) and EVERY registration MUST pass `predicate` + `proof` options. The scope entry EXCLUDES the canonical dir — inside it, the TypeScript signature is the missing-args backstop; outside it, every `defineClassProof(...)` call fires exactly once: with the missing-options diagnostic when `predicate` or `proof` is absent, otherwise with the wrong-location diagnostic.
Included: `**/*.ts`, `**/*.tsx`, `**/*.mts`, `lint-plugins/ok-rules/__fixtures__/class-proof-registration-discipline.fixture.tsx`. Excluded: `**/node_modules/**`, `**/dist/**`, `**/*.test.ts`, `**/*.test.tsx`, `**/*.test.mts`, `packages/md-conformance/src/class-proofs/proofs/**`.
-Rule: [`lint-plugins/ok-rules/rules/class-proof-registration-discipline.mjs`](rules/class-proof-registration-discipline.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/class-proof-registration-discipline.fixture.tsx`](__fixtures__/class-proof-registration-discipline.fixture.tsx). Test: [`packages/md-conformance/src/lint-plugins/class-proof-registration-discipline.test.ts`](../../packages/md-conformance/src/lint-plugins/class-proof-registration-discipline.test.ts).
+Rule: [`lint-plugins/ok-rules/rules/class-proof-registration-discipline.mjs`](rules/class-proof-registration-discipline.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/class-proof-registration-discipline.fixture.tsx`](__fixtures__/class-proof-registration-discipline.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/class-proof-registration-discipline.uncached.test.mjs`](tests/class-proof-registration-discipline.uncached.test.mjs).
### `playwright-prefer-to-have-count`
@@ -227,7 +227,7 @@ The rule does NOT catch:
Included: `packages/app/tests/stress/**/*.e2e.ts`, `packages/app/tests/visual/**/*.e2e.ts`, `packages/app/tests/a11y/**/*.e2e.ts`, `lint-plugins/ok-rules/__fixtures__/playwright-prefer-to-have-count.fixture.tsx`.
-Rule: [`lint-plugins/ok-rules/rules/playwright-prefer-to-have-count.mjs`](rules/playwright-prefer-to-have-count.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/playwright-prefer-to-have-count.fixture.tsx`](__fixtures__/playwright-prefer-to-have-count.fixture.tsx). Test: [`packages/app/tests/lint-plugins/playwright-prefer-to-have-count.test.ts`](../../packages/app/tests/lint-plugins/playwright-prefer-to-have-count.test.ts). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
+Rule: [`lint-plugins/ok-rules/rules/playwright-prefer-to-have-count.mjs`](rules/playwright-prefer-to-have-count.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/playwright-prefer-to-have-count.fixture.tsx`](__fixtures__/playwright-prefer-to-have-count.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/playwright-prefer-to-have-count.uncached.test.mjs`](tests/playwright-prefer-to-have-count.uncached.test.mjs). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
### `no-roundtrip-identity-oracle`
@@ -250,7 +250,7 @@ The rule does NOT catch:
Included: `packages/**/*.test.ts`, `packages/**/*.test.tsx`, `packages/**/*.e2e.ts`, `lint-plugins/ok-rules/__fixtures__/no-roundtrip-identity-oracle.fixture.tsx`. Excluded: `packages/md-conformance/**`, `packages/app/tests/fidelity/**`, `packages/core/src/markdown/**/*.test.ts`, `packages/core/src/bridge/**/*.test.ts`, `**/*.private.*`.
-Rule: [`lint-plugins/ok-rules/rules/no-roundtrip-identity-oracle.mjs`](rules/no-roundtrip-identity-oracle.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-roundtrip-identity-oracle.fixture.tsx`](__fixtures__/no-roundtrip-identity-oracle.fixture.tsx). Test: [`packages/app/tests/lint-plugins/no-roundtrip-identity-oracle.test.ts`](../../packages/app/tests/lint-plugins/no-roundtrip-identity-oracle.test.ts). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention and [PRECEDENTS.md #38](../../PRECEDENTS.md) for the Bridge-invariant contract.
+Rule: [`lint-plugins/ok-rules/rules/no-roundtrip-identity-oracle.mjs`](rules/no-roundtrip-identity-oracle.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-roundtrip-identity-oracle.fixture.tsx`](__fixtures__/no-roundtrip-identity-oracle.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-roundtrip-identity-oracle.uncached.test.mjs`](tests/no-roundtrip-identity-oracle.uncached.test.mjs). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention and [PRECEDENTS.md #38](../../PRECEDENTS.md) for the Bridge-invariant contract.
### `no-hand-rolled-branch-validation`
@@ -364,7 +364,7 @@ Suppress with a reason:
Included: `packages/server/src/**/*.ts`, `lint-plugins/ok-rules/__fixtures__/no-hand-rolled-branch-validation.fixture.tsx`. Excluded: `**/*.test.ts`, `**/*.test-helper.ts`.
-Rule: [`lint-plugins/ok-rules/rules/no-hand-rolled-branch-validation.mjs`](rules/no-hand-rolled-branch-validation.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-hand-rolled-branch-validation.fixture.tsx`](__fixtures__/no-hand-rolled-branch-validation.fixture.tsx). Test: [`packages/app/tests/lint-plugins/no-hand-rolled-branch-validation.test.ts`](../../packages/app/tests/lint-plugins/no-hand-rolled-branch-validation.test.ts). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
+Rule: [`lint-plugins/ok-rules/rules/no-hand-rolled-branch-validation.mjs`](rules/no-hand-rolled-branch-validation.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-hand-rolled-branch-validation.fixture.tsx`](__fixtures__/no-hand-rolled-branch-validation.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-hand-rolled-branch-validation.uncached.test.mjs`](tests/no-hand-rolled-branch-validation.uncached.test.mjs). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
### `no-hand-rolled-spinner`
@@ -378,7 +378,7 @@ Unscoped, like the other rules in `UNSCOPED_RULES` — it applies wherever a cla
The `\b` delimiter is asymmetric in a way that is easy to misread: `animate-spinner` does NOT fire (the trailing boundary fails against a word character) but `animate-spin-slow` DOES (`-` is a boundary). That is the retired pattern's behaviour, kept deliberately — a slowed hand-rolled spin is still hand-rolled — and both halves are pinned in the fixture.
-Rule: [`lint-plugins/ok-rules/rules/no-hand-rolled-spinner.mjs`](rules/no-hand-rolled-spinner.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-hand-rolled-spinner.fixture.tsx`](__fixtures__/no-hand-rolled-spinner.fixture.tsx). Test: [`packages/app/tests/lint-plugins/no-hand-rolled-spinner.test.ts`](../../packages/app/tests/lint-plugins/no-hand-rolled-spinner.test.ts).
+Rule: [`lint-plugins/ok-rules/rules/no-hand-rolled-spinner.mjs`](rules/no-hand-rolled-spinner.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-hand-rolled-spinner.fixture.tsx`](__fixtures__/no-hand-rolled-spinner.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-hand-rolled-spinner.uncached.test.mjs`](tests/no-hand-rolled-spinner.uncached.test.mjs).
### `no-inline-tolerance-class`
@@ -402,7 +402,7 @@ The rule does NOT catch:
Included: `packages/**/*.test.ts`, `packages/**/*.test.tsx`, `packages/**/*.e2e.ts`, `lint-plugins/ok-rules/__fixtures__/no-inline-tolerance-class.fixture.tsx`. Excluded: `packages/md-conformance/**`, `packages/app/tests/fidelity/**`, `packages/core/src/markdown/**/*.test.ts`, `packages/core/src/bridge/**/*.test.ts`, `**/*.private.*`.
-Rule: [`lint-plugins/ok-rules/rules/no-inline-tolerance-class.mjs`](rules/no-inline-tolerance-class.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-inline-tolerance-class.fixture.tsx`](__fixtures__/no-inline-tolerance-class.fixture.tsx). Test: [`packages/app/tests/lint-plugins/no-inline-tolerance-class.test.ts`](../../packages/app/tests/lint-plugins/no-inline-tolerance-class.test.ts). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
+Rule: [`lint-plugins/ok-rules/rules/no-inline-tolerance-class.mjs`](rules/no-inline-tolerance-class.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-inline-tolerance-class.fixture.tsx`](__fixtures__/no-inline-tolerance-class.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-inline-tolerance-class.uncached.test.mjs`](tests/no-inline-tolerance-class.uncached.test.mjs). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
### `require-windowshide-on-spawn`
@@ -478,7 +478,7 @@ Adding a host that needs a different install mechanism? Add it to `HOSTS_WITH_US
Included: `packages/server/src/**/*.ts`, `packages/cli/src/**/*.ts`, `lint-plugins/ok-rules/__fixtures__/no-blind-agent-host-fanout.fixture.tsx`.
-Rule: [`lint-plugins/ok-rules/rules/no-blind-agent-host-fanout.mjs`](rules/no-blind-agent-host-fanout.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-blind-agent-host-fanout.fixture.tsx`](__fixtures__/no-blind-agent-host-fanout.fixture.tsx). Test: [`packages/app/tests/lint-plugins/no-blind-agent-host-fanout.test.ts`](../../packages/app/tests/lint-plugins/no-blind-agent-host-fanout.test.ts). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
+Rule: [`lint-plugins/ok-rules/rules/no-blind-agent-host-fanout.mjs`](rules/no-blind-agent-host-fanout.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-blind-agent-host-fanout.fixture.tsx`](__fixtures__/no-blind-agent-host-fanout.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-blind-agent-host-fanout.uncached.test.mjs`](tests/no-blind-agent-host-fanout.uncached.test.mjs). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
### `no-unwrapped-user-facing-string`
@@ -519,7 +519,7 @@ The rule does NOT catch:
Included: `packages/app/src/**/*.ts`, `packages/app/src/**/*.tsx`, `packages/desktop/src/**/*.ts`, `packages/desktop/src/**/*.tsx`, `packages/plugin/src/**/*.ts`, `packages/plugin/src/**/*.tsx`, `lint-plugins/ok-rules/__fixtures__/no-unwrapped-user-facing-string.fixture.tsx`. Excluded: `packages/app/src/editor/**`, `packages/app/src/components/ui/**`, `packages/desktop/src/main/**`, `**/*.test.ts`, `**/*.test.tsx`, `**/*.dom.test.tsx`.
-Rule: [`lint-plugins/ok-rules/rules/no-unwrapped-user-facing-string.mjs`](rules/no-unwrapped-user-facing-string.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-unwrapped-user-facing-string.fixture.tsx`](__fixtures__/no-unwrapped-user-facing-string.fixture.tsx). Test: [`packages/app/tests/lint-plugins/no-unwrapped-user-facing-string.test.ts`](../../packages/app/tests/lint-plugins/no-unwrapped-user-facing-string.test.ts). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
+Rule: [`lint-plugins/ok-rules/rules/no-unwrapped-user-facing-string.mjs`](rules/no-unwrapped-user-facing-string.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-unwrapped-user-facing-string.fixture.tsx`](__fixtures__/no-unwrapped-user-facing-string.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-unwrapped-user-facing-string.uncached.test.mjs`](tests/no-unwrapped-user-facing-string.uncached.test.mjs). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
### `no-physical-direction-utility`
@@ -547,7 +547,7 @@ The rule does NOT catch:
Included: `packages/app/src/**/*.tsx`, `packages/desktop/src/**/*.tsx`, `packages/plugin/src/**/*.tsx`, `lint-plugins/ok-rules/__fixtures__/no-physical-direction-utility.fixture.tsx`. Excluded: `packages/app/src/editor/**`, `packages/app/src/components/ui/**`, `**/*.test.tsx`, `**/*.dom.test.tsx`.
-Rule: [`lint-plugins/ok-rules/rules/no-physical-direction-utility.mjs`](rules/no-physical-direction-utility.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-physical-direction-utility.fixture.tsx`](__fixtures__/no-physical-direction-utility.fixture.tsx). Test: [`packages/app/tests/lint-plugins/no-physical-direction-utility.test.ts`](../../packages/app/tests/lint-plugins/no-physical-direction-utility.test.ts). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
+Rule: [`lint-plugins/ok-rules/rules/no-physical-direction-utility.mjs`](rules/no-physical-direction-utility.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-physical-direction-utility.fixture.tsx`](__fixtures__/no-physical-direction-utility.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-physical-direction-utility.uncached.test.mjs`](tests/no-physical-direction-utility.uncached.test.mjs). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
### `no-raw-route-hash-construction`
@@ -565,7 +565,7 @@ The rule matches a node's own source text, so a comment, JSX text or a regex lit
Included: `packages/app/src/**/*.ts`, `packages/app/src/**/*.tsx`, `lint-plugins/ok-rules/__fixtures__/no-raw-route-hash-construction.fixture.tsx`. Excluded: `packages/app/src/lib/doc-hash.ts`, `**/*.test.ts`, `**/*.test.tsx`.
-Rule: [`lint-plugins/ok-rules/rules/no-raw-route-hash-construction.mjs`](rules/no-raw-route-hash-construction.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-raw-route-hash-construction.fixture.tsx`](__fixtures__/no-raw-route-hash-construction.fixture.tsx). Test: [`packages/app/src/lint-plugins/no-raw-route-hash-construction.test.ts`](../../packages/app/src/lint-plugins/no-raw-route-hash-construction.test.ts). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
+Rule: [`lint-plugins/ok-rules/rules/no-raw-route-hash-construction.mjs`](rules/no-raw-route-hash-construction.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-raw-route-hash-construction.fixture.tsx`](__fixtures__/no-raw-route-hash-construction.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-raw-route-hash-construction.uncached.test.mjs`](tests/no-raw-route-hash-construction.uncached.test.mjs). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
### `no-demoted-dialog-confirm`
@@ -607,7 +607,7 @@ Suppress a footer that genuinely wants a muted tertiary control alongside a prop
Included: `packages/app/src/**/*.tsx`, `packages/desktop/src/**/*.tsx`, `packages/plugin/src/**/*.tsx`, `lint-plugins/ok-rules/__fixtures__/no-demoted-dialog-confirm.fixture.tsx`. Excluded: `packages/app/src/components/ui/**`, `**/*.test.tsx`, `**/*.dom.test.tsx`.
-Rule: [`lint-plugins/ok-rules/rules/no-demoted-dialog-confirm.mjs`](rules/no-demoted-dialog-confirm.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-demoted-dialog-confirm.fixture.tsx`](__fixtures__/no-demoted-dialog-confirm.fixture.tsx). Test: [`packages/app/tests/lint-plugins/no-demoted-dialog-confirm.test.ts`](../../packages/app/tests/lint-plugins/no-demoted-dialog-confirm.test.ts). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
+Rule: [`lint-plugins/ok-rules/rules/no-demoted-dialog-confirm.mjs`](rules/no-demoted-dialog-confirm.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-demoted-dialog-confirm.fixture.tsx`](__fixtures__/no-demoted-dialog-confirm.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-demoted-dialog-confirm.uncached.test.mjs`](tests/no-demoted-dialog-confirm.uncached.test.mjs). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
### `no-unconverted-git-pathspec`
@@ -635,7 +635,7 @@ It also over-catches, in the same direction. The array branch fires on any array
The behavioural backstop is [`packages/server/src/git-pathspec-name-invariance.test.ts`](../../packages/server/src/git-pathspec-name-invariance.test.ts) and its CLI sibling, which drive real git over hostile filenames end to end.
-Rule: [`lint-plugins/ok-rules/rules/no-unconverted-git-pathspec.mjs`](rules/no-unconverted-git-pathspec.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-unconverted-git-pathspec.fixture.tsx`](__fixtures__/no-unconverted-git-pathspec.fixture.tsx). Test: [`packages/app/tests/lint-plugins/no-unconverted-git-pathspec.test.ts`](../../packages/app/tests/lint-plugins/no-unconverted-git-pathspec.test.ts). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
+Rule: [`lint-plugins/ok-rules/rules/no-unconverted-git-pathspec.mjs`](rules/no-unconverted-git-pathspec.mjs). Fixture: [`lint-plugins/ok-rules/__fixtures__/no-unconverted-git-pathspec.fixture.tsx`](__fixtures__/no-unconverted-git-pathspec.fixture.tsx). Test: [`lint-plugins/ok-rules/tests/no-unconverted-git-pathspec.uncached.test.mjs`](tests/no-unconverted-git-pathspec.uncached.test.mjs). See [PRECEDENTS.md #42](../../PRECEDENTS.md#custom-lint-enforcement-precedent-42) for the custom-rule convention.
### `no-sentinel-signal-target`
@@ -749,7 +749,7 @@ export const ruleName = {
### 2. Register the rule
-Import it in [`index.mjs`](index.mjs), add it to the `declared` map, then switch it on in [`oxlint.config.ts`](../../oxlint.config.ts) as `'ok/<rule-name>': 'error'`.
+Import it in [`index.mjs`](index.mjs), add it to the `declared` map, then switch it on in [`oxlint.config.ts`](../../oxlint.config.ts) as `'ok/<rule-name>': 'error'`, and add the same entry to [`__fixtures__/oxlint.fixtures.json`](__fixtures__/oxlint.fixtures.json), the config the fixture tests lint with.
A small number of rules are registered from a second plugin instead of this one. If the rule you are adding documents a calibrated measurement, an internal file list, or anything else that should not reach a public clone, do not follow this step as written. That path is documented in a maintainers-only checklist that is not part of this clone; if you cannot reach it, open an issue describing what the rule would enforce and leave the registration to a maintainer rather than guessing at the shape.
@@ -763,39 +763,46 @@ Scope lives here rather than in `oxlint.config.ts#overrides` because **oxlint's
### 4. Author the fixture file
-Drop `<rule-name>.fixture.tsx` in `__fixtures__/`, pairing positive cases (must fire) with negative cases (must NOT fire), each labelled. Include a boundary negative: the nearest shape the rule must NOT match. The directory is in `oxlint.config.ts#ignorePatterns` so the deliberately-bad content does not break the main lint; `__fixtures__/oxlint.fixtures.json` re-enables every rule for the tests.
+Drop `<rule-name>.fixture.tsx` in `__fixtures__/`, pairing positive cases (must fire) with negative cases (must NOT fire), each labelled. Include a boundary negative: the nearest shape the rule must NOT match. The directory is in `oxlint.config.ts#ignorePatterns` so the deliberately-bad content does not break the main lint; `__fixtures__/oxlint.fixtures.json` enables the rules the fixture tests lint with, one entry per rule, and `ok-rules-scope-partition.uncached.test.mjs` fails, naming that file, when a registered rule has no `error` entry there.
### 5. Author the fixture-file test
-Put it at `lint-plugins/ok-rules/tests/<rule-name>.uncached.test.mjs`, not in a package. The `.uncached.test` suffix runs it in the uncached cross-package tier (`vitest.uncached.config.ts`): every agent round, CI's `lint` job, and beside every `turbo run test` that runs `server#test`. A package's cached test tier would replay a stale pass when only the rule or `oxlint.config.ts` changed, unless that package's Turbo key hashed both. Write it as plain JavaScript. Shell out to oxlint against the fixture config and assert an exact count:
+Put it at `lint-plugins/ok-rules/tests/<rule-name>.uncached.test.mjs`, not in a package. The `.uncached.test` suffix runs it in the uncached cross-package tier (`vitest.uncached.config.ts`): every agent round, CI's `lint` job, and beside every `turbo run test` that runs `server#test`. A package's cached test tier would replay a stale pass when only the rule or `oxlint.config.ts` changed, unless that package's Turbo key hashed both. The tests in that directory check that every rule the `ok` plugin registers has one. Write it as plain JavaScript.
+
+The tier's global setup, `test-support/ok-rules-fixture-lint.ts`, runs oxlint once over every fixture with the fixture config and hands the report to the tests; a watch-mode rerun lints again. Every rule test fails when that run could not start, exited other than 1, gave no JSON report, linted a different number of files than the directory's `*.fixture.tsx` files, or reported a diagnostic on no fixture. `lintOkRulesFixture` in `test-support/read-ok-rules-config.test-helper.ts` returns one fixture's diagnostics from the report, each with its rule code, `line:column` position and message, in a fixed order. A diagnostic that names no rule (a rule that threw while linting that fixture, or a fixture oxlint could not parse) fails that fixture's test with oxlint's message, as it does the scope meta-test, which reads every fixture. oxlint also drops every other JS-plugin diagnostic on a file where a rule threw, so a rule whose scope reaches other fixtures fails their tests too. Run outside the tier, it fails and prints the command that runs the test. Assert the exact list of your rule's fire positions, filtered by its own code:
```js
-import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
-const FIXTURE = 'lint-plugins/ok-rules/__fixtures__/<rule-name>.fixture.tsx';
-const CONFIG = 'lint-plugins/ok-rules/__fixtures__/oxlint.fixtures.json';
-
-describe('<rule-name> oxlint rule', () => {
- test('fires on exactly N positive cases (and on no negative case)', () => {
- const result = spawnSync('pnpm', ['exec', 'oxlint', '-c', CONFIG, FIXTURE], {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.error).toBeUndefined();
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- expect((output.match(/ok\(<rule-name>\)/g) ?? []).length).toBe(N);
- expect(output).toContain('<fix-noun>');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#<rule-name>');
+const RULE = '<rule-name>';
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its positive cases, by its own code, and on no negative case', () => {
+ const fires = lintOkRulesFixture(FIXTURE).filter((d) => d.code === `ok(${RULE})`);
+ expect(fires.map((fire) => fire.position)).toEqual(['12:5', '18:5']);
+ for (const fire of fires) {
+ expect(fire.message).toContain('<fix-noun>');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(`lint-plugins/ok-rules/README.md#${RULE}`);
+ }
+ });
+
+ test('rule is registered and enabled', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
});
});
```
-Exact equality is the point: it catches false-negative regressions (count drops below N) and false-positive widenings (count rises above N) alike.
+The positions list is the point. Its length is the exact count, so it catches a weakened rule (a positive stops firing) and a widened one (a negative starts firing). It also catches what a count cannot: a rule that stops firing on one positive and starts firing on a negative keeps the same total but changes the list. Filtering by the rule's own code catches a rule registered under the wrong name. A rule with more than one message asserts each fire's branch beside its position, as `no-sentinel-signal-target.uncached.test.mjs` does. After editing the fixture, take the new positions from the failure diff and check each lands on a positive case.
### 6. Verify
@@ -811,8 +818,8 @@ pnpm exec vitest run --config vitest.uncached.config.ts <rule-name>
# restore it; re-run; confirm it passes.
# 4. False-positive widening check (manual, one-time):
-# Add a positive case to the fixture WITHOUT bumping N in the test.
-# Re-run; confirm it FAILS. This verifies toBe(N) is load-bearing.
+# Add a positive case to the fixture WITHOUT adding its position to the test.
+# Re-run; confirm it FAILS. This verifies the positions list is load-bearing.
```
### 7. Document the rule in this README
diff --git a/lint-plugins/ok-rules/__fixtures__/class-proof-registration-discipline.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/class-proof-registration-discipline.fixture.tsx
index 4c58a1031..191bdd0d5 100644
--- a/lint-plugins/ok-rules/__fixtures__/class-proof-registration-discipline.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/class-proof-registration-discipline.fixture.tsx
@@ -1,5 +1,5 @@
-// FIXTURE — drives `class-proof-registration-discipline.test.ts` via
-// shell-out to `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/`
+// FIXTURE — drives `class-proof-registration-discipline.uncached.test.mjs` via
+// shell-out to oxlint. Not part of the main lint: `__fixtures__/`
// is in `oxlint.config.ts#ignorePatterns`, and
// `__fixtures__/oxlint.fixtures.json` re-enables the rules for the test.
//
@@ -17,7 +17,7 @@
// (1 fire — Pattern B diagnostic)
// - Negative cases: 0 fires (must NOT fire)
//
-// Exact-equality (`toBe(3)`) catches both false-negative regressions (drop
+// Exact-equality (the 3-position list) catches both false-negative regressions (drop
// below 3) and false-positive widenings (above 3).
declare const defineClassProof: any;
diff --git a/lint-plugins/ok-rules/__fixtures__/cst-pm-handler-todo-stub.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/cst-pm-handler-todo-stub.fixture.tsx
index 4fe209fa6..6741edf62 100644
--- a/lint-plugins/ok-rules/__fixtures__/cst-pm-handler-todo-stub.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/cst-pm-handler-todo-stub.fixture.tsx
@@ -1,10 +1,10 @@
-// FIXTURE — drives `cst-pm-handler-todo-stub.test.ts` via shell-out
-// to `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in `oxlint.config.ts#ignorePatterns`,
+// FIXTURE — drives `cst-pm-handler-todo-stub.uncached.test.mjs` via shell-out
+// to oxlint. Not part of the main lint: `__fixtures__/` is in `oxlint.config.ts#ignorePatterns`,
// and `__fixtures__/oxlint.fixtures.json` re-enables the rules for the test.
//
// 4 positive cases (deliberate codemod-stub bodies — rule must fire) +
// 4 negative cases (filled-in bodies + non-handler error throws that must
-// NOT fire). Exact-equality (`toBe(4)`) in the test catches both
+// NOT fire). Exact-equality (the 4-position list) in the test catches both
// false-negative regressions (drop below 4) and false-positive widenings
// (above 4).
//
diff --git a/lint-plugins/ok-rules/__fixtures__/microcopy-ellipsis.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/microcopy-ellipsis.fixture.tsx
index 50507581d..664844425 100644
--- a/lint-plugins/ok-rules/__fixtures__/microcopy-ellipsis.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/microcopy-ellipsis.fixture.tsx
@@ -1,4 +1,4 @@
-// FIXTURE — drives `microcopy-ellipsis.test.ts` via shell-out to `pnpm exec oxlint`. Not part
+// FIXTURE — drives `microcopy-ellipsis.uncached.test.mjs` via shell-out to oxlint. Not part
// of the main lint: `__fixtures__/` is in `oxlint.config.ts#ignorePatterns`,
// and `__fixtures__/oxlint.fixtures.json` re-enables the rules for the test.
//
@@ -7,7 +7,7 @@
// attribute — rule must NOT fire).
//
// If you add a new pattern to `rules/microcopy-ellipsis.mjs`, add a matching
-// positive case here and raise the test's exact count.
+// positive case here and add its position to the test.
export function PositiveJsxText() {
return <span>Loading…</span>;
@@ -29,7 +29,7 @@ export function NegativeCleanAttribute() {
// list (placeholder | label | title | aria-label | description | tooltip).
// The rule must NOT fire even though the value contains …. If a future change
// removes the attribute-name filter, this case raises the count above 2 and
-// `toBe(2)` catches the regression.
+// the 2-position list catches the regression.
export function NegativeNonUiAttribute() {
return <div data-raw="Loading…" />;
}
diff --git a/lint-plugins/ok-rules/__fixtures__/no-blind-agent-host-fanout.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-blind-agent-host-fanout.fixture.tsx
index 9cb98b2f4..5542aca25 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-blind-agent-host-fanout.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-blind-agent-host-fanout.fixture.tsx
@@ -1,4 +1,4 @@
-// FIXTURE — drives `no-blind-agent-host-fanout.test.ts` via shell-out to `pnpm exec oxlint`. Not part
+// FIXTURE — drives `no-blind-agent-host-fanout.uncached.test.mjs` via shell-out to oxlint. Not part
// of the main lint: `__fixtures__/` is in `oxlint.config.ts#ignorePatterns`,
// and `__fixtures__/oxlint.fixtures.json` re-enables the rules for the test.
//
@@ -7,7 +7,7 @@
// rule MUST fire) with negative cases (an unrelated `'skills'` word, a
// similarly-spelled flag, a comment mention, a template literal, and a
// concatenation — rule must NOT fire). The fixture-file test asserts the
-// diagnostic count with exact equality (`toBe(5)`) so both a weakened pattern
+// diagnostic count with exact equality (the 5-position list) so both a weakened pattern
// (drops below 5) and a widened pattern that catches a negative (rises above 5)
// fail the gate.
//
diff --git a/lint-plugins/ok-rules/__fixtures__/no-demoted-dialog-confirm.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-demoted-dialog-confirm.fixture.tsx
index 1b307d8f7..32eef73e2 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-demoted-dialog-confirm.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-demoted-dialog-confirm.fixture.tsx
@@ -1,11 +1,11 @@
-// FIXTURE — drives `no-demoted-dialog-confirm.test.ts` via shell-out to
-// `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in
+// FIXTURE — drives `no-demoted-dialog-confirm.uncached.test.mjs` via shell-out to
+// oxlint. Not part of the main lint: `__fixtures__/` is in
// `oxlint.config.ts#ignorePatterns`, and `__fixtures__/oxlint.fixtures.json`
// re-enables the rules for the test.
//
// Three positive cases (deliberate violations — rule must fire) + four
// negative cases (clean usage that must NOT fire). Exact-equality
-// (`toBe(3)`) in the test catches both false-negative regressions (drop
+// (the 3-position list) in the test catches both false-negative regressions (drop
// below 3) and false-positive widenings (above 3).
import { AlertDialogFooter } from '@/components/ui/alert-dialog';
diff --git a/lint-plugins/ok-rules/__fixtures__/no-hand-rolled-branch-validation.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-hand-rolled-branch-validation.fixture.tsx
index 73d866a47..f37b75b01 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-hand-rolled-branch-validation.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-hand-rolled-branch-validation.fixture.tsx
@@ -1,11 +1,11 @@
-// FIXTURE — drives `no-hand-rolled-branch-validation.test.ts` via shell-out to
-// `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in
+// FIXTURE — drives `no-hand-rolled-branch-validation.uncached.test.mjs` via shell-out to
+// oxlint. Not part of the main lint: `__fixtures__/` is in
// `oxlint.config.ts#ignorePatterns`, and `__fixtures__/oxlint.fixtures.json`
// re-enables the rules for the test.
//
// 4 positive cases (deliberate violations — rule must fire) + 4 negative cases
// (sanctioned or unrelated shapes that must NOT fire). Exact-equality
-// (`toBe(4)`) in the test catches both false-negative regressions (drop below
+// (the 4-position list) in the test catches both false-negative regressions (drop below
// 4) and false-positive widenings (above 4).
//
// Positive1 is the load-bearing one: it is the exact pre-fix source line
diff --git a/lint-plugins/ok-rules/__fixtures__/no-hand-rolled-spinner.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-hand-rolled-spinner.fixture.tsx
index 67919efd2..310c58131 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-hand-rolled-spinner.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-hand-rolled-spinner.fixture.tsx
@@ -1,10 +1,10 @@
-// FIXTURE — drives `no-hand-rolled-spinner.test.ts` via shell-out to
-// `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in
+// FIXTURE — drives `no-hand-rolled-spinner.uncached.test.mjs` via shell-out to
+// oxlint. Not part of the main lint: `__fixtures__/` is in
// `oxlint.config.ts#ignorePatterns`, and `__fixtures__/oxlint.fixtures.json`
// re-enables the rules for the test.
//
// 5 positive cases (hand-rolled spins — rule MUST fire) paired with 5 negative
-// cases (rule must NOT fire). The test asserts exact equality (`toBe(5)`) so a
+// cases (rule must NOT fire). The test asserts exact equality (the 5-position list) so a
// weakened predicate drops below 5 and a widened one rises above it.
//
// The boundary cases are the point. `animate-spinner` does NOT fire because the
@@ -49,7 +49,7 @@ export function PositiveSuffixedVariant() {
// wrapping `cn()`), the token sits entirely on one physical line, and the
// predicate reads `sourceCode.getText` of the whole value node, so no
// mutation of the rule separates the two. It is here as a realism sample
-// -- the shape a reader will actually meet -- and it costs `toBe(5)`
+// -- the shape a reader will actually meet -- and it costs the 5-position list
// nothing.
export function PositiveMultiline() {
return (
diff --git a/lint-plugins/ok-rules/__fixtures__/no-inline-tolerance-class.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-inline-tolerance-class.fixture.tsx
index dc3498d73..12344edd4 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-inline-tolerance-class.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-inline-tolerance-class.fixture.tsx
@@ -1,4 +1,4 @@
-// FIXTURE — drives `no-inline-tolerance-class.test.ts` via shell-out to `pnpm exec oxlint`. Not part
+// FIXTURE — drives `no-inline-tolerance-class.uncached.test.mjs` via shell-out to oxlint. Not part
// of the main lint: `__fixtures__/` is in `oxlint.config.ts#ignorePatterns`,
// and `__fixtures__/oxlint.fixtures.json` re-enables the rules for the test.
//
@@ -8,7 +8,7 @@
// a class name appearing only as a SUBSTRING of test-title / docName prose, a
// comment mention, a concatenation, and a non-catalog literal — rule must NOT
// fire). The fixture-file test asserts the diagnostic count with exact equality
-// (`toBe(8)`) so both a weakened pattern (drops below 8) and a widened pattern
+// (the 8-position list) so both a weakened pattern (drops below 8) and a widened pattern
// that catches a negative (rises above 8) fail the gate.
//
// The universal-encoding negatives (`crlf`, `bom`, `trailing-whitespace`,
diff --git a/lint-plugins/ok-rules/__fixtures__/no-loosely-typed-webcontents-ipc.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-loosely-typed-webcontents-ipc.fixture.tsx
index cd8c0cb84..56ffbec28 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-loosely-typed-webcontents-ipc.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-loosely-typed-webcontents-ipc.fixture.tsx
@@ -1,11 +1,11 @@
-// FIXTURE — drives `no-loosely-typed-webcontents-ipc.test.ts` via shell-out
-// to `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in
+// FIXTURE — drives `no-loosely-typed-webcontents-ipc.uncached.test.mjs` via shell-out
+// to oxlint. Not part of the main lint: `__fixtures__/` is in
// `oxlint.config.ts#ignorePatterns`, and `__fixtures__/oxlint.fixtures.json`
// re-enables the rules for the test.
//
// Six positive cases (deliberate violations — rule must fire) + four
// negative cases (clean usage on the same objects — rule must NOT fire).
-// Exact-equality (`toBe(6)`) in the test catches both false-negative
+// Exact-equality (the 6-position list) in the test catches both false-negative
// regressions (drop below 6) and false-positive widenings (above 6).
import type { IpcMain, IpcRenderer, WebContents } from 'electron';
@@ -25,7 +25,7 @@ ipcRenderer.once('ok:test-channel', () => {});
// === Negative cases — adjacent method calls on the same objects ===
// These exercise the precision of the rule. If a future widening
-// matches any of these, the diagnostic count rises above 6 and `toBe(6)`
+// matches any of these, the diagnostic count rises above 6 and the 6-position list
// catches the regression.
// (1) Different method on webContents (e.g., devtools open).
diff --git a/lint-plugins/ok-rules/__fixtures__/no-physical-direction-utility.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-physical-direction-utility.fixture.tsx
index eaab09f36..451d922d1 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-physical-direction-utility.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-physical-direction-utility.fixture.tsx
@@ -1,12 +1,12 @@
-// FIXTURE — drives `no-physical-direction-utility.test.ts` via shell-out to
-// `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in
+// FIXTURE — drives `no-physical-direction-utility.uncached.test.mjs` via shell-out to
+// oxlint. Not part of the main lint: `__fixtures__/` is in
// `oxlint.config.ts#ignorePatterns`, and `__fixtures__/oxlint.fixtures.json`
// re-enables the rules for the test.
//
// Positive cases (deliberate violations — rule must fire) paired with
// negative cases: the logical forms the rule asks for, plus the physical-looking
-// shapes that are direction-correct already and must stay silent. Exact-equality
-// `toBe(N)` in the test catches both a weakened pattern (count drops) and a
+// shapes that are direction-correct already and must stay silent. The exact
+// positions list in the test catches both a weakened pattern (count drops) and a
// widened one (a negative starts firing, count rises).
declare const cn: (...parts: unknown[]) => string;
diff --git a/lint-plugins/ok-rules/__fixtures__/no-raw-html-interactive-element.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-raw-html-interactive-element.fixture.tsx
index ef03c7466..3c423c060 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-raw-html-interactive-element.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-raw-html-interactive-element.fixture.tsx
@@ -1,11 +1,11 @@
-// FIXTURE — drives `no-raw-html-interactive-element.test.ts` via shell-out
-// to `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in
+// FIXTURE — drives `no-raw-html-interactive-element.uncached.test.mjs` via shell-out
+// to oxlint. Not part of the main lint: `__fixtures__/` is in
// `oxlint.config.ts#ignorePatterns`, and `__fixtures__/oxlint.fixtures.json`
// re-enables the rules for the test.
//
// Eight positive cases (deliberate violations — rule must fire) + five
// negative cases (clean usage that must NOT fire). Exact-equality
-// (`toBe(8)`) in the test catches both false-negative regressions (drop
+// (the 8-position list) in the test catches both false-negative regressions (drop
// below 8) and false-positive widenings (above 8).
declare const Button: any;
diff --git a/lint-plugins/ok-rules/__fixtures__/no-raw-route-hash-construction.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-raw-route-hash-construction.fixture.tsx
index 4298678fe..623977fce 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-raw-route-hash-construction.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-raw-route-hash-construction.fixture.tsx
@@ -1,4 +1,4 @@
-// FIXTURE — drives `no-raw-route-hash-construction.test.ts` via shell-out to `pnpm exec oxlint`. Not part
+// FIXTURE — drives `no-raw-route-hash-construction.uncached.test.mjs` via shell-out to oxlint. Not part
// of the main lint: `__fixtures__/` is in `oxlint.config.ts#ignorePatterns`,
// and `__fixtures__/oxlint.fixtures.json` re-enables the rules for the test.
//
diff --git a/lint-plugins/ok-rules/__fixtures__/no-resolved-value-theme-source.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-resolved-value-theme-source.fixture.tsx
index ad143dc7e..bba76686a 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-resolved-value-theme-source.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-resolved-value-theme-source.fixture.tsx
@@ -1,5 +1,5 @@
-// FIXTURE — drives `no-resolved-value-theme-source.test.ts` via shell-out
-// to `pnpm exec oxlint`. Excluded from `pnpm run lint` because `__fixtures__/`
+// FIXTURE — drives `no-resolved-value-theme-source.uncached.test.mjs` via shell-out
+// to oxlint. Excluded from `pnpm run lint` because `__fixtures__/`
// is in `oxlint.config.ts#ignorePatterns`; `__fixtures__/oxlint.fixtures.json`
// re-enables the rules for the test.
//
diff --git a/lint-plugins/ok-rules/__fixtures__/no-roundtrip-identity-oracle.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-roundtrip-identity-oracle.fixture.tsx
index 6d4e617d5..e99b476f1 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-roundtrip-identity-oracle.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-roundtrip-identity-oracle.fixture.tsx
@@ -1,4 +1,4 @@
-// FIXTURE — drives `no-roundtrip-identity-oracle.test.ts` via shell-out to `pnpm exec oxlint`. Not part
+// FIXTURE — drives `no-roundtrip-identity-oracle.uncached.test.mjs` via shell-out to oxlint. Not part
// of the main lint: `__fixtures__/` is in `oxlint.config.ts#ignorePatterns`,
// and `__fixtures__/oxlint.fixtures.json` re-enables the rules for the test.
//
@@ -7,7 +7,7 @@
// Bridge-invariant comparator, the `!==` normalizing-construct detector, the
// helper-wrapped and two-statement round-trip forms — rule must NOT fire).
// The fixture-file test asserts the diagnostic count with exact equality
-// (`toBe(10)`) so both a weakened pattern (drops below 10) and a widened
+// (the 10-position list) so both a weakened pattern (drops below 10) and a widened
// pattern that catches a negative (rises above 10) fail the gate.
//
// Deliberately NOT linted by the main `pnpm run lint` pass (`__fixtures__/` is in
diff --git a/lint-plugins/ok-rules/__fixtures__/no-sentinel-signal-target.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-sentinel-signal-target.fixture.tsx
index 513c65d97..ae2dcd879 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-sentinel-signal-target.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-sentinel-signal-target.fixture.tsx
@@ -1,5 +1,5 @@
// FIXTURE — drives `no-sentinel-signal-target.uncached.test.mjs` via shell-out to
-// `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in
+// oxlint. Not part of the main lint: `__fixtures__/` is in
// `oxlint.config.ts#ignorePatterns`; `__fixtures__/oxlint.fixtures.json`
// re-enables the rules for the test.
//
@@ -25,7 +25,7 @@
// (`-(child.pid as number)` and bare `-spawnedPid`) pass because the rule does not
// check that the child is unreaped, a lifecycle blind spot; and a range-checked
// parsed pid held in a variable passes as data flow the rule cannot see.
-// Exact-equality (`toBe(20)` plus the per-branch counts) catches false-negative
+// Exact-equality (the 20-position list plus the per-branch counts) catches false-negative
// regressions and false-positive widenings alike.
type Signal = 'SIGKILL' | 'SIGTERM';
diff --git a/lint-plugins/ok-rules/__fixtures__/no-split-suggestion-dispatch.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-split-suggestion-dispatch.fixture.tsx
index 8b23cb76c..436d3ad78 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-split-suggestion-dispatch.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-split-suggestion-dispatch.fixture.tsx
@@ -1,4 +1,4 @@
-// FIXTURE — drives `no-split-suggestion-dispatch.test.ts` via shell-out to `pnpm exec oxlint`. Not part
+// FIXTURE — drives `no-split-suggestion-dispatch.uncached.test.mjs` via shell-out to oxlint. Not part
// of the main lint: `__fixtures__/` is in `oxlint.config.ts#ignorePatterns`,
// and `__fixtures__/oxlint.fixtures.json` re-enables the rules for the test.
//
diff --git a/lint-plugins/ok-rules/__fixtures__/no-themeless-pierre-diff.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-themeless-pierre-diff.fixture.tsx
index 27d8c93f5..696486820 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-themeless-pierre-diff.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-themeless-pierre-diff.fixture.tsx
@@ -1,5 +1,5 @@
-// FIXTURE — drives `no-themeless-pierre-diff.test.ts` via shell-out to
-// `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in
+// FIXTURE — drives `no-themeless-pierre-diff.uncached.test.mjs` via shell-out to
+// oxlint. Not part of the main lint: `__fixtures__/` is in
// `oxlint.config.ts#ignorePatterns`, and `__fixtures__/oxlint.fixtures.json`
// re-enables the rules for the test.
//
diff --git a/lint-plugins/ok-rules/__fixtures__/no-unconverted-git-pathspec.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-unconverted-git-pathspec.fixture.tsx
index 5d5113481..66a7ace82 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-unconverted-git-pathspec.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-unconverted-git-pathspec.fixture.tsx
@@ -1,4 +1,4 @@
-// FIXTURE — drives `no-unconverted-git-pathspec.test.ts` via shell-out to `pnpm exec oxlint`. Not
+// FIXTURE — drives `no-unconverted-git-pathspec.uncached.test.mjs` via shell-out to oxlint. Not
// part of the main lint: `__fixtures__/` is in `oxlint.config.ts#ignorePatterns`, and
// `__fixtures__/oxlint.fixtures.json` re-enables the rules for the test.
//
@@ -14,7 +14,7 @@
// comparisons against the `--` token, which are not argv construction at all and are the shape most
// likely to draw a widened pattern.
//
-// The fixture test asserts the diagnostic count with exact equality (`toBe(7)`) so both a weakened
+// The fixture test asserts the diagnostic count with exact equality (the 7-position list) so both a weakened
// pattern (drops below 7) and a widened pattern that catches a negative (rises above 7) fail the
// gate.
//
diff --git a/lint-plugins/ok-rules/__fixtures__/no-uninstall-forbidden-import.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-uninstall-forbidden-import.fixture.tsx
index 97fd39bb9..e0d3a6424 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-uninstall-forbidden-import.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-uninstall-forbidden-import.fixture.tsx
@@ -1,5 +1,5 @@
-// FIXTURE — drives `no-uninstall-forbidden-import.test.ts` via shell-out to
-// `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in
+// FIXTURE — drives `no-uninstall-forbidden-import.uncached.test.mjs` via shell-out to
+// oxlint. Not part of the main lint: `__fixtures__/` is in
// `oxlint.config.ts#ignorePatterns`, and `__fixtures__/oxlint.fixtures.json`
// re-enables the rules for the test.
//
@@ -7,7 +7,7 @@
// forbidden specifier across every import shape (named / default / namespace /
// type / side-effect / subpath) plus a dynamic import. Paired with negative
// cases (clean usage that must NOT fire), including the allowed core package and
-// the plain markdown-render prosemirror/@tiptap libs. Exact-equality (`toBe(13)`)
+// the plain markdown-render prosemirror/@tiptap libs. Exact-equality (the 13-position list)
// in the test catches both false-negative regressions (drop below 13) and
// false-positive widenings (above 13).
diff --git a/lint-plugins/ok-rules/__fixtures__/no-unportaled-editor-content.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-unportaled-editor-content.fixture.tsx
index 5f97f31ef..0906e21fd 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-unportaled-editor-content.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-unportaled-editor-content.fixture.tsx
@@ -1,11 +1,11 @@
-// FIXTURE — drives `no-unportaled-editor-content.test.ts` via shell-out
-// to `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in
+// FIXTURE — drives `no-unportaled-editor-content.uncached.test.mjs` via shell-out
+// to oxlint. Not part of the main lint: `__fixtures__/` is in
// `oxlint.config.ts#ignorePatterns`, and `__fixtures__/oxlint.fixtures.json`
// re-enables the rules for the test.
//
// Three positive cases (deliberate violations — rule must fire) + three
// negative cases (clean usage that must NOT fire). Exact-equality
-// (`toBe(3)`) in the test catches both false-negative regressions (drop
+// (the 3-position list) in the test catches both false-negative regressions (drop
// below 3) and false-positive widenings (above 3).
import { EditorContent, PureEditorContent } from '@tiptap/react';
diff --git a/lint-plugins/ok-rules/__fixtures__/no-unwrapped-user-facing-string.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/no-unwrapped-user-facing-string.fixture.tsx
index 317226750..d15ad0093 100644
--- a/lint-plugins/ok-rules/__fixtures__/no-unwrapped-user-facing-string.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/no-unwrapped-user-facing-string.fixture.tsx
@@ -1,11 +1,11 @@
-// FIXTURE — drives `no-unwrapped-user-facing-string.test.ts` via shell-out to
-// `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in
+// FIXTURE — drives `no-unwrapped-user-facing-string.uncached.test.mjs` via shell-out to
+// oxlint. Not part of the main lint: `__fixtures__/` is in
// `oxlint.config.ts#ignorePatterns`, and `__fixtures__/oxlint.fixtures.json`
// re-enables the rules for the test.
//
// Positive cases (deliberate violations — rule must fire) paired with
// negative cases (already-wrapped copy, and the non-prose token shapes this
-// codebase legitimately writes raw). Exact-equality `toBe(N)` in the test
+// codebase legitimately writes raw). The exact positions list in the test
// catches both a weakened pattern (count drops) and a widened one (a negative
// starts firing, count rises).
diff --git a/lint-plugins/ok-rules/__fixtures__/path-conditional-map-driven-origin.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/path-conditional-map-driven-origin.fixture.tsx
index 62e03b571..ad48c78df 100644
--- a/lint-plugins/ok-rules/__fixtures__/path-conditional-map-driven-origin.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/path-conditional-map-driven-origin.fixture.tsx
@@ -1,10 +1,10 @@
// FIXTURE — drives `path-conditional-map-driven-origin.uncached.test.mjs` via shell-out
-// to `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in
+// to oxlint. Not part of the main lint: `__fixtures__/` is in
// `oxlint.config.ts#ignorePatterns`, and `__fixtures__/oxlint.fixtures.json`
// re-enables the rules for the test.
//
// 7 positive cases (deliberate violations — rule must fire) + 3 negative
-// cases (sanctioned shapes that must NOT fire). Exact-equality (`toBe(7)`) in
+// cases (sanctioned shapes that must NOT fire). Exact-equality (the 7-position list) in
// the test catches both false-negative regressions (drop below 7) and
// false-positive widenings (above 7).
//
diff --git a/lint-plugins/ok-rules/__fixtures__/playwright-prefer-to-have-count.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/playwright-prefer-to-have-count.fixture.tsx
index a4b27044a..e3f27d9e0 100644
--- a/lint-plugins/ok-rules/__fixtures__/playwright-prefer-to-have-count.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/playwright-prefer-to-have-count.fixture.tsx
@@ -1,11 +1,11 @@
-// FIXTURE — drives `playwright-prefer-to-have-count.test.ts` via shell-out to `pnpm exec oxlint`. Not part
+// FIXTURE — drives `playwright-prefer-to-have-count.uncached.test.mjs` via shell-out to oxlint. Not part
// of the main lint: `__fixtures__/` is in `oxlint.config.ts#ignorePatterns`,
// and `__fixtures__/oxlint.fixtures.json` re-enables the rules for the test.
//
// 3 positive cases (one-shot count reads — rule MUST fire) paired with
// 5 negative cases (web-first / legitimately different shapes — rule
// must NOT fire). The fixture-file test asserts the diagnostic count with
-// exact equality (`toBe(3)`) so both weakened-pattern and widened-pattern
+// exact equality (the 3-position list) so both weakened-pattern and widened-pattern
// drift fail the gate.
//
// Deliberately NOT linted by the main `pnpm run lint` pass (`__fixtures__/` is in
diff --git a/lint-plugins/ok-rules/__fixtures__/require-utf8-multipart-parser.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/require-utf8-multipart-parser.fixture.tsx
index cf57310f2..2257c1048 100644
--- a/lint-plugins/ok-rules/__fixtures__/require-utf8-multipart-parser.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/require-utf8-multipart-parser.fixture.tsx
@@ -1,5 +1,5 @@
// FIXTURE — drives `require-utf8-multipart-parser.uncached.test.mjs` via shell-out to
-// `pnpm exec oxlint`. The rule's scope entry self-includes this fixture, so the
+// oxlint. The rule's scope entry self-includes this fixture, so the
// rule DOES apply here; what keeps the 3 fires below out of a normal
// `pnpm run lint` is that `__fixtures__/` is in `oxlint.config.ts#ignorePatterns`,
// which `__fixtures__/oxlint.fixtures.json` re-enables for the test.
@@ -14,7 +14,7 @@
// Negatives (0 fires): the sanctioned `createMultipartParser(...)` call, a
// `ReturnType<typeof busboy>` type annotation (the form a call site uses to
// name a parser's type without constructing one), a member call, and an
-// unrelated identifier. Exact-equality (`toBe(3)`) catches false-negative regressions
+// unrelated identifier. Exact-equality (the 3-position list) catches false-negative regressions
// (< 3) and false-positive widenings (> 3) - the type-annotation negative in
// particular guards against a pattern change that starts matching type positions.
//
diff --git a/lint-plugins/ok-rules/__fixtures__/require-windowshide-on-spawn.fixture.tsx b/lint-plugins/ok-rules/__fixtures__/require-windowshide-on-spawn.fixture.tsx
index 41316434a..6a508701c 100644
--- a/lint-plugins/ok-rules/__fixtures__/require-windowshide-on-spawn.fixture.tsx
+++ b/lint-plugins/ok-rules/__fixtures__/require-windowshide-on-spawn.fixture.tsx
@@ -1,5 +1,5 @@
// FIXTURE — drives `require-windowshide-on-spawn.uncached.test.mjs` via shell-out to
-// `pnpm exec oxlint`. Not part of the main lint: `__fixtures__/` is in
+// oxlint. Not part of the main lint: `__fixtures__/` is in
// `oxlint.config.ts#ignorePatterns`; the fixture is named in the rule's scope
// entry, and `__fixtures__/oxlint.fixtures.json` re-enables the rules for the test.
//
@@ -13,7 +13,7 @@
// Negatives (0 fires): inline `windowsHide: true`, the `withHiddenWindowsConsole`
// helper (both the options-wrapping and the no-options `({})` forms), a member
// call (`deps.spawn` — different AST), a differently-named helper, and bare
-// `exec` (intentionally outside the matcher). Exact-equality (`toBe(7)`)
+// `exec` (intentionally outside the matcher). Exact-equality (the 7-position list)
// catches false-negative regressions (< 7) and false-positive widenings (> 7).
type Opts = Record<string, unknown>;
diff --git a/lint-plugins/ok-rules/tests/class-proof-registration-discipline.uncached.test.mjs b/lint-plugins/ok-rules/tests/class-proof-registration-discipline.uncached.test.mjs
new file mode 100644
index 000000000..0a667c83c
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/class-proof-registration-discipline.uncached.test.mjs
@@ -0,0 +1,73 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'class-proof-registration-discipline';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+const BRANCHES = [
+ [
+ 'missing',
+ 'Class-proof registration missing `predicate` or `proof` option',
+ 'Provide all three of `{ enumerate, predicate, proof }`',
+ ],
+ [
+ 'location',
+ 'Class-proof registered outside the canonical dir',
+ 'packages/md-conformance/src/class-proofs/proofs/<name>.ts',
+ ],
+];
+
+function branchOf(message) {
+ return BRANCHES.find(([, marker]) => message.includes(marker))?.[0] ?? 'unknown';
+}
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 3 positive cases: 2 missing-args and 1 outside-canonical, each on its branch, by its own code', () => {
+ const found = fires();
+ expect(found.map((fire) => `${fire.position} ${branchOf(fire.message)}`)).toEqual([
+ '32:41 missing',
+ '38:37 missing',
+ '46:43 location',
+ ]);
+ for (const fire of found) {
+ const [, , fix] = BRANCHES.find(([name]) => name === branchOf(fire.message));
+ expect(fire.message).toContain(fix);
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
+ [
+ '**/*.ts',
+ '**/*.tsx',
+ '**/*.mts',
+ '!**/node_modules/**',
+ '!**/dist/**',
+ '!**/*.test.ts',
+ '!**/*.test.tsx',
+ '!**/*.test.mts',
+ '!packages/md-conformance/src/class-proofs/proofs/**',
+ FIXTURE,
+ ].sort(),
+ );
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/cst-pm-handler-todo-stub.uncached.test.mjs b/lint-plugins/ok-rules/tests/cst-pm-handler-todo-stub.uncached.test.mjs
new file mode 100644
index 000000000..98b73c267
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/cst-pm-handler-todo-stub.uncached.test.mjs
@@ -0,0 +1,43 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'cst-pm-handler-todo-stub';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 4 codemod stubs, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual(['23:3', '28:3', '33:3', '38:3']);
+ for (const fire of found) {
+ expect(fire.message).toContain('Codemod-emitted handler stub still throws TODO marker');
+ expect(fire.message).toContain('fill in the substrate-specific body');
+ expect(fire.message).toContain('ICstEngine');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
+ ['packages/md-conformance/src/substrates/*/handlers/**/*.ts', FIXTURE].sort(),
+ );
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/microcopy-ellipsis.uncached.test.mjs b/lint-plugins/ok-rules/tests/microcopy-ellipsis.uncached.test.mjs
new file mode 100644
index 000000000..4920a315a
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/microcopy-ellipsis.uncached.test.mjs
@@ -0,0 +1,46 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'microcopy-ellipsis';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+const BRANCHES = [
+ ['text', 'Reserve U+2026 for macOS native menus', 'drop the trailing'],
+ ['attribute', 'from this UI-facing attribute', 'drop the trailing'],
+];
+
+function branchOf(message) {
+ return BRANCHES.find(([, marker]) => message.includes(marker))?.[0] ?? 'unknown';
+}
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 2 positive cases, each on its branch, by its own code', () => {
+ const found = fires();
+ expect(found.map((fire) => `${fire.position} ${branchOf(fire.message)}`)).toEqual([
+ '13:16 text',
+ '17:29 attribute',
+ ]);
+ for (const fire of found) {
+ const [, , fix] = BRANCHES.find(([name]) => name === branchOf(fire.message));
+ expect(fire.message).toContain(fix);
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and deliberately unscoped', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-blind-agent-host-fanout.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-blind-agent-host-fanout.uncached.test.mjs
new file mode 100644
index 000000000..9a5a02eff
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-blind-agent-host-fanout.uncached.test.mjs
@@ -0,0 +1,64 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+import { FORBIDDEN_SPECS } from '../rules/no-blind-agent-host-fanout.mjs';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-blind-agent-host-fanout';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 5 planted positives, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual([
+ '29:23',
+ '30:23',
+ '31:23',
+ '32:23',
+ '35:29',
+ ]);
+ for (const fire of found) {
+ expect(fire.message).toContain('User-global skill installs must be gated on detected hosts');
+ expect(fire.message).toContain('detectUserSkillHosts');
+ expect(fire.message).toContain('HOSTS_WITH_USER_SKILL_DIR');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ expect(readRuleScope(REPO_ROOT, RULE)).not.toEqual([]);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ const scope = readRuleScope(REPO_ROOT, RULE);
+ expect(scope).toContain(FIXTURE);
+ expect(scope).toContain('packages/server/src/**/*.ts');
+ expect(scope).toContain('packages/cli/src/**/*.ts');
+ for (const excluded of ['!**/*.test.ts', '!**/*.test-helper.ts']) {
+ expect(scope).not.toContain(excluded);
+ }
+ });
+
+ test('bans every range shape of the spec, not just the one that shipped', () => {
+ const matched = [...FORBIDDEN_SPECS].sort();
+ expect(matched.length).toBeGreaterThan(0);
+ for (const spec of ['skills@~1.5.0', 'skills@^1.5.0', '[email protected]', 'skills@latest']) {
+ expect(matched).toContain(spec);
+ }
+ expect(matched).toContain('--agent');
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-demoted-dialog-confirm.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-demoted-dialog-confirm.uncached.test.mjs
new file mode 100644
index 000000000..ed38d6230
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-demoted-dialog-confirm.uncached.test.mjs
@@ -0,0 +1,50 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-demoted-dialog-confirm';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 3 demoted dialog footers, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual(['26:5', '41:5', '55:5']);
+ for (const fire of found) {
+ expect(fire.message).toContain('Demoted confirm in a dialog footer');
+ expect(fire.message).toContain('Drop the variant prop');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped to product chrome', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
+ [
+ 'packages/app/src/**/*.tsx',
+ 'packages/desktop/src/**/*.tsx',
+ 'packages/plugin/src/**/*.tsx',
+ '!packages/app/src/components/ui/**',
+ '!**/*.test.tsx',
+ '!**/*.dom.test.tsx',
+ FIXTURE,
+ ].sort(),
+ );
+ });
+});
diff --git a/packages/app/tests/lint-plugins/no-hand-rolled-branch-validation.test.ts b/lint-plugins/ok-rules/tests/no-hand-rolled-branch-validation.uncached.test.mjs
similarity index 51%
rename from packages/app/tests/lint-plugins/no-hand-rolled-branch-validation.test.ts
rename to lint-plugins/ok-rules/tests/no-hand-rolled-branch-validation.uncached.test.mjs
index 8eb065fba..e41613721 100644
--- a/packages/app/tests/lint-plugins/no-hand-rolled-branch-validation.test.ts
+++ b/lint-plugins/ok-rules/tests/no-hand-rolled-branch-validation.uncached.test.mjs
@@ -1,37 +1,34 @@
-/** The `no-hand-rolled-branch-validation` oxlint rule fixture test, per precedent #42. */
-
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
+import { fileURLToPath } from 'node:url';
import { describe, expect, test } from 'vitest';
-import { BRANCH_IDENTIFIER_RE } from '../../../../lint-plugins/ok-rules/rules/no-hand-rolled-branch-validation.mjs';
-import { isInScope } from '../../../../lint-plugins/ok-rules/scope.mjs';
import {
- oxlintFixtureArgs,
+ lintOkRulesFixture,
readEnabledRuleIds,
readRegisteredRuleNames,
readRuleScope,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+import { BRANCH_IDENTIFIER_RE } from '../rules/no-hand-rolled-branch-validation.mjs';
+import { isInScope } from '../scope.mjs';
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
const RULE = 'no-hand-rolled-branch-validation';
-const FIXTURE_REL =
- 'lint-plugins/ok-rules/__fixtures__/no-hand-rolled-branch-validation.fixture.tsx';
-const GUARD_REL = 'packages/server/src/http/history-routes.ts';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
-describe('no-hand-rolled-branch-validation oxlint rule', () => {
- test('fires on exactly 4 planted positives (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.error).toBeUndefined();
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (output.match(/Hand-rolled branch-name validation/g) ?? []).length;
- expect(fires).toBe(4);
- expect(output).toContain('isValidBranchName');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-hand-rolled-branch-validation');
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 4 planted positives, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual(['29:33', '37:10', '42:10', '48:10']);
+ for (const fire of found) {
+ expect(fire.message).toContain('Hand-rolled branch-name validation');
+ expect(fire.message).toContain('isValidBranchName');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
});
test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
@@ -42,12 +39,12 @@ describe('no-hand-rolled-branch-validation oxlint rule', () => {
test('its scope table still carries every include and exclude the rule depends on', () => {
expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
- ['packages/server/src/**/*.ts', '!**/*.test.ts', '!**/*.test-helper.ts', FIXTURE_REL].sort(),
+ ['packages/server/src/**/*.ts', '!**/*.test.ts', '!**/*.test-helper.ts', FIXTURE].sort(),
);
});
test('covers the guard it was promoted for, and neither definition site of the contract', () => {
- expect(isInScope(RULE, GUARD_REL)).toBe(true);
+ expect(isInScope(RULE, 'packages/server/src/http/history-routes.ts')).toBe(true);
expect(isInScope(RULE, 'packages/core/src/schemas/api/share.ts')).toBe(false);
expect(isInScope(RULE, 'docs/src/lib/share-splash.ts')).toBe(false);
expect(isInScope(RULE, 'packages/server/src/http/history-routes.test.ts')).toBe(false);
diff --git a/lint-plugins/ok-rules/tests/no-hand-rolled-spinner.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-hand-rolled-spinner.uncached.test.mjs
new file mode 100644
index 000000000..581b1ad99
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-hand-rolled-spinner.uncached.test.mjs
@@ -0,0 +1,52 @@
+import { readFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-hand-rolled-spinner';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 5 hand-rolled spins, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual([
+ '28:25',
+ '33:25',
+ '38:33',
+ '44:25',
+ '57:17',
+ ]);
+ for (const fire of found) {
+ expect(fire.message).toContain('Hand-rolled loading spinner');
+ expect(fire.message).toContain('@/components/ui/spinner');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and deliberately unscoped', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+
+ test('the word boundary admits a suffixed variant but not a longer token', () => {
+ const source = readFileSync(join(REPO_ROOT, FIXTURE), 'utf-8').split('\n');
+ const flagged = fires()
+ .map((fire) => source[Number(fire.position.split(':')[0]) - 1])
+ .join('\n');
+ expect(flagged).toContain('animate-spin-slow');
+ expect(flagged).not.toContain('animate-spinner');
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-hand-rolled-test-file-suffix.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-hand-rolled-test-file-suffix.uncached.test.mjs
index e1d06a452..b24d4b892 100644
--- a/lint-plugins/ok-rules/tests/no-hand-rolled-test-file-suffix.uncached.test.mjs
+++ b/lint-plugins/ok-rules/tests/no-hand-rolled-test-file-suffix.uncached.test.mjs
@@ -4,6 +4,7 @@ import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, test } from 'vitest';
import {
+ lintOkRulesFixture,
readEnabledRuleIds,
readRegisteredRuleNames,
readRuleScope,
@@ -34,22 +35,32 @@ function lint(args) {
describe('shared test-file predicate enforcement', () => {
test('fires on all 15 positives and none of the adjacent negatives', () => {
+ const fires = lintOkRulesFixture(FIXTURE).filter((fire) => fire.code === `ok(${RULE})`);
+ expect(fires.map((fire) => fire.position)).toEqual([
+ '6:20',
+ '7:21',
+ '8:20',
+ '9:20',
+ '11:20',
+ '12:20',
+ '13:20',
+ '14:20',
+ '15:20',
+ '16:20',
+ '17:20',
+ '18:20',
+ '19:20',
+ '20:20',
+ '21:20',
+ ]);
const source = readFileSync(join(ROOT, FIXTURE), 'utf8').split('\n');
- const expectedLines = source.flatMap((line, index) =>
+ const positiveLines = source.flatMap((line, index) =>
/^export const p\d+ =/.test(line) ? [index + 1] : [],
);
- expect(expectedLines).toHaveLength(15);
- const { status, diagnostics } = lint([
- '-c',
- 'lint-plugins/ok-rules/__fixtures__/oxlint.fixtures.json',
- FIXTURE,
- ]);
- expect(status).toBe(1);
- expect(diagnostics).toHaveLength(15);
- expect(diagnostics.map((diagnostic) => diagnostic.labels[0].span.line)).toEqual(expectedLines);
- for (const diagnostic of diagnostics) {
- expect(diagnostic.message).toContain('Use isTestOnlySourceFile');
- expect(diagnostic.message).toContain(`${README}#${RULE}`);
+ expect(fires.map((fire) => Number(fire.position.split(':')[0]))).toEqual(positiveLines);
+ for (const fire of fires) {
+ expect(fire.message).toContain('Use isTestOnlySourceFile');
+ expect(fire.message).toContain(`${README}#${RULE}`);
}
});
diff --git a/lint-plugins/ok-rules/tests/no-inline-tolerance-class.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-inline-tolerance-class.uncached.test.mjs
new file mode 100644
index 000000000..67b6e3852
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-inline-tolerance-class.uncached.test.mjs
@@ -0,0 +1,79 @@
+import { readFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+import { MATCHED_FIDELITY_CLASSES } from '../rules/no-inline-tolerance-class.mjs';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-inline-tolerance-class';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 8 inline fidelity-class literals, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual([
+ '30:18',
+ '33:5',
+ '34:5',
+ '35:5',
+ '36:5',
+ '39:24',
+ '41:31',
+ '43:31',
+ ]);
+ for (const fire of found) {
+ expect(fire.message).toContain('Inline bridge normalization-class value in a public test');
+ expect(fire.message).toContain('hard-coding a BRIDGE_TOLERANCE_CLASSES label');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped to the public test surface', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
+ [
+ 'packages/**/*.test.ts',
+ 'packages/**/*.test.tsx',
+ 'packages/**/*.e2e.ts',
+ '!packages/md-conformance/**',
+ '!packages/app/tests/fidelity/**',
+ '!packages/core/src/markdown/**/*.test.ts',
+ '!packages/core/src/bridge/**/*.test.ts',
+ '!**/*.private.*',
+ FIXTURE,
+ ].sort(),
+ );
+ });
+
+ test('matched fidelity set + universal-encoding set partition BRIDGE_TOLERANCE_CLASSES', () => {
+ const universalEncoding = ['bom', 'crlf', 'trailing-whitespace', 'trailing-newline'];
+ const catalogSrc = readFileSync(
+ join(REPO_ROOT, 'packages/core/src/bridge/normalize.ts'),
+ 'utf-8',
+ );
+ const arrayBody = catalogSrc.match(/BRIDGE_TOLERANCE_CLASSES\s*=\s*\[([\s\S]*?)\]/)?.[1];
+ expect(arrayBody).toBeDefined();
+ const catalog = [...(arrayBody ?? '').matchAll(/'([^']+)'/g)].map((m) => m[1]).sort();
+ expect(catalog.length).toBeGreaterThan(0);
+ const matched = [...MATCHED_FIDELITY_CLASSES].sort();
+ expect(matched.filter((c) => universalEncoding.includes(c))).toEqual([]);
+ expect([...new Set([...matched, ...universalEncoding])].sort()).toEqual(catalog);
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-loosely-typed-webcontents-ipc.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-loosely-typed-webcontents-ipc.uncached.test.mjs
new file mode 100644
index 000000000..70dbc0d40
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-loosely-typed-webcontents-ipc.uncached.test.mjs
@@ -0,0 +1,42 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-loosely-typed-webcontents-ipc';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 6 banned primitives, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual([
+ '19:1',
+ '20:1',
+ '21:1',
+ '22:6',
+ '23:1',
+ '24:1',
+ ]);
+ for (const fire of found) {
+ expect(fire.message).toContain('Direct electron IPC primitive');
+ expect(fire.message).toContain('route through createInvoker');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and deliberately unscoped', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-physical-direction-utility.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-physical-direction-utility.uncached.test.mjs
new file mode 100644
index 000000000..702a0b7f9
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-physical-direction-utility.uncached.test.mjs
@@ -0,0 +1,101 @@
+import { readFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-physical-direction-utility';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 7 physical direction utilities, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual([
+ '25:25',
+ '33:17',
+ '43:25',
+ '49:25',
+ '55:25',
+ '61:36',
+ '67:25',
+ ]);
+ for (const fire of found) {
+ expect(fire.message).toContain('Physical direction utility');
+ expect(fire.message).toContain('Use the logical equivalent');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped to the chrome', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
+ [
+ 'packages/app/src/**/*.tsx',
+ 'packages/desktop/src/**/*.tsx',
+ 'packages/plugin/src/**/*.tsx',
+ '!packages/app/src/editor/**',
+ '!packages/app/src/components/ui/**',
+ '!**/*.test.tsx',
+ '!**/*.dom.test.tsx',
+ FIXTURE,
+ ].sort(),
+ );
+ });
+
+ function flaggedSource() {
+ const fixture = readFileSync(join(REPO_ROOT, FIXTURE), 'utf-8').split('\n');
+ const lines = fires().map((fire) => Number(fire.position.split(':')[0]));
+ expect(lines.length).toBeGreaterThan(0);
+ return lines.map((n) => fixture.slice(n - 1, n + 2).join('\n')).join('\n');
+ }
+
+ test('every positive case is reported', () => {
+ const flagged = flaggedSource();
+ for (const token of [
+ 'ml-2 flex items-center',
+ "isCompact && 'pr-1.5'",
+ 'absolute top-2 right-2',
+ 'pl-[var(--ok-example-reserve,1rem)]',
+ 'ml-auto shrink-0',
+ 'containerClassName="bottom-3 left-3',
+ 'sm:-mr-1',
+ ]) {
+ expect(flagged).toContain(token);
+ }
+ });
+
+ test('no negative case is reported', () => {
+ const flagged = flaggedSource();
+ for (const token of [
+ 'ms-2 me-1.5 ps-6 pe-2',
+ 'start-0 end-2',
+ 'inset-x-0',
+ 'left-1/2',
+ 'mt-2 mb-2 inset-0',
+ 'data-side=left',
+ 'edge="right"',
+ 'data-token="ml-4"',
+ 'title="Row indent is pl-2"',
+ 'token="pr-1.5"',
+ ]) {
+ expect(flagged).not.toContain(token);
+ }
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-raw-html-interactive-element.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-raw-html-interactive-element.uncached.test.mjs
new file mode 100644
index 000000000..e4a460707
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-raw-html-interactive-element.uncached.test.mjs
@@ -0,0 +1,61 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-raw-html-interactive-element';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 8 positive cases, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual([
+ '22:10',
+ '27:10',
+ '32:10',
+ '37:10',
+ '42:10',
+ '47:10',
+ '55:5',
+ '64:10',
+ ]);
+ for (const fire of found) {
+ expect(fire.message).toContain('Raw HTML interactive primitive');
+ expect(fire.message).toContain('use shadcn Button/Input/Textarea/Select');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
+ [
+ 'packages/app/src/**/*.tsx',
+ 'packages/desktop/src/**/*.tsx',
+ 'packages/plugin/src/**/*.tsx',
+ '!packages/app/src/editor/**',
+ '!packages/app/src/components/ui/**',
+ '!**/*.test.tsx',
+ '!**/*.dom.test.tsx',
+ '!**/*.test-helper.tsx',
+ FIXTURE,
+ ].sort(),
+ );
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-raw-route-hash-construction.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-raw-route-hash-construction.uncached.test.mjs
new file mode 100644
index 000000000..fb66f806e
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-raw-route-hash-construction.uncached.test.mjs
@@ -0,0 +1,56 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-raw-route-hash-construction';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 5 hand-built hashes, none on the read forms, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual([
+ '17:19',
+ '20:19',
+ '23:19',
+ '26:19',
+ '33:14',
+ ]);
+ for (const fire of found) {
+ expect(fire.message).toContain('Raw route-hash construction');
+ expect(fire.message).toContain('hashFromDocName');
+ expect(fire.message).toContain('hashFromFolderPath');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped with doc-hash.ts excluded', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
+ [
+ 'packages/app/src/**/*.ts',
+ 'packages/app/src/**/*.tsx',
+ '!packages/app/src/lib/doc-hash.ts',
+ '!**/*.test.ts',
+ '!**/*.test.tsx',
+ FIXTURE,
+ ].sort(),
+ );
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-resolved-value-theme-source.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-resolved-value-theme-source.uncached.test.mjs
new file mode 100644
index 000000000..4251ba0a4
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-resolved-value-theme-source.uncached.test.mjs
@@ -0,0 +1,47 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-resolved-value-theme-source';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+const BRANCHES = [
+ ['matchMedia', 'matchMedia inside setThemeSource argument', 'pass the unresolved CRDT value'],
+ ['literal', "resolves to 'light'/'dark' literals", 'pass the unresolved CRDT value'],
+];
+
+function branchOf(message) {
+ return BRANCHES.find(([, marker]) => message.includes(marker))?.[0] ?? 'unknown';
+}
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 3 positive cases, each on its branch, by its own code', () => {
+ const found = fires();
+ expect(found.map((fire) => `${fire.position} ${branchOf(fire.message)}`)).toEqual([
+ '21:1 matchMedia',
+ '24:1 literal',
+ '27:1 literal',
+ ]);
+ for (const fire of found) {
+ const [, , fix] = BRANCHES.find(([name]) => name === branchOf(fire.message));
+ expect(fire.message).toContain(fix);
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and deliberately unscoped', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-roundtrip-identity-oracle.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-roundtrip-identity-oracle.uncached.test.mjs
new file mode 100644
index 000000000..f9fe883e4
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-roundtrip-identity-oracle.uncached.test.mjs
@@ -0,0 +1,63 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-roundtrip-identity-oracle';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 10 byte-identity oracle assertions, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual([
+ '38:3',
+ '39:3',
+ '40:3',
+ '42:3',
+ '43:3',
+ '44:3',
+ '46:15',
+ '47:15',
+ '49:15',
+ '50:15',
+ ]);
+ for (const fire of found) {
+ expect(fire.message).toContain('Byte-fidelity round-trip oracle in a public test');
+ expect(fire.message).toContain('assert a fixed expected literal for a specific contract');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped to the public test surface', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
+ [
+ 'packages/**/*.test.ts',
+ 'packages/**/*.test.tsx',
+ 'packages/**/*.e2e.ts',
+ '!packages/md-conformance/**',
+ '!packages/app/tests/fidelity/**',
+ '!packages/core/src/markdown/**/*.test.ts',
+ '!packages/core/src/bridge/**/*.test.ts',
+ '!**/*.private.*',
+ FIXTURE,
+ ].sort(),
+ );
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-sentinel-signal-target.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-sentinel-signal-target.uncached.test.mjs
index 9448cac12..d864b39ed 100644
--- a/lint-plugins/ok-rules/tests/no-sentinel-signal-target.uncached.test.mjs
+++ b/lint-plugins/ok-rules/tests/no-sentinel-signal-target.uncached.test.mjs
@@ -1,11 +1,9 @@
-import { spawnSync } from 'node:child_process';
import { existsSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, test } from 'vitest';
import {
- oxlintFixtureArgs,
- parseOxlintDiagnostics,
+ lintOkRulesFixture,
readEnabledRuleIds,
readRegisteredRuleNames,
readRuleScope,
@@ -13,43 +11,57 @@ import {
const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
const RULE = 'no-sentinel-signal-target';
-const FIXTURE_REL = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
-const README_REL = 'lint-plugins/ok-rules/README.md';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const README = 'lint-plugins/ok-rules/README.md';
+const DOCS = `${README}#${RULE}`;
+const BRANCHES = [
+ ['literal', 'Signal only a pid you spawned'],
+ ['fallback', 'Filter the nullable pid out'],
+ ['parsed', 'Signal the `ChildProcess` you spawned'],
+];
-function lintFixture() {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- windowsHide: true,
- maxBuffer: 64 * 1024 * 1024,
- });
- expect(result.error).toBeUndefined();
- expect(typeof result.status).toBe('number');
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- return parseOxlintDiagnostics(output).filter((d) => d.code === `ok(${RULE})`);
+function branchOf(message) {
+ return BRANCHES.find(([, marker]) => message.includes(marker))?.[0] ?? 'unknown';
}
-describe('no-sentinel-signal-target oxlint rule', () => {
- test('fires exactly 20 times, split 10 literal / 4 fallback / 6 parsed, and on no negative case', () => {
- const fires = lintFixture();
- expect(fires.length).toBe(20);
- const literal = fires.filter((d) => d.message.includes('Signal only a pid you spawned'));
- const fallback = fires.filter((d) => d.message.includes('Filter the nullable pid out'));
- const parsed = fires.filter((d) => d.message.includes('Signal the `ChildProcess` you spawned'));
- expect(literal.length).toBe(10);
- expect(fallback.length).toBe(4);
- expect(parsed.length).toBe(6);
- for (const fire of fires) {
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 20 positive cases, each on its branch, by its own code', () => {
+ const found = fires();
+ expect(found.map((fire) => `${fire.position} ${branchOf(fire.message)}`)).toEqual([
+ '61:19 literal',
+ '62:19 literal',
+ '63:19 literal',
+ '64:19 fallback',
+ '65:19 fallback',
+ '66:19 parsed',
+ '67:19 parsed',
+ '68:19 literal',
+ '69:19 literal',
+ '70:20 fallback',
+ '71:20 literal',
+ '72:20 literal',
+ '73:20 fallback',
+ '74:20 parsed',
+ '75:20 parsed',
+ '76:20 parsed',
+ '77:20 parsed',
+ '78:20 literal',
+ '79:20 literal',
+ '80:20 literal',
+ ]);
+ for (const fire of found) {
expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
- expect(fire.message).toContain(`${README_REL}#${RULE}`);
+ expect(fire.message).toContain(DOCS);
}
});
test('the literal remedy sanctions a handle-derived pid negated for its group and names the detached precondition', () => {
- const literal = lintFixture().filter((d) =>
- d.message.includes('Signal only a pid you spawned'),
- );
+ const literal = fires().filter((fire) => branchOf(fire.message) === 'literal');
expect(literal.length).toBe(10);
for (const fire of literal) {
expect(fire.message).toContain('its pid taken from that handle');
@@ -58,9 +70,7 @@ describe('no-sentinel-signal-target oxlint rule', () => {
});
test('the parsed remedy names the handle you spawned and, for a pid you hold no handle for, its owner or a report', () => {
- const parsed = lintFixture().filter((d) =>
- d.message.includes('Signal the `ChildProcess` you spawned'),
- );
+ const parsed = fires().filter((fire) => branchOf(fire.message) === 'parsed');
expect(parsed.length).toBe(6);
for (const fire of parsed) {
expect(fire.message).toContain('stop that process through its owner, or report it');
@@ -68,13 +78,11 @@ describe('no-sentinel-signal-target oxlint rule', () => {
});
test('every fire lands on a positive case and none on the negatives', () => {
- const source = readFileSync(join(REPO_ROOT, FIXTURE_REL), 'utf8').split('\n');
- const firedLines = lintFixture()
- .map((d) => d.labels?.[0]?.span?.line)
- .filter((line) => typeof line === 'number');
- expect(firedLines.length).toBe(20);
- for (const line of firedLines) {
- expect(source[line - 1]).toMatch(/^export const p\d+ = /);
+ const source = readFileSync(join(REPO_ROOT, FIXTURE), 'utf8').split('\n');
+ const found = fires();
+ expect(found.length).toBe(20);
+ for (const fire of found) {
+ expect(source[Number(fire.position.split(':')[0]) - 1]).toMatch(/^export const p\d+ = /);
}
});
@@ -85,7 +93,7 @@ describe('no-sentinel-signal-target oxlint rule', () => {
});
test('the README carries a heading for the rule, and the rule module exists', () => {
- const readme = readFileSync(join(REPO_ROOT, README_REL), 'utf8');
+ const readme = readFileSync(join(REPO_ROOT, README), 'utf8');
expect(readme).toContain(`### \`${RULE}\``);
expect(existsSync(join(REPO_ROOT, `lint-plugins/ok-rules/rules/${RULE}.mjs`))).toBe(true);
});
diff --git a/lint-plugins/ok-rules/tests/no-split-suggestion-dispatch.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-split-suggestion-dispatch.uncached.test.mjs
new file mode 100644
index 000000000..2d4c07ef4
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-split-suggestion-dispatch.uncached.test.mjs
@@ -0,0 +1,55 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-split-suggestion-dispatch';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+const BRANCHES = [
+ [
+ 'chain',
+ 'this chain dispatches the trigger-range delete on its own',
+ 'Compose the delete and the insert into ONE chain',
+ ],
+ [
+ 'commands',
+ '`commands.deleteRange` dispatches the trigger-range delete immediately',
+ 'Compose the delete and the insert into ONE chain',
+ ],
+];
+
+function branchOf(message) {
+ return BRANCHES.find(([, marker]) => message.includes(marker))?.[0] ?? 'unknown';
+}
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 3 positive cases, each on its branch, by its own code', () => {
+ const found = fires();
+ expect(found.map((fire) => `${fire.position} ${branchOf(fire.message)}`)).toEqual([
+ '51:5 chain',
+ '59:5 chain',
+ '67:5 commands',
+ ]);
+ for (const fire of found) {
+ const [, , fix] = BRANCHES.find(([name]) => name === branchOf(fire.message));
+ expect(fire.message).toContain(fix);
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and deliberately unscoped', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-themeless-pierre-diff.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-themeless-pierre-diff.uncached.test.mjs
new file mode 100644
index 000000000..91888ea30
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-themeless-pierre-diff.uncached.test.mjs
@@ -0,0 +1,64 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-themeless-pierre-diff';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+const BRANCHES = [
+ ['theme', 'this renderer passes no theme', 'add `theme: okPierreTheme()`'],
+ ['style', "does not set diffStyle: 'unified'", 'add it to its options'],
+];
+
+function branchOf(message) {
+ return BRANCHES.find(([, marker]) => message.includes(marker))?.[0] ?? 'unknown';
+}
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 7 positive cases, each on its branch, by its own code', () => {
+ const found = fires();
+ expect(found.map((fire) => `${fire.position} ${branchOf(fire.message)}`)).toEqual([
+ '22:10 theme',
+ '27:10 style',
+ '33:5 style',
+ '44:5 theme',
+ '56:5 theme',
+ '64:10 theme',
+ '98:10 theme',
+ ]);
+ for (const fire of found) {
+ const [, , fix] = BRANCHES.find(([name]) => name === branchOf(fire.message));
+ expect(fire.message).toContain(fix);
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
+ [
+ 'packages/app/src/**/*.tsx',
+ '!**/*.test.tsx',
+ '!**/*.dom.test.tsx',
+ '!**/*.test-helper.tsx',
+ FIXTURE,
+ ].sort(),
+ );
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-unconverted-git-pathspec.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-unconverted-git-pathspec.uncached.test.mjs
new file mode 100644
index 000000000..a2a42f7c4
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-unconverted-git-pathspec.uncached.test.mjs
@@ -0,0 +1,76 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+import { NON_PATHSPEC_VERBS } from '../rules/no-unconverted-git-pathspec.mjs';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-unconverted-git-pathspec';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 7 planted positives, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual([
+ '44:17',
+ '46:23',
+ '48:9',
+ '50:17',
+ '52:24',
+ '54:17',
+ '58:5',
+ ]);
+ for (const fire of found) {
+ expect(fire.message).toContain("Hand-written `'--'` in a git argv");
+ expect(fire.message).toContain('pathspecArgs(paths)');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ expect(readRuleScope(REPO_ROOT, RULE)).not.toEqual([]);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ const scope = readRuleScope(REPO_ROOT, RULE);
+ expect(scope).toContain(FIXTURE);
+ for (const included of [
+ 'packages/core/src/**/*.ts',
+ 'packages/server/src/**/*.ts',
+ 'packages/cli/src/**/*.ts',
+ 'packages/desktop/src/**/*.ts',
+ ]) {
+ expect(scope).toContain(included);
+ }
+ for (const excluded of [
+ '!packages/core/src/git-pathspec.ts',
+ '!**/*.test.ts',
+ '!**/*.test-helper.ts',
+ ]) {
+ expect(scope).toContain(excluded);
+ }
+ });
+
+ test('exempts every verb whose "--" operands are not pathspecs, and nothing else', () => {
+ expect([...NON_PATHSPEC_VERBS].sort()).toEqual([
+ 'clone',
+ 'hash-object',
+ 'mv',
+ 'update-index',
+ 'worktree',
+ ]);
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-uninstall-forbidden-import.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-uninstall-forbidden-import.uncached.test.mjs
new file mode 100644
index 000000000..855d90a97
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-uninstall-forbidden-import.uncached.test.mjs
@@ -0,0 +1,68 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-uninstall-forbidden-import';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+const BRANCHES = [
+ ['forbidden', 'Forbidden module in the uninstall entry', 'must connect to nothing'],
+ ['dynamic', 'Dynamic import under src/uninstall', 'eager-load'],
+];
+
+function branchOf(message) {
+ return BRANCHES.find(([, marker]) => message.includes(marker))?.[0] ?? 'unknown';
+}
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 13 cases: 12 forbidden imports and 1 dynamic import, each on its branch, by its own code', () => {
+ const found = fires();
+ expect(found.map((fire) => `${fire.position} ${branchOf(fire.message)}`)).toEqual([
+ '16:1 forbidden',
+ '17:1 forbidden',
+ '18:1 forbidden',
+ '19:1 forbidden',
+ '20:1 forbidden',
+ '21:1 forbidden',
+ '22:1 forbidden',
+ '23:1 forbidden',
+ '24:1 forbidden',
+ '25:1 forbidden',
+ '26:1 forbidden',
+ '27:1 forbidden',
+ '43:10 dynamic',
+ ]);
+ for (const fire of found) {
+ const [, , fix] = BRANCHES.find(([name]) => name === branchOf(fire.message));
+ expect(fire.message).toContain(fix);
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ expect(readRuleScope(REPO_ROOT, RULE)).not.toEqual([]);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ const scope = readRuleScope(REPO_ROOT, RULE);
+ expect(scope).toContain('packages/app/src/uninstall/**/*.ts');
+ expect(scope).toContain('packages/app/src/uninstall/**/*.tsx');
+ expect(scope).toContain('!packages/app/src/uninstall/**/*.test.ts');
+ expect(scope).toContain('!packages/app/src/uninstall/**/*.test.tsx');
+ expect(scope).toContain('!packages/app/src/uninstall/**/*.dom.test.tsx');
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-unportaled-editor-content.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-unportaled-editor-content.uncached.test.mjs
new file mode 100644
index 000000000..fa60db899
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-unportaled-editor-content.uncached.test.mjs
@@ -0,0 +1,35 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-unportaled-editor-content';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 3 positive cases, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual(['21:10', '26:10', '33:7']);
+ for (const fire of found) {
+ expect(fire.message).toContain('Portal-only: render <EditorContent');
+ expect(fire.message).toContain('render <EditorContent />');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and deliberately unscoped', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/no-unwrapped-user-facing-string.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-unwrapped-user-facing-string.uncached.test.mjs
new file mode 100644
index 000000000..84008299e
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/no-unwrapped-user-facing-string.uncached.test.mjs
@@ -0,0 +1,86 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'no-unwrapped-user-facing-string';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+const BRANCHES = [
+ ['toast', 'Unwrapped user-facing string in a toast argument', 'Wrap it with the Lingui'],
+ ['jsx', 'Unwrapped user-facing string in JSX text', 'Wrap it with the Lingui'],
+ ['attribute', 'Unwrapped user-facing string in a UI-facing attribute', 'Wrap it with the Lingui'],
+ [
+ 'property',
+ 'Unwrapped user-facing string in a UI-facing object property',
+ 'Wrap it with the Lingui',
+ ],
+];
+
+function branchOf(message) {
+ return BRANCHES.find(([, marker]) => message.includes(marker))?.[0] ?? 'unknown';
+}
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 15 unwrapped user-facing strings, each on its branch, by its own code', () => {
+ const found = fires();
+ expect(found.map((fire) => `${fire.position} ${branchOf(fire.message)}`)).toEqual([
+ '23:3 toast',
+ '24:3 toast',
+ '29:16 jsx',
+ '37:10 jsx',
+ '47:23 attribute',
+ '48:26 attribute',
+ '49:16 attribute',
+ '50:18 attribute',
+ '61:14 property',
+ '62:14 property',
+ '63:20 property',
+ '64:12 property',
+ '65:20 property',
+ '66:21 property',
+ '73:36 property',
+ ]);
+ for (const fire of found) {
+ const [, , fix] = BRANCHES.find(([name]) => name === branchOf(fire.message));
+ expect(fire.message).toContain(fix);
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped to the product surface', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
+ [
+ 'packages/app/src/**/*.ts',
+ 'packages/app/src/**/*.tsx',
+ 'packages/desktop/src/**/*.ts',
+ 'packages/desktop/src/**/*.tsx',
+ 'packages/plugin/src/**/*.ts',
+ 'packages/plugin/src/**/*.tsx',
+ '!packages/app/src/editor/**',
+ '!packages/app/src/components/ui/**',
+ '!packages/desktop/src/main/**',
+ '!**/*.test.ts',
+ '!**/*.test.tsx',
+ '!**/*.dom.test.tsx',
+ FIXTURE,
+ ].sort(),
+ );
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/ok-rules-scope-partition.uncached.test.mjs b/lint-plugins/ok-rules/tests/ok-rules-scope-partition.uncached.test.mjs
new file mode 100644
index 000000000..0bfcdf419
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/ok-rules-scope-partition.uncached.test.mjs
@@ -0,0 +1,145 @@
+import { readdirSync, readFileSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readJsPluginSpecifiers,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+import plugin, { rules } from '../index.mjs';
+import { isInScope, RULE_SCOPES, UNSCOPED_RULES } from '../scope.mjs';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const TESTS_DIR = fileURLToPath(new URL('.', import.meta.url));
+const FIXTURES_DIR = fileURLToPath(new URL('../__fixtures__/', import.meta.url));
+const FIXTURE_CONFIG = fileURLToPath(
+ new URL('../__fixtures__/oxlint.fixtures.json', import.meta.url),
+);
+const TIER_TEST = /\.uncached\.test\.mjs$/;
+const CODE_FILE = /\.[cm]?[jt]sx?$/;
+const META_TESTS = ['ok-rules-scope-partition', 'ok-rules-vocabulary'];
+
+const registered = Object.keys(rules).sort();
+
+function publicTestStems() {
+ return readdirSync(TESTS_DIR)
+ .filter((name) => TIER_TEST.test(name) && !name.includes('.private.'))
+ .map((name) => name.replace(TIER_TEST, ''));
+}
+
+describe('ok-rules scope table', () => {
+ test('every registered rule is either scoped or deliberately unscoped, never both', () => {
+ const scoped = Object.keys(RULE_SCOPES);
+ const unscoped = [...UNSCOPED_RULES];
+ expect([...scoped, ...unscoped].sort()).toEqual(registered);
+ expect(scoped.filter((r) => UNSCOPED_RULES.has(r))).toEqual([]);
+ });
+
+ test('UNSCOPED_RULES holds exactly the rules that are deliberately global', () => {
+ expect([...UNSCOPED_RULES].sort()).toEqual([
+ 'microcopy-ellipsis',
+ 'no-hand-rolled-spinner',
+ 'no-loosely-typed-webcontents-ipc',
+ 'no-resolved-value-theme-source',
+ 'no-sentinel-signal-target',
+ 'no-split-suggestion-dispatch',
+ 'no-unportaled-editor-content',
+ ]);
+ });
+
+ test('the `ok` plugin registers exactly the rules it exports', () => {
+ expect(Object.keys(plugin.rules).sort()).toEqual(registered);
+ });
+
+ test('an unclassified rule name fails closed rather than scoping everywhere', () => {
+ expect(() => isInScope('rule-that-does-not-exist', 'packages/app/src/x.tsx')).toThrow(
+ /no entry in the scope table it was looked up in/,
+ );
+ });
+
+ test('UNSCOPED_RULES does not leak into a caller-supplied table', () => {
+ const unscopedName = [...UNSCOPED_RULES][0];
+ expect(() => isInScope(unscopedName, 'packages/app/src/x.tsx', {})).toThrow(
+ /no entry in the scope table it was looked up in/,
+ );
+ expect(isInScope(unscopedName, 'packages/app/src/x.tsx')).toBe(true);
+ });
+
+ test('oxlint.config.ts still loads the `ok` plugin these rules are exported from', async () => {
+ expect(await readJsPluginSpecifiers(REPO_ROOT)).toContain('./lint-plugins/ok-rules/index.mjs');
+ });
+
+ test('every scope entry names its own fixture, so the fixture test can fire', () => {
+ for (const [rule, globs] of Object.entries(RULE_SCOPES)) {
+ const fixture = globs.find((g) => g.includes('__fixtures__'));
+ expect(fixture, `${rule} has no fixture glob in its scope`).toBeDefined();
+ expect(fixture).toContain(rule);
+ }
+ });
+
+ test('no rule reports on a fixture outside its scope', () => {
+ const fixtures = readdirSync(FIXTURES_DIR).filter((name) => name.endsWith('.fixture.tsx'));
+ expect(fixtures.length).toBeGreaterThan(0);
+ let checked = 0;
+ const outOfScope = [];
+ for (const name of fixtures) {
+ const fixture = `lint-plugins/ok-rules/__fixtures__/${name}`;
+ for (const fire of lintOkRulesFixture(fixture)) {
+ const rule = /^ok\((.+)\)$/.exec(fire.code)?.[1];
+ if (rule === undefined) continue;
+ checked += 1;
+ if (!isInScope(rule, fixture))
+ outOfScope.push(`${fire.code} at ${fixture}:${fire.position}`);
+ }
+ }
+ expect(checked).toBeGreaterThan(0);
+ expect(
+ outOfScope,
+ 'a rule reported on a file its scope excludes, so scoped() in scope.mjs no longer gates it',
+ ).toEqual([]);
+ });
+
+ test('the matcher rejects glob syntax it does not implement, rather than mis-scoping', () => {
+ for (const globs of Object.values(RULE_SCOPES)) {
+ for (const glob of globs) {
+ expect(glob.replace(/^!/, '')).not.toMatch(/[?{}[\]()]/);
+ }
+ }
+ });
+});
+
+describe('ok-rules fixture tests', () => {
+ test('every file in the tests directory runs in the uncached tier or is a helper', () => {
+ const misplaced = readdirSync(TESTS_DIR).filter(
+ (name) => CODE_FILE.test(name) && !TIER_TEST.test(name) && !name.endsWith('.test-helper.mjs'),
+ );
+ expect(
+ misplaced,
+ 'a fixture test here is named <rule>.uncached.test.mjs, so the uncached tier runs it',
+ ).toEqual([]);
+ });
+
+ test('every rule the `ok` plugin registers has its fixture test here', () => {
+ const stems = new Set(publicTestStems());
+ expect(
+ registered.filter((rule) => !stems.has(rule)),
+ 'a rule ships with lint-plugins/ok-rules/tests/<rule>.uncached.test.mjs (precedent #42)',
+ ).toEqual([]);
+ });
+
+ test('the fixture config enables exactly the registered rules, at error', () => {
+ const { rules: configured } = JSON.parse(readFileSync(FIXTURE_CONFIG, 'utf8'));
+ const enabled = Object.entries(configured).filter(([id]) => id.startsWith('ok/'));
+ expect(
+ enabled.map(([id]) => id.slice('ok/'.length)).sort(),
+ 'a registered rule needs an "ok/<rule>": "error" entry in lint-plugins/ok-rules/__fixtures__/oxlint.fixtures.json',
+ ).toEqual(registered);
+ expect(enabled.filter(([, severity]) => severity !== 'error')).toEqual([]);
+ });
+
+ test('every fixture test here names a registered rule or a meta-test of the rule set', () => {
+ expect(
+ publicTestStems().filter((stem) => !registered.includes(stem) && !META_TESTS.includes(stem)),
+ 'rename or delete a fixture test whose rule was renamed or removed',
+ ).toEqual([]);
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/ok-rules-vocabulary.test-helper.mjs b/lint-plugins/ok-rules/tests/ok-rules-vocabulary.test-helper.mjs
new file mode 100644
index 000000000..b248fb8d3
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/ok-rules-vocabulary.test-helper.mjs
@@ -0,0 +1,147 @@
+import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
+import { join, relative, sep } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+
+const VOCABULARY_SOURCES = 'lint-plugins/ok-rules/tests/ok-rules-vocabulary.';
+
+const RETIRED = /gritql|\.grit\b|biome-plugins|bun run/i;
+
+const HISTORICAL = /\b(?:retired|replaced|superseded|no longer|used to|formerly|migrat)/i;
+
+const ENGINE_NAMES = ['GritQL', 'biome', 'eslint', 'remark', 'rehype', 'vite', 'babel', 'oxlint'];
+
+const DEMOTED_UNAMBIGUOUS = new RegExp(
+ [
+ String.raw`\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+ (?:(?:${ENGINE_NAMES.join('|')}) )?plugins?\b`,
+ String.raw`\bok/[a-z0-9-]+\b.{0,60}\bplugins?\b`,
+ String.raw`\bplugins?\b\s*(?:test|fixture)\b`,
+ ].join('|'),
+ 'i',
+);
+
+const ENGINE_PLUGINS = new RegExp(`\\b(?:${ENGINE_NAMES.join('|')})[- ]plugins?\\b`, 'gi');
+
+export function pluginDirNames() {
+ const dir = join(REPO_ROOT, 'lint-plugins');
+ const names = readdirSync(dir, { withFileTypes: true })
+ .filter((e) => e.isDirectory())
+ .map((e) => e.name);
+ if (names.length === 0) {
+ throw new Error(
+ `ok-rules-vocabulary: ${relative(REPO_ROOT, dir)} lists no plugin directories. An empty ` +
+ 'alternation would strip every `plugin` token and green the gate.',
+ );
+ }
+ return names;
+}
+
+const REAL_PLUGIN_NAMES = new RegExp(
+ `\\b(?:${pluginDirNames()
+ .map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
+ .join('|')})\\b[^.]{0,3}(?:(?:${ENGINE_NAMES.join('|')}) )?plugins?\\b`,
+ 'gi',
+);
+
+const PLUGIN_AS_MODULE = new RegExp(
+ [
+ 'lint-plugins',
+ 'jsPlugins',
+ 'plugin\\.mjs',
+ 'plugins\\.html',
+ 'JS[- ]plugins?',
+ 'packages/\\{[^}]*plugin[^}]*\\}',
+ 'packages/plugin',
+ 'index\\.(?:private\\.)?mjs',
+ 'lint/plugin/',
+ 'import plugin',
+ 'plugin\\.rules',
+ '(?:`ok`|`\\.private\\.`) plugins?',
+ 'PLUGIN_NAME',
+ ].join('|'),
+ 'gi',
+);
+
+const NEAR_RULE_VOCABULARY = new RegExp(
+ [
+ String.raw`\bplugins?\b\s*(?:test|fixture)`,
+ String.raw`\b(?:rule|test|fixture)\b.{0,60}\bplugins?\b`,
+ String.raw`\bplugins?\b.{0,60}\b(?:fires|must fire|fixture|test)\b`,
+ ].join('|'),
+ 'i',
+);
+
+function blank(line, pattern) {
+ return line.replace(pattern, (m) => ' '.repeat(m.length));
+}
+
+export function judgeDemotion(line, { demotedFirst = true } = {}) {
+ const named = blank(line, REAL_PLUGIN_NAMES);
+ if (demotedFirst && DEMOTED_UNAMBIGUOUS.test(named)) return true;
+ const residue = blank(blank(named, ENGINE_PLUGINS), PLUGIN_AS_MODULE);
+ if (!demotedFirst && DEMOTED_UNAMBIGUOUS.test(residue)) return true;
+ return /\bplugins?\b/i.test(residue) && NEAR_RULE_VOCABULARY.test(residue);
+}
+
+export function namesRetiredMechanism(line) {
+ return RETIRED.test(line) && !HISTORICAL.test(line);
+}
+
+export function readmeLine(startsWith) {
+ const lines = readFileSync(join(REPO_ROOT, 'lint-plugins/ok-rules/README.md'), 'utf-8').split(
+ '\n',
+ );
+ const found = lines.filter((l) => l.startsWith(startsWith));
+ if (found.length !== 1) {
+ throw new Error(
+ `ok-rules-vocabulary: expected exactly one README line starting "${startsWith}", found ` +
+ `${found.length}. The pinned legitimate case must track a real line, not an index.`,
+ );
+ }
+ return found[0];
+}
+
+function posixRel(file) {
+ return relative(REPO_ROOT, file).split(sep).join('/');
+}
+
+function corpusFiles(dirs) {
+ const found = [];
+ const walk = (dir) => {
+ for (const entry of readdirSync(dir)) {
+ const full = join(dir, entry);
+ if (statSync(full).isDirectory()) walk(full);
+ else if (/\.(mjs|ts|tsx|json|md)$/.test(entry)) found.push(full);
+ }
+ };
+ for (const dir of dirs) {
+ const abs = join(REPO_ROOT, dir);
+ if (existsSync(abs)) walk(abs);
+ }
+ return found.filter((file) => !posixRel(file).startsWith(VOCABULARY_SOURCES));
+}
+
+export function filesPerDir(dirs) {
+ const counts = new Map(dirs.map((dir) => [dir, 0]));
+ for (const file of corpusFiles(dirs)) {
+ const rel = posixRel(file);
+ for (const dir of dirs) {
+ if (rel.startsWith(`${dir}/`)) counts.set(dir, (counts.get(dir) ?? 0) + 1);
+ }
+ }
+ return counts;
+}
+
+export function scan(dirs, judge) {
+ const out = [];
+ for (const file of corpusFiles(dirs)) {
+ const rel = posixRel(file);
+ readFileSync(file, 'utf-8')
+ .split('\n')
+ .forEach((line, i) => {
+ if (judge(line)) out.push(`${rel}:${i + 1}: ${line.trim()}`);
+ });
+ }
+ return out;
+}
diff --git a/lint-plugins/ok-rules/tests/ok-rules-vocabulary.uncached.test.mjs b/lint-plugins/ok-rules/tests/ok-rules-vocabulary.uncached.test.mjs
new file mode 100644
index 000000000..ff76aeaed
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/ok-rules-vocabulary.uncached.test.mjs
@@ -0,0 +1,59 @@
+import { describe, expect, test } from 'vitest';
+import {
+ filesPerDir,
+ judgeDemotion,
+ namesRetiredMechanism,
+ pluginDirNames,
+ readmeLine,
+ scan,
+} from './ok-rules-vocabulary.test-helper.mjs';
+
+const CORPUS_DIRS = ['lint-plugins/ok-rules', 'packages/app/tests/lint-plugins'];
+
+describe('ok-rules corpus vocabulary', () => {
+ test('every corpus directory contributes at least one scanned file', () => {
+ const missing = [...filesPerDir(CORPUS_DIRS)].filter(([, n]) => n === 0).map(([dir]) => dir);
+ expect(missing).toEqual([]);
+ });
+
+ test('demotion detection survives an engine name and a spanning phrase', () => {
+ const demotions = [
+ 'The no-hand-rolled-spinner plugin registers exactly 5 diagnostics.',
+ 'The GritQL era is over; the no-hand-rolled-spinner plugin registers exactly 5 diagnostics.',
+ 'The GritQL plugins were slow; the no-hand-rolled-spinner plugin fires on its fixture.',
+ 'The sibling plugin fires twice on that fixture.',
+ 'what the plugin test counts',
+ "the oxlint path-conditional-origin plugin's enforcement target",
+ 'the ok/no-hand-rolled-spinner oxlint plugin fires on its fixture.',
+ 'the path-conditional-origin oxlint plugin fires on its fixture.',
+ ];
+ for (const line of demotions) expect(judgeDemotion(line), line).toBe(true);
+
+ const legitimate = [
+ readmeLine('One plugin holding every rule is deliberate'),
+ 'This rule ships as its own `.private.` plugin rather than inside the `ok` plugin.',
+ "describe('no-comments oxlint plugin', () => {",
+ ...pluginDirNames().map((name) => `the ${name} plugin fires on that fixture`),
+ 'the rehype clipboard cleanup plugins (eight strip-* plugins plus a skipper)',
+ ];
+ for (const line of legitimate) expect(judgeDemotion(line), line).toBe(false);
+ });
+
+ test('the stage order is load-bearing, not incidental', () => {
+ for (const orderSensitive of [
+ 'the `ok` plugin test',
+ 'the ok/no-hand-rolled-spinner oxlint plugin fires on its fixture.',
+ ]) {
+ expect(judgeDemotion(orderSensitive), orderSensitive).toBe(true);
+ expect(judgeDemotion(orderSensitive, { demotedFirst: false }), orderSensitive).toBe(false);
+ }
+ });
+
+ test('no file names the retired GritQL or Bun mechanism as if it were current', () => {
+ expect(scan(CORPUS_DIRS, namesRetiredMechanism)).toEqual([]);
+ });
+
+ test('no file calls an ok rule a plugin', () => {
+ expect(scan(CORPUS_DIRS, (line) => judgeDemotion(line))).toEqual([]);
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/path-conditional-map-driven-origin.uncached.test.mjs b/lint-plugins/ok-rules/tests/path-conditional-map-driven-origin.uncached.test.mjs
index b5fe57a1e..11b861585 100644
--- a/lint-plugins/ok-rules/tests/path-conditional-map-driven-origin.uncached.test.mjs
+++ b/lint-plugins/ok-rules/tests/path-conditional-map-driven-origin.uncached.test.mjs
@@ -1,47 +1,50 @@
-import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { describe, expect, test } from 'vitest';
import {
- oxlintFixtureArgs,
+ lintOkRulesFixture,
readEnabledRuleIds,
readRegisteredRuleNames,
readRuleScope,
} from '../../../test-support/read-ok-rules-config.test-helper.ts';
const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
-const FIXTURE_REL =
- 'lint-plugins/ok-rules/__fixtures__/path-conditional-map-driven-origin.fixture.tsx';
+const RULE = 'path-conditional-map-driven-origin';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
-describe('path-conditional-map-driven-origin oxlint rule', () => {
- test('fires on exactly 7 positive cases (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (output.match(/Observer-side transact call missing sanctioned origin/g) ?? [])
- .length;
- expect(fires).toBe(7);
- expect(output).toContain('Pass `OBSERVER_SYNC_ORIGIN` as the second argument');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#path-conditional-map-driven-origin');
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 7 positive cases, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual([
+ '29:3',
+ '34:3',
+ '39:3',
+ '45:3',
+ '52:3',
+ '57:3',
+ '65:3',
+ ]);
+ for (const fire of found) {
+ expect(fire.message).toContain('Observer-side transact call missing sanctioned origin');
+ expect(fire.message).toContain('Pass `OBSERVER_SYNC_ORIGIN` as the second argument');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
});
test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(
- 'path-conditional-map-driven-origin',
- );
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/path-conditional-map-driven-origin');
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
});
test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'path-conditional-map-driven-origin');
- expect(scope.sort()).toEqual(
- [
- 'packages/server/src/server-observers.ts',
- 'lint-plugins/ok-rules/__fixtures__/path-conditional-map-driven-origin.fixture.tsx',
- ].sort(),
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
+ ['packages/server/src/server-observers.ts', FIXTURE].sort(),
);
});
});
diff --git a/lint-plugins/ok-rules/tests/playwright-prefer-to-have-count.uncached.test.mjs b/lint-plugins/ok-rules/tests/playwright-prefer-to-have-count.uncached.test.mjs
new file mode 100644
index 000000000..e437b672b
--- /dev/null
+++ b/lint-plugins/ok-rules/tests/playwright-prefer-to-have-count.uncached.test.mjs
@@ -0,0 +1,47 @@
+import { fileURLToPath } from 'node:url';
+import { describe, expect, test } from 'vitest';
+import {
+ lintOkRulesFixture,
+ readEnabledRuleIds,
+ readRegisteredRuleNames,
+ readRuleScope,
+} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+
+const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
+const RULE = 'playwright-prefer-to-have-count';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
+
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
+
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 3 one-shot count reads, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual(['20:3', '22:3', '24:3']);
+ for (const fire of found) {
+ expect(fire.message).toContain('One-shot count read never retries');
+ expect(fire.message).toContain('use the web-first `await expect(locator).toHaveCount(n)`');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
+ });
+
+ test('rule is registered, enabled, and scoped to the e2e suites', async () => {
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
+ });
+
+ test('its scope table still carries every include and exclude the rule depends on', () => {
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
+ [
+ 'packages/app/tests/stress/**/*.e2e.ts',
+ 'packages/app/tests/visual/**/*.e2e.ts',
+ 'packages/app/tests/a11y/**/*.e2e.ts',
+ FIXTURE,
+ ].sort(),
+ );
+ });
+});
diff --git a/lint-plugins/ok-rules/tests/require-utf8-multipart-parser.uncached.test.mjs b/lint-plugins/ok-rules/tests/require-utf8-multipart-parser.uncached.test.mjs
index 4863bc968..097606cf3 100644
--- a/lint-plugins/ok-rules/tests/require-utf8-multipart-parser.uncached.test.mjs
+++ b/lint-plugins/ok-rules/tests/require-utf8-multipart-parser.uncached.test.mjs
@@ -1,56 +1,43 @@
-import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { describe, expect, test } from 'vitest';
import {
- oxlintFixtureArgs,
+ lintOkRulesFixture,
readEnabledRuleIds,
readRegisteredRuleNames,
readRuleScope,
} from '../../../test-support/read-ok-rules-config.test-helper.ts';
+import { isInScope } from '../scope.mjs';
const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/require-utf8-multipart-parser.fixture.tsx';
+const RULE = 'require-utf8-multipart-parser';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
-describe('require-utf8-multipart-parser oxlint rule', () => {
- test('fires exactly 3 times — one per direct busboy construction', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- windowsHide: true,
- });
- expect(result.error).toBeUndefined();
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
- const fires = (output.match(/busboy constructed directly/g) ?? []).length;
- expect(fires).toBe(3);
-
- expect(output).toContain('createMultipartParser');
- expect(output).toContain('packages/server/src/multipart.ts');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#require-utf8-multipart-parser');
- });
-
- test('the factory module itself is exempt, so the sanctioned call passes', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs('packages/server/src/multipart.ts'), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- windowsHide: true,
- });
- expect(result.error).toBeUndefined();
- const output = `${result.stdout}\n${result.stderr}`;
- expect(output).not.toContain('ok(require-utf8-multipart-parser)');
- expect(output).not.toContain('busboy constructed directly');
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 3 direct busboy constructions, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual(['41:19', '47:19', '50:19']);
+ for (const fire of found) {
+ expect(fire.message).toContain('busboy constructed directly');
+ expect(fire.message).toContain('createMultipartParser');
+ expect(fire.message).toContain('packages/server/src/multipart.ts');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
});
test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('require-utf8-multipart-parser');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/require-utf8-multipart-parser');
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
});
test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'require-utf8-multipart-parser');
- expect(scope.sort()).toEqual(
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
[
'**/*.ts',
'**/*.tsx',
@@ -62,8 +49,13 @@ describe('require-utf8-multipart-parser oxlint rule', () => {
'!**/*.test.mts',
'!**/*.test-helper.ts',
'!packages/server/src/multipart.ts',
- 'lint-plugins/ok-rules/__fixtures__/require-utf8-multipart-parser.fixture.tsx',
+ FIXTURE,
].sort(),
);
});
+
+ test('the scope table excludes the factory module and includes a sibling server module', () => {
+ expect(isInScope(RULE, 'packages/server/src/multipart.ts')).toBe(false);
+ expect(isInScope(RULE, 'packages/server/src/api-extension.ts')).toBe(true);
+ });
});
diff --git a/lint-plugins/ok-rules/tests/require-windowshide-on-spawn.uncached.test.mjs b/lint-plugins/ok-rules/tests/require-windowshide-on-spawn.uncached.test.mjs
index 04a3201f0..225036377 100644
--- a/lint-plugins/ok-rules/tests/require-windowshide-on-spawn.uncached.test.mjs
+++ b/lint-plugins/ok-rules/tests/require-windowshide-on-spawn.uncached.test.mjs
@@ -1,51 +1,57 @@
-import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { describe, expect, test } from 'vitest';
import {
- oxlintFixtureArgs,
+ lintOkRulesFixture,
readEnabledRuleIds,
readRegisteredRuleNames,
readRuleScope,
} from '../../../test-support/read-ok-rules-config.test-helper.ts';
const REPO_ROOT = fileURLToPath(new URL('../../..', import.meta.url));
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/require-windowshide-on-spawn.fixture.tsx';
+const RULE = 'require-windowshide-on-spawn';
+const CODE = `ok(${RULE})`;
+const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;
+const DOCS = `lint-plugins/ok-rules/README.md#${RULE}`;
-describe('require-windowshide-on-spawn oxlint rule', () => {
- test('fires exactly 7 times — one per spawn that hides neither way', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- windowsHide: true,
- });
- expect(result.error).toBeUndefined();
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
+function fires() {
+ return lintOkRulesFixture(FIXTURE).filter((d) => d.code === CODE);
+}
- const fires = (output.match(/without a hidden Windows console/g) ?? []).length;
- expect(fires).toBe(7);
-
- expect(output).toContain('withHiddenWindowsConsole');
- expect(output).toContain('windowsHide: true');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#require-windowshide-on-spawn');
+describe(`${RULE} oxlint rule`, () => {
+ test('fires at exactly its 7 spawns that hide neither way, by its own code, and on no negative case', () => {
+ const found = fires();
+ expect(found.map((fire) => fire.position)).toEqual([
+ '35:19',
+ '36:19',
+ '37:19',
+ '38:19',
+ '39:19',
+ '40:19',
+ '41:19',
+ ]);
+ for (const fire of found) {
+ expect(fire.message).toContain('child_process spawn without a hidden Windows console');
+ expect(fire.message).toContain('withHiddenWindowsConsole');
+ expect(fire.message).toContain('windowsHide: true');
+ expect(fire.message).toMatch(/https?:\/\/[^\s]+/);
+ expect(fire.message).toContain(DOCS);
+ }
});
test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('require-windowshide-on-spawn');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/require-windowshide-on-spawn');
+ expect(await readRegisteredRuleNames(REPO_ROOT)).toContain(RULE);
+ expect(await readEnabledRuleIds(REPO_ROOT)).toContain(`ok/${RULE}`);
});
test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'require-windowshide-on-spawn');
- expect(scope.sort()).toEqual(
+ expect(readRuleScope(REPO_ROOT, RULE).sort()).toEqual(
[
'packages/server/src/**/*.ts',
'packages/cli/src/**/*.ts',
'packages/desktop/src/**/*.ts',
'!**/*.test.ts',
'!**/*.test-helper.ts',
- 'lint-plugins/ok-rules/__fixtures__/require-windowshide-on-spawn.fixture.tsx',
+ FIXTURE,
].sort(),
);
});
diff --git a/packages/app/src/lint-plugins/no-raw-route-hash-construction.test.ts b/packages/app/src/lint-plugins/no-raw-route-hash-construction.test.ts
deleted file mode 100644
index 5f957808d..000000000
--- a/packages/app/src/lint-plugins/no-raw-route-hash-construction.test.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
- readRuleScope,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/no-raw-route-hash-construction.fixture.tsx';
-
-describe('no-raw-route-hash-construction oxlint rule', () => {
- test('fires exactly 5 times — one per hand-built hash, none on the read forms', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- windowsHide: true,
- });
- expect(result.error).toBeUndefined();
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
-
- const fires = (output.match(/Raw route-hash construction/g) ?? []).length;
- expect(fires).toBe(5);
-
- expect(output).toContain('hashFromDocName');
- expect(output).toContain('hashFromFolderPath');
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-raw-route-hash-construction');
- });
-
- test('rule is registered, enabled, and scoped with doc-hash.ts excluded', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-raw-route-hash-construction');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-raw-route-hash-construction');
- });
-
- test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'no-raw-route-hash-construction');
- expect(scope.sort()).toEqual(
- [
- 'packages/app/src/**/*.ts',
- 'packages/app/src/**/*.tsx',
- '!packages/app/src/lib/doc-hash.ts',
- '!**/*.test.ts',
- '!**/*.test.tsx',
- 'lint-plugins/ok-rules/__fixtures__/no-raw-route-hash-construction.fixture.tsx',
- ].sort(),
- );
- });
-});
diff --git a/packages/app/tests/integration/microcopy-ellipsis.test.ts b/packages/app/tests/integration/microcopy-ellipsis.test.ts
deleted file mode 100644
index e1440147c..000000000
--- a/packages/app/tests/integration/microcopy-ellipsis.test.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-/** The `microcopy-ellipsis` oxlint rule fixture test, per precedent #42. */
-
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/microcopy-ellipsis.fixture.tsx';
-
-describe('microcopy-ellipsis oxlint rule', () => {
- test('fires on exactly 2 positive cases (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (output.match(/Microcopy: drop the trailing/g) ?? []).length;
- expect(fires).toBe(2);
- expect(output).toContain('drop the trailing');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#microcopy-ellipsis');
- });
-
- test('rule is registered, enabled, and deliberately unscoped', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('microcopy-ellipsis');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/microcopy-ellipsis');
- });
-});
diff --git a/packages/app/tests/integration/no-unportaled-editor-content.test.ts b/packages/app/tests/integration/no-unportaled-editor-content.test.ts
deleted file mode 100644
index 68b53c5aa..000000000
--- a/packages/app/tests/integration/no-unportaled-editor-content.test.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-/** The `no-unportaled-editor-content` oxlint rule fixture test, per precedent #42. */
-
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/no-unportaled-editor-content.fixture.tsx';
-
-describe('no-unportaled-editor-content oxlint rule', () => {
- test('fires on exactly 3 positive cases (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (output.match(/Portal-only: render <EditorContent/g) ?? []).length;
- expect(fires).toBe(3);
- expect(output).toContain('render <EditorContent />');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-unportaled-editor-content');
- });
-
- test('rule is registered, enabled, and deliberately unscoped', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-unportaled-editor-content');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-unportaled-editor-content');
- });
-});
diff --git a/packages/app/tests/lint-plugins/no-blind-agent-host-fanout.test.ts b/packages/app/tests/lint-plugins/no-blind-agent-host-fanout.test.ts
deleted file mode 100644
index 4bb76076f..000000000
--- a/packages/app/tests/lint-plugins/no-blind-agent-host-fanout.test.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-/** The `no-blind-agent-host-fanout` oxlint rule fixture test, per precedent #42. */
-
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import { FORBIDDEN_SPECS } from '../../../../lint-plugins/ok-rules/rules/no-blind-agent-host-fanout.mjs';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
- readRuleScope,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/no-blind-agent-host-fanout.fixture.tsx';
-
-describe('no-blind-agent-host-fanout oxlint rule', () => {
- test('fires on exactly 5 planted positives (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.error).toBeUndefined();
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (
- output.match(/User-global skill installs must be gated on detected hosts/g) ?? []
- ).length;
- expect(fires).toBe(5);
- expect(output).toContain('detectUserSkillHosts');
- expect(output).toContain('HOSTS_WITH_USER_SKILL_DIR');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-blind-agent-host-fanout');
- });
-
- test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-blind-agent-host-fanout');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-blind-agent-host-fanout');
- expect(readRuleScope(REPO_ROOT, 'no-blind-agent-host-fanout')).not.toEqual([]);
- });
-
- test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'no-blind-agent-host-fanout');
- expect(scope).toContain(FIXTURE_REL);
- expect(scope).toContain('packages/server/src/**/*.ts');
- expect(scope).toContain('packages/cli/src/**/*.ts');
- for (const excluded of ['!**/*.test.ts', '!**/*.test-helper.ts']) {
- expect(scope).not.toContain(excluded);
- }
- });
-
- test('bans every range shape of the spec, not just the one that shipped', () => {
- const matched = [...FORBIDDEN_SPECS].sort();
- expect(matched.length).toBeGreaterThan(0);
- for (const spec of ['skills@~1.5.0', 'skills@^1.5.0', '[email protected]', 'skills@latest']) {
- expect(matched).toContain(spec);
- }
- expect(matched).toContain('--agent');
- });
-});
diff --git a/packages/app/tests/lint-plugins/no-demoted-dialog-confirm.test.ts b/packages/app/tests/lint-plugins/no-demoted-dialog-confirm.test.ts
deleted file mode 100644
index e6b823a7b..000000000
--- a/packages/app/tests/lint-plugins/no-demoted-dialog-confirm.test.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-/** The `no-demoted-dialog-confirm` oxlint rule fixture test, per precedent #42. */
-
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
- readRuleScope,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/no-demoted-dialog-confirm.fixture.tsx';
-
-describe('no-demoted-dialog-confirm oxlint rule', () => {
- test('fires on exactly 3 demoted dialog footers (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.error).toBeUndefined();
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (output.match(/Demoted confirm in a dialog footer/g) ?? []).length;
- expect(fires).toBe(3);
- expect(output).toContain('Drop the variant prop');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-demoted-dialog-confirm');
- });
-
- test('rule is registered, enabled, and scoped to product chrome', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-demoted-dialog-confirm');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-demoted-dialog-confirm');
- });
-
- test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'no-demoted-dialog-confirm');
- expect(scope.sort()).toEqual(
- [
- 'packages/app/src/**/*.tsx',
- 'packages/desktop/src/**/*.tsx',
- 'packages/plugin/src/**/*.tsx',
- '!packages/app/src/components/ui/**',
- '!**/*.test.tsx',
- '!**/*.dom.test.tsx',
- 'lint-plugins/ok-rules/__fixtures__/no-demoted-dialog-confirm.fixture.tsx',
- ].sort(),
- );
- });
-});
diff --git a/packages/app/tests/lint-plugins/no-hand-rolled-spinner.test.ts b/packages/app/tests/lint-plugins/no-hand-rolled-spinner.test.ts
deleted file mode 100644
index b93e2a0e4..000000000
--- a/packages/app/tests/lint-plugins/no-hand-rolled-spinner.test.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-/** The `no-hand-rolled-spinner` oxlint rule fixture test, per precedent #42. */
-
-import { spawnSync } from 'node:child_process';
-import { readFileSync } from 'node:fs';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- parseOxlintDiagnostics,
- readEnabledRuleIds,
- readRegisteredRuleNames,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/no-hand-rolled-spinner.fixture.tsx';
-
-function checkFixture(): string {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.error).toBeUndefined();
- expect(result.status).not.toBe(0);
- return `${result.stdout}\n${result.stderr}`;
-}
-
-describe('no-hand-rolled-spinner oxlint rule', () => {
- test('fires on exactly 5 hand-rolled spins (and on no negative case)', () => {
- const output = checkFixture();
- const fires = parseOxlintDiagnostics(output).filter(
- (d) => d.code === 'ok(no-hand-rolled-spinner)',
- );
- expect(fires.length).toBe(5);
- expect(output).toContain('Hand-rolled loading spinner');
- expect(output).toContain('@/components/ui/spinner');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-hand-rolled-spinner');
- });
-
- test('rule is registered, enabled, and deliberately unscoped', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-hand-rolled-spinner');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-hand-rolled-spinner');
- });
-
- test('the word boundary admits a suffixed variant but not a longer token', () => {
- const lines = parseOxlintDiagnostics(checkFixture())
- .filter((d) => d.code === 'ok(no-hand-rolled-spinner)')
- .map((d) => d.labels?.[0]?.span?.line)
- .filter((n): n is number => typeof n === 'number');
-
- const source = readFileSync(join(REPO_ROOT, FIXTURE_REL), 'utf-8').split('\n');
- const flagged = lines.map((n) => source[n - 1]).join('\n');
-
- expect(flagged).toContain('animate-spin-slow');
- expect(flagged).not.toContain('animate-spinner');
- });
-});
diff --git a/packages/app/tests/lint-plugins/no-inline-tolerance-class.test.ts b/packages/app/tests/lint-plugins/no-inline-tolerance-class.test.ts
deleted file mode 100644
index c40bbe73b..000000000
--- a/packages/app/tests/lint-plugins/no-inline-tolerance-class.test.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-/** The `no-inline-tolerance-class` oxlint rule fixture test, per precedent #42. */
-
-import { spawnSync } from 'node:child_process';
-import { readFileSync } from 'node:fs';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import { MATCHED_FIDELITY_CLASSES } from '../../../../lint-plugins/ok-rules/rules/no-inline-tolerance-class.mjs';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
- readRuleScope,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/no-inline-tolerance-class.fixture.tsx';
-const CATALOG_SOURCE_ABS = join(REPO_ROOT, 'packages/core/src/bridge/normalize.ts');
-
-describe('no-inline-tolerance-class oxlint rule', () => {
- test('fires on exactly 8 inline fidelity-class literals (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.error).toBeUndefined();
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (output.match(/Inline bridge normalization-class value in a public test/g) ?? [])
- .length;
- expect(fires).toBe(8);
- expect(output).toContain('hard-coding a BRIDGE_TOLERANCE_CLASSES label');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-inline-tolerance-class');
- });
-
- test('rule is registered, enabled, and scoped to the public test surface', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-inline-tolerance-class');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-inline-tolerance-class');
- });
-
- test('matched fidelity set + universal-encoding set partition BRIDGE_TOLERANCE_CLASSES', () => {
- const UNIVERSAL_ENCODING = ['bom', 'crlf', 'trailing-whitespace', 'trailing-newline'];
-
- const catalogSrc = readFileSync(CATALOG_SOURCE_ABS, 'utf-8');
- const arrayBody = catalogSrc.match(/BRIDGE_TOLERANCE_CLASSES\s*=\s*\[([\s\S]*?)\]/)?.[1];
- expect(arrayBody).toBeDefined();
- const catalog = [...(arrayBody ?? '').matchAll(/'([^']+)'/g)].map((m) => m[1]).sort();
- expect(catalog.length).toBeGreaterThan(0);
-
- const matched = [...MATCHED_FIDELITY_CLASSES].sort();
-
- expect(matched.filter((c) => UNIVERSAL_ENCODING.includes(c))).toEqual([]);
- const union = [...new Set([...matched, ...UNIVERSAL_ENCODING])].sort();
- expect(union).toEqual(catalog);
- });
-
- test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'no-inline-tolerance-class');
- expect(scope.sort()).toEqual(
- [
- 'packages/**/*.test.ts',
- 'packages/**/*.test.tsx',
- 'packages/**/*.e2e.ts',
- '!packages/md-conformance/**',
- '!packages/app/tests/fidelity/**',
- '!packages/core/src/markdown/**/*.test.ts',
- '!packages/core/src/bridge/**/*.test.ts',
- '!**/*.private.*',
- 'lint-plugins/ok-rules/__fixtures__/no-inline-tolerance-class.fixture.tsx',
- ].sort(),
- );
- });
-});
diff --git a/packages/app/tests/lint-plugins/no-physical-direction-utility.test.ts b/packages/app/tests/lint-plugins/no-physical-direction-utility.test.ts
deleted file mode 100644
index aee033c2d..000000000
--- a/packages/app/tests/lint-plugins/no-physical-direction-utility.test.ts
+++ /dev/null
@@ -1,107 +0,0 @@
-/** The `no-physical-direction-utility` oxlint rule fixture test, per precedent #42. */
-
-import { spawnSync } from 'node:child_process';
-import { readFileSync } from 'node:fs';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- parseOxlintDiagnostics,
- readEnabledRuleIds,
- readRegisteredRuleNames,
- readRuleScope,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/no-physical-direction-utility.fixture.tsx';
-
-function checkFixture(): string {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.error).toBeUndefined();
- expect(result.status).not.toBe(0);
- return `${result.stdout}\n${result.stderr}`;
-}
-
-function countMatches(output: string, pattern: RegExp): number {
- return (output.match(pattern) ?? []).length;
-}
-
-function flaggedSource(output: string): string {
- const fixture = readFileSync(join(REPO_ROOT, FIXTURE_REL), 'utf-8').split('\n');
- const lines = parseOxlintDiagnostics(output)
- .filter((d) => d.code === 'ok(no-physical-direction-utility)')
- .map((d) => d.labels?.[0]?.span?.line)
- .filter((n): n is number => typeof n === 'number');
- expect(lines.length).toBeGreaterThan(0);
- return lines.map((n) => fixture.slice(n - 1, n + 2).join('\n')).join('\n');
-}
-
-describe('no-physical-direction-utility oxlint rule', () => {
- test('fires on exactly 7 physical direction utilities (and on no negative case)', () => {
- expect(countMatches(checkFixture(), /Physical direction utility/g)).toBe(7);
- });
-
- test('every positive case is reported', () => {
- const flagged = flaggedSource(checkFixture());
- for (const token of [
- 'ml-2 flex items-center',
- "isCompact && 'pr-1.5'",
- 'absolute top-2 right-2',
- 'pl-[var(--ok-example-reserve,1rem)]',
- 'ml-auto shrink-0',
- 'containerClassName="bottom-3 left-3',
- 'sm:-mr-1',
- ]) {
- expect(flagged).toContain(token);
- }
- });
-
- test('no negative case is reported', () => {
- const flagged = flaggedSource(checkFixture());
- for (const token of [
- 'ms-2 me-1.5 ps-6 pe-2',
- 'start-0 end-2',
- 'inset-x-0',
- 'left-1/2',
- 'mt-2 mb-2 inset-0',
- 'data-side=left',
- 'edge="right"',
- 'data-token="ml-4"',
- 'title="Row indent is pl-2"',
- 'token="pr-1.5"',
- ]) {
- expect(flagged).not.toContain(token);
- }
- });
-
- test('the diagnostic names the fix and links this rule section of the docs', () => {
- const output = checkFixture();
- expect(output).toContain('Use the logical equivalent');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-physical-direction-utility');
- });
-
- test('rule is registered, enabled, and scoped to the chrome', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-physical-direction-utility');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-physical-direction-utility');
- });
-
- test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'no-physical-direction-utility');
- expect(scope.sort()).toEqual(
- [
- 'packages/app/src/**/*.tsx',
- 'packages/desktop/src/**/*.tsx',
- 'packages/plugin/src/**/*.tsx',
- '!packages/app/src/editor/**',
- '!packages/app/src/components/ui/**',
- '!**/*.test.tsx',
- '!**/*.dom.test.tsx',
- 'lint-plugins/ok-rules/__fixtures__/no-physical-direction-utility.fixture.tsx',
- ].sort(),
- );
- });
-});
diff --git a/packages/app/tests/lint-plugins/no-raw-html-interactive-element.test.ts b/packages/app/tests/lint-plugins/no-raw-html-interactive-element.test.ts
deleted file mode 100644
index 3612ba606..000000000
--- a/packages/app/tests/lint-plugins/no-raw-html-interactive-element.test.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
- readRuleScope,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL =
- 'lint-plugins/ok-rules/__fixtures__/no-raw-html-interactive-element.fixture.tsx';
-
-describe('no-raw-html-interactive-element oxlint rule', () => {
- test('fires on exactly 8 positive cases (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (output.match(/Raw HTML interactive primitive/g) ?? []).length;
- expect(fires).toBe(8);
- expect(output).toContain('use shadcn Button/Input/Textarea/Select');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-raw-html-interactive-element');
- });
-
- test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-raw-html-interactive-element');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-raw-html-interactive-element');
- });
-
- test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'no-raw-html-interactive-element');
- expect(scope.sort()).toEqual(
- [
- 'packages/app/src/**/*.tsx',
- 'packages/desktop/src/**/*.tsx',
- 'packages/plugin/src/**/*.tsx',
- '!packages/app/src/editor/**',
- '!packages/app/src/components/ui/**',
- '!**/*.test.tsx',
- '!**/*.dom.test.tsx',
- '!**/*.test-helper.tsx',
- 'lint-plugins/ok-rules/__fixtures__/no-raw-html-interactive-element.fixture.tsx',
- ].sort(),
- );
- });
-});
diff --git a/packages/app/tests/lint-plugins/no-roundtrip-identity-oracle.test.ts b/packages/app/tests/lint-plugins/no-roundtrip-identity-oracle.test.ts
deleted file mode 100644
index 8496ac7b5..000000000
--- a/packages/app/tests/lint-plugins/no-roundtrip-identity-oracle.test.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * The `no-roundtrip-identity-oracle` oxlint rule fixture test, per precedent #42; its negative
- * cases include the `normalizeBridge(a) === normalizeBridge(b)` contract from precedent #38.
- */
-
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
- readRuleScope,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/no-roundtrip-identity-oracle.fixture.tsx';
-
-describe('no-roundtrip-identity-oracle oxlint rule', () => {
- test('fires on exactly 10 byte-identity oracle assertions (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.error).toBeUndefined();
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (output.match(/Byte-fidelity round-trip oracle in a public test/g) ?? []).length;
- expect(fires).toBe(10);
- expect(output).toContain('assert a fixed expected literal for a specific contract');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-roundtrip-identity-oracle');
- });
-
- test('rule is registered, enabled, and scoped to the public test surface', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-roundtrip-identity-oracle');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-roundtrip-identity-oracle');
- });
-
- test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'no-roundtrip-identity-oracle');
- expect(scope.sort()).toEqual(
- [
- 'packages/**/*.test.ts',
- 'packages/**/*.test.tsx',
- 'packages/**/*.e2e.ts',
- '!packages/md-conformance/**',
- '!packages/app/tests/fidelity/**',
- '!packages/core/src/markdown/**/*.test.ts',
- '!packages/core/src/bridge/**/*.test.ts',
- '!**/*.private.*',
- 'lint-plugins/ok-rules/__fixtures__/no-roundtrip-identity-oracle.fixture.tsx',
- ].sort(),
- );
- });
-});
diff --git a/packages/app/tests/lint-plugins/no-split-suggestion-dispatch.test.ts b/packages/app/tests/lint-plugins/no-split-suggestion-dispatch.test.ts
deleted file mode 100644
index fc1e98f56..000000000
--- a/packages/app/tests/lint-plugins/no-split-suggestion-dispatch.test.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * The `no-split-suggestion-dispatch` oxlint rule fixture test: one-transaction suggestion
- * insertion per precedent #58.
- */
-
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/no-split-suggestion-dispatch.fixture.tsx';
-
-describe('no-split-suggestion-dispatch oxlint rule', () => {
- test('fires on exactly 3 positive cases (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (output.match(/Split suggestion dispatch/g) ?? []).length;
- expect(fires).toBe(3);
- expect(output).toContain('Compose the delete and the insert into ONE chain');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-split-suggestion-dispatch');
- });
-
- test('rule is registered, enabled, and deliberately unscoped', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-split-suggestion-dispatch');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-split-suggestion-dispatch');
- });
-});
diff --git a/packages/app/tests/lint-plugins/no-themeless-pierre-diff.test.ts b/packages/app/tests/lint-plugins/no-themeless-pierre-diff.test.ts
deleted file mode 100644
index 23767a81e..000000000
--- a/packages/app/tests/lint-plugins/no-themeless-pierre-diff.test.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
- readRuleScope,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/no-themeless-pierre-diff.fixture.tsx';
-
-describe('no-themeless-pierre-diff oxlint rule', () => {
- test('fires on exactly 7 positive cases (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (output.match(/@pierre\/diffs render contract/g) ?? []).length;
- expect(fires).toBe(7);
- const themeFires = (output.match(/add `theme: okPierreTheme\(\)`/g) ?? []).length;
- const styleFires = (output.match(/does not set diffStyle: 'unified'/g) ?? []).length;
- expect(themeFires).toBe(5);
- expect(styleFires).toBe(2);
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-themeless-pierre-diff');
- });
-
- test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-themeless-pierre-diff');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-themeless-pierre-diff');
- });
-
- test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'no-themeless-pierre-diff');
- expect(scope.sort()).toEqual(
- [
- 'packages/app/src/**/*.tsx',
- '!**/*.test.tsx',
- '!**/*.dom.test.tsx',
- '!**/*.test-helper.tsx',
- 'lint-plugins/ok-rules/__fixtures__/no-themeless-pierre-diff.fixture.tsx',
- ].sort(),
- );
- });
-});
diff --git a/packages/app/tests/lint-plugins/no-unconverted-git-pathspec.test.ts b/packages/app/tests/lint-plugins/no-unconverted-git-pathspec.test.ts
deleted file mode 100644
index 0a4903dbb..000000000
--- a/packages/app/tests/lint-plugins/no-unconverted-git-pathspec.test.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-/** The `no-unconverted-git-pathspec` oxlint rule fixture test, per precedent #42. */
-
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import { NON_PATHSPEC_VERBS } from '../../../../lint-plugins/ok-rules/rules/no-unconverted-git-pathspec.mjs';
-import {
- oxlintFixtureArgs,
- parseOxlintDiagnostics,
- readEnabledRuleIds,
- readRegisteredRuleNames,
- readRuleScope,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/no-unconverted-git-pathspec.fixture.tsx';
-const RULE_CODE = 'ok(no-unconverted-git-pathspec)';
-
-function runFixture(): { status: number | null; output: string } {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.error).toBeUndefined();
- return { status: result.status, output: `${result.stdout}\n${result.stderr}` };
-}
-
-describe('no-unconverted-git-pathspec oxlint rule', () => {
- test('fires on exactly 7 planted positives (and on no negative case)', () => {
- const { status, output } = runFixture();
- expect(status).not.toBe(0);
- const fires = parseOxlintDiagnostics(output).filter((d) => d.code === RULE_CODE);
- expect(fires.length).toBe(7);
- });
-
- test('its message names the fix and links this rule section of the README', () => {
- const [first] = parseOxlintDiagnostics(runFixture().output).filter((d) => d.code === RULE_CODE);
- expect(first?.message).toContain('pathspecArgs(paths)');
- expect(first?.message).toMatch(/https?:\/\/[^\s]+/);
- expect(first?.message).toContain('lint-plugins/ok-rules/README.md#no-unconverted-git-pathspec');
- });
-
- test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-unconverted-git-pathspec');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-unconverted-git-pathspec');
- expect(readRuleScope(REPO_ROOT, 'no-unconverted-git-pathspec')).not.toEqual([]);
- });
-
- test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'no-unconverted-git-pathspec');
- expect(scope).toContain(FIXTURE_REL);
- for (const included of [
- 'packages/core/src/**/*.ts',
- 'packages/server/src/**/*.ts',
- 'packages/cli/src/**/*.ts',
- 'packages/desktop/src/**/*.ts',
- ]) {
- expect(scope).toContain(included);
- }
- for (const excluded of [
- '!packages/core/src/git-pathspec.ts',
- '!**/*.test.ts',
- '!**/*.test-helper.ts',
- ]) {
- expect(scope).toContain(excluded);
- }
- });
-
- test('exempts every verb whose "--" operands are not pathspecs, and nothing else', () => {
- expect([...NON_PATHSPEC_VERBS].sort()).toEqual([
- 'clone',
- 'hash-object',
- 'mv',
- 'update-index',
- 'worktree',
- ]);
- });
-});
diff --git a/packages/app/tests/lint-plugins/no-unwrapped-user-facing-string.test.ts b/packages/app/tests/lint-plugins/no-unwrapped-user-facing-string.test.ts
deleted file mode 100644
index 1d33985df..000000000
--- a/packages/app/tests/lint-plugins/no-unwrapped-user-facing-string.test.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-/** The `no-unwrapped-user-facing-string` oxlint rule fixture test, per precedent #42. */
-
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
- readRuleScope,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL =
- 'lint-plugins/ok-rules/__fixtures__/no-unwrapped-user-facing-string.fixture.tsx';
-
-function checkFixture(): string {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.error).toBeUndefined();
- expect(result.status).not.toBe(0);
- return `${result.stdout}\n${result.stderr}`;
-}
-
-function countMatches(output: string, pattern: RegExp): number {
- return (output.match(pattern) ?? []).length;
-}
-
-describe('no-unwrapped-user-facing-string oxlint rule', () => {
- test('fires on exactly 15 unwrapped user-facing strings (and on no negative case)', () => {
- expect(countMatches(checkFixture(), /Unwrapped user-facing string/g)).toBe(15);
- });
-
- test('each branch carries its own share of the count', () => {
- const output = checkFixture();
- expect(countMatches(output, /Unwrapped user-facing string in a toast argument/g)).toBe(2);
- expect(countMatches(output, /Unwrapped user-facing string in JSX text/g)).toBe(2);
- expect(countMatches(output, /Unwrapped user-facing string in a UI-facing attribute/g)).toBe(4);
- expect(
- countMatches(output, /Unwrapped user-facing string in a UI-facing object property/g),
- ).toBe(7);
- });
-
- test('the diagnostic names the fix and links this rule section of the docs', () => {
- const output = checkFixture();
- expect(output).toContain('Wrap it with the Lingui');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-unwrapped-user-facing-string');
- });
-
- test('rule is registered, enabled, and scoped to the product surface', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-unwrapped-user-facing-string');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-unwrapped-user-facing-string');
- });
-
- test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'no-unwrapped-user-facing-string');
- expect(scope.sort()).toEqual(
- [
- 'packages/app/src/**/*.ts',
- 'packages/app/src/**/*.tsx',
- 'packages/desktop/src/**/*.ts',
- 'packages/desktop/src/**/*.tsx',
- 'packages/plugin/src/**/*.ts',
- 'packages/plugin/src/**/*.tsx',
- '!packages/app/src/editor/**',
- '!packages/app/src/components/ui/**',
- '!packages/desktop/src/main/**',
- '!**/*.test.ts',
- '!**/*.test.tsx',
- '!**/*.dom.test.tsx',
- 'lint-plugins/ok-rules/__fixtures__/no-unwrapped-user-facing-string.fixture.tsx',
- ].sort(),
- );
- });
-});
diff --git a/packages/app/tests/lint-plugins/ok-rules-scope-partition.test.ts b/packages/app/tests/lint-plugins/ok-rules-scope-partition.test.ts
deleted file mode 100644
index defd7c1e5..000000000
--- a/packages/app/tests/lint-plugins/ok-rules-scope-partition.test.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import plugin, { rules } from '../../../../lint-plugins/ok-rules/index.mjs';
-import {
- isInScope,
- RULE_SCOPES,
- UNSCOPED_RULES,
-} from '../../../../lint-plugins/ok-rules/scope.mjs';
-import { readJsPluginSpecifiers } from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const registered = Object.keys(rules).sort();
-
-describe('ok-rules scope table', () => {
- test('every registered rule is either scoped or deliberately unscoped, never both', () => {
- const scoped = Object.keys(RULE_SCOPES);
- const unscoped = [...UNSCOPED_RULES];
- expect([...scoped, ...unscoped].sort()).toEqual(registered);
- expect(scoped.filter((r) => UNSCOPED_RULES.has(r))).toEqual([]);
- });
-
- test('UNSCOPED_RULES holds exactly the rules that are deliberately global', () => {
- expect([...UNSCOPED_RULES].sort()).toEqual([
- 'microcopy-ellipsis',
- 'no-hand-rolled-spinner',
- 'no-loosely-typed-webcontents-ipc',
- 'no-resolved-value-theme-source',
- 'no-sentinel-signal-target',
- 'no-split-suggestion-dispatch',
- 'no-unportaled-editor-content',
- ]);
- });
-
- test('the `ok` plugin registers exactly the rules it exports', () => {
- expect(Object.keys(plugin.rules).sort()).toEqual(registered);
- });
-
- test('an unclassified rule name fails closed rather than scoping everywhere', () => {
- expect(() => isInScope('rule-that-does-not-exist', 'packages/app/src/x.tsx')).toThrow(
- /no entry in the scope table it was looked up in/,
- );
- });
-
- test('UNSCOPED_RULES does not leak into a caller-supplied table', () => {
- const unscopedName = [...UNSCOPED_RULES][0];
- expect(() => isInScope(unscopedName, 'packages/app/src/x.tsx', {})).toThrow(
- /no entry in the scope table it was looked up in/,
- );
- expect(isInScope(unscopedName, 'packages/app/src/x.tsx')).toBe(true);
- });
-
- test('oxlint.config.ts still loads the `ok` plugin these rules are exported from', async () => {
- expect(await readJsPluginSpecifiers(join(__dirname, '..', '..', '..', '..'))).toContain(
- './lint-plugins/ok-rules/index.mjs',
- );
- });
-
- test('every scope entry names its own fixture, so the fixture test can fire', () => {
- for (const [rule, globs] of Object.entries(RULE_SCOPES)) {
- const fixture = globs.find((g) => g.includes('__fixtures__'));
- expect(fixture, `${rule} has no fixture glob in its scope`).toBeDefined();
- expect(fixture).toContain(rule);
- }
- });
-
- test('the matcher rejects glob syntax it does not implement, rather than mis-scoping', () => {
- for (const globs of Object.values(RULE_SCOPES)) {
- for (const glob of globs) {
- expect(glob.replace(/^!/, '')).not.toMatch(/[?{}[\]()]/);
- }
- }
- });
-});
diff --git a/packages/app/tests/lint-plugins/ok-rules-vocabulary.test.ts b/packages/app/tests/lint-plugins/ok-rules-vocabulary.test.ts
deleted file mode 100644
index 65e9e69be..000000000
--- a/packages/app/tests/lint-plugins/ok-rules-vocabulary.test.ts
+++ /dev/null
@@ -1,269 +0,0 @@
-import { isTestOnlySourceFile } from '../../../../test-support/test-only-source-file.mjs';
-/**
- * The rule corpus precedent #42 names carries no vocabulary from the retired GritQL plugin or
- * the Bun runner; the corpus is `CORPUS_DIRS` and `TEST_DIRS`, read from the constants.
- */
-
-import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
-import { join, relative, sep } from 'node:path';
-import { describe, expect, test } from 'vitest';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-
-const CORPUS_DIRS = [
- 'lint-plugins/ok-rules',
- 'packages/app/tests/lint-plugins',
- 'packages/app/src/lint-plugins',
- 'packages/md-conformance/src/lint-plugins',
- 'packages/md-conformance/src/contracts',
-];
-
-const TEST_DIRS = ['packages/app/tests/integration', 'packages/desktop/tests/integration'];
-
-const RETIRED = /gritql|\.grit\b|biome-plugins|bun run/i;
-
-const HISTORICAL = /\b(?:retired|replaced|superseded|no longer|used to|formerly|migrat)/i;
-
-const ENGINE_NAMES = ['GritQL', 'biome', 'eslint', 'remark', 'rehype', 'vite', 'babel', 'oxlint'];
-
-const DEMOTED_UNAMBIGUOUS = new RegExp(
- [
- String.raw`\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+ (?:(?:${ENGINE_NAMES.join('|')}) )?plugins?\b`,
- String.raw`\bok/[a-z0-9-]+\b.{0,60}\bplugins?\b`,
- String.raw`\bplugins?\b\s*(?:test|fixture)\b`,
- ].join('|'),
- 'i',
-);
-
-const ENGINE_PLUGINS = new RegExp(`\\b(?:${ENGINE_NAMES.join('|')})[- ]plugins?\\b`, 'gi');
-
-function pluginDirNames(): string[] {
- const dir = join(REPO_ROOT, 'lint-plugins');
- const names = readdirSync(dir, { withFileTypes: true })
- .filter((e) => e.isDirectory())
- .map((e) => e.name);
- if (names.length === 0) {
- throw new Error(
- `ok-rules-vocabulary: ${relative(REPO_ROOT, dir)} lists no plugin directories. An empty ` +
- 'alternation would strip every `plugin` token and green the gate.',
- );
- }
- return names;
-}
-
-const REAL_PLUGIN_NAMES = new RegExp(
- `\\b(?:${pluginDirNames()
- .map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
- .join('|')})\\b[^.]{0,3}(?:(?:${ENGINE_NAMES.join('|')}) )?plugins?\\b`,
- 'gi',
-);
-
-const PLUGIN_AS_MODULE = new RegExp(
- [
- 'lint-plugins',
- 'jsPlugins',
- 'plugin\\.mjs',
- 'plugins\\.html',
- 'JS[- ]plugins?',
- 'packages/\\{[^}]*plugin[^}]*\\}',
- 'packages/plugin',
- 'index\\.(?:private\\.)?mjs',
- 'lint/plugin/',
- 'import plugin',
- 'plugin\\.rules',
- '(?:`ok`|`\\.private\\.`) plugins?',
- 'PLUGIN_NAME',
- ].join('|'),
- 'gi',
-);
-
-const NEAR_RULE_VOCABULARY = new RegExp(
- [
- String.raw`\bplugins?\b\s*(?:test|fixture)`,
- String.raw`\b(?:rule|test|fixture)\b.{0,60}\bplugins?\b`,
- String.raw`\bplugins?\b.{0,60}\b(?:fires|must fire|fixture|test)\b`,
- ].join('|'),
- 'i',
-);
-
-const SELF = 'packages/app/tests/lint-plugins/ok-rules-vocabulary.test.ts';
-
-const MIRROR_ABSENT_PACKAGE_ROOT = 'packages/md-conformance';
-
-const ABSENT_ON_MIRROR = [
- 'packages/md-conformance/src/lint-plugins',
- 'packages/md-conformance/src/contracts',
-];
-
-function ruleStems(): string[] {
- const dir = join(REPO_ROOT, 'lint-plugins/ok-rules/__fixtures__');
- if (!existsSync(dir)) {
- throw new Error(
- `ok-rules-vocabulary: ${relative(REPO_ROOT, dir)} is missing. Every rule's fixture lives ` +
- 'there and it ships to the public mirror, so its absence means the corpus definition is ' +
- 'wrong rather than that this is a reduced clone.',
- );
- }
- return readdirSync(dir)
- .filter((f) => f.endsWith('.fixture.tsx'))
- .map((f) => f.replace(/\.fixture\.tsx$/, ''));
-}
-
-function walkCorpus(onFile: (file: string) => void): void {
- const walk = (dir: string) => {
- for (const entry of readdirSync(dir)) {
- const full = join(dir, entry);
- if (statSync(full).isDirectory()) walk(full);
- else if (/\.(mjs|ts|tsx|json|md)$/.test(entry)) onFile(full);
- }
- };
- for (const dir of CORPUS_DIRS) {
- const abs = join(REPO_ROOT, dir);
- if (existsSync(abs)) walk(abs);
- }
-}
-
-function posixRel(file: string): string {
- return relative(REPO_ROOT, file).split(sep).join('/');
-}
-
-function filesPerDir(): Map<string, number> {
- const counts = new Map<string, number>([...CORPUS_DIRS, ...TEST_DIRS].map((d) => [d, 0]));
- const bump = (dirs: readonly string[]) => (file: string) => {
- const rel = posixRel(file);
- if (rel === SELF) return;
- for (const dir of dirs) {
- if (rel.startsWith(`${dir}/`)) counts.set(dir, (counts.get(dir) ?? 0) + 1);
- }
- };
- walkCorpus(bump(CORPUS_DIRS));
- const bumpTestDir = bump(TEST_DIRS);
- for (const file of testDirFiles()) bumpTestDir(file);
- return counts;
-}
-
-function testDirFiles(): string[] {
- const stems = new Set(ruleStems());
- const found: string[] = [];
- for (const dir of TEST_DIRS) {
- const abs = join(REPO_ROOT, dir);
- if (!existsSync(abs)) continue;
- for (const entry of readdirSync(abs)) {
- if (!(isTestOnlySourceFile(entry, 'vitest') && entry.endsWith('.ts'))) continue;
- if (stems.has(entry.replace(/\.test\.ts$/, ''))) found.push(join(abs, entry));
- }
- }
- return found;
-}
-
-function corpusFiles(): string[] {
- const found: string[] = [];
- walkCorpus((file) => found.push(file));
- return [...new Set([...found, ...testDirFiles()])];
-}
-
-function readmeLine(startsWith: string): string {
- const lines = readFileSync(join(REPO_ROOT, 'lint-plugins/ok-rules/README.md'), 'utf-8').split(
- '\n',
- );
- const found = lines.filter((l) => l.startsWith(startsWith));
- if (found.length !== 1) {
- throw new Error(
- `ok-rules-vocabulary: expected exactly one README line starting "${startsWith}", found ` +
- `${found.length}. The pinned legitimate case must track a real line, not an index.`,
- );
- }
- return found[0];
-}
-
-function blank(line: string, pattern: RegExp): string {
- return line.replace(pattern, (m) => ' '.repeat(m.length));
-}
-
-function judgeDemotion(line: string, { demotedFirst = true } = {}): boolean {
- const named = blank(line, REAL_PLUGIN_NAMES);
- if (demotedFirst && DEMOTED_UNAMBIGUOUS.test(named)) return true;
- const residue = blank(blank(named, ENGINE_PLUGINS), PLUGIN_AS_MODULE);
- if (!demotedFirst && DEMOTED_UNAMBIGUOUS.test(residue)) return true;
- return /\bplugins?\b/i.test(residue) && NEAR_RULE_VOCABULARY.test(residue);
-}
-
-function scan(judge: (line: string) => boolean): string[] {
- const out: string[] = [];
- for (const file of corpusFiles()) {
- const rel = posixRel(file);
- if (rel === SELF) continue;
- readFileSync(file, 'utf-8')
- .split('\n')
- .forEach((line, i) => {
- if (judge(line)) out.push(`${rel}:${i + 1}: ${line.trim()}`);
- });
- }
- return out;
-}
-
-describe('ok-rules corpus vocabulary', () => {
- test('every corpus directory contributes at least one scanned file', () => {
- const counts = filesPerDir();
- const missing = [...counts]
- .filter(([dir, n]) => n === 0 && !ABSENT_ON_MIRROR.includes(dir))
- .map(([dir]) => dir);
- expect(missing).toEqual([]);
- });
-
- test('every mirror-exempt entry lives under the one package the mirror drops', () => {
- expect(
- ABSENT_ON_MIRROR.filter((dir) => !dir.startsWith(`${MIRROR_ABSENT_PACKAGE_ROOT}/`)),
- ).toEqual([]);
- });
-
- test('on a full checkout the exempt directories are held to the same standard', (ctx) => {
- ctx.skip(
- !existsSync(join(REPO_ROOT, MIRROR_ABSENT_PACKAGE_ROOT)),
- 'the public mirror omits the exempt package root',
- );
- const counts = filesPerDir();
- expect(ABSENT_ON_MIRROR.filter((dir) => (counts.get(dir) ?? 0) === 0)).toEqual([]);
- });
-
- test('demotion detection survives an engine name and a spanning phrase', () => {
- const demotions = [
- 'The no-hand-rolled-spinner plugin registers exactly 5 diagnostics.',
- 'The GritQL era is over; the no-hand-rolled-spinner plugin registers exactly 5 diagnostics.',
- 'The GritQL plugins were slow; the no-hand-rolled-spinner plugin fires on its fixture.',
- 'The sibling plugin fires twice on that fixture.',
- 'what the plugin test counts',
- "the oxlint path-conditional-origin plugin's enforcement target",
- 'the ok/no-hand-rolled-spinner oxlint plugin fires on its fixture.',
- 'the path-conditional-origin oxlint plugin fires on its fixture.',
- ];
- for (const line of demotions) expect(judgeDemotion(line), line).toBe(true);
-
- const legitimate = [
- readmeLine('One plugin holding every rule is deliberate'),
- 'This rule ships as its own `.private.` plugin rather than inside the `ok` plugin.',
- "describe('no-comments oxlint plugin', () => {",
- ...pluginDirNames().map((name) => `the ${name} plugin fires on that fixture`),
- 'the rehype clipboard cleanup plugins (eight strip-* plugins plus a skipper)',
- ];
- for (const line of legitimate) expect(judgeDemotion(line), line).toBe(false);
- });
-
- test('the stage order is load-bearing, not incidental', () => {
- for (const orderSensitive of [
- 'the `ok` plugin test',
- 'the ok/no-hand-rolled-spinner oxlint plugin fires on its fixture.',
- ]) {
- expect(judgeDemotion(orderSensitive), orderSensitive).toBe(true);
- expect(judgeDemotion(orderSensitive, { demotedFirst: false }), orderSensitive).toBe(false);
- }
- });
-
- test('no file names the retired GritQL or Bun mechanism as if it were current', () => {
- expect(scan((line) => RETIRED.test(line) && !HISTORICAL.test(line))).toEqual([]);
- });
-
- test('no file calls an ok rule a plugin', () => {
- expect(scan(judgeDemotion)).toEqual([]);
- });
-});
diff --git a/packages/app/tests/lint-plugins/playwright-prefer-to-have-count.test.ts b/packages/app/tests/lint-plugins/playwright-prefer-to-have-count.test.ts
deleted file mode 100644
index fc4e80f5f..000000000
--- a/packages/app/tests/lint-plugins/playwright-prefer-to-have-count.test.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-/** The `playwright-prefer-to-have-count` oxlint rule fixture test, per precedent #42. */
-
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
- readRuleScope,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL =
- 'lint-plugins/ok-rules/__fixtures__/playwright-prefer-to-have-count.fixture.tsx';
-
-describe('playwright-prefer-to-have-count oxlint rule', () => {
- test('fires on exactly 3 one-shot count reads (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (output.match(/One-shot count read never retries/g) ?? []).length;
- expect(fires).toBe(3);
- expect(output).toContain('use the web-first `await expect(locator).toHaveCount(n)`');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#playwright-prefer-to-have-count');
- });
-
- test('rule is registered, enabled, and scoped to the e2e suites', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('playwright-prefer-to-have-count');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/playwright-prefer-to-have-count');
- });
-
- test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'playwright-prefer-to-have-count');
- expect(scope.sort()).toEqual(
- [
- 'packages/app/tests/stress/**/*.e2e.ts',
- 'packages/app/tests/visual/**/*.e2e.ts',
- 'packages/app/tests/a11y/**/*.e2e.ts',
- 'lint-plugins/ok-rules/__fixtures__/playwright-prefer-to-have-count.fixture.tsx',
- ].sort(),
- );
- });
-});
diff --git a/packages/app/vitest.integration.config.ts b/packages/app/vitest.integration.config.ts
index 4bdc9c6e2..d732e8634 100644
--- a/packages/app/vitest.integration.config.ts
+++ b/packages/app/vitest.integration.config.ts
@@ -2,7 +2,7 @@ import { defineConfig, type ViteUserConfig } from 'vitest/config';
import { appVitestConfig } from './vitest.config';
// Integration tier: multi-client CRDT convergence over the real Node test
-// harness (tests/integration) plus the meta and lint-plugin suites. Reuses the
+// harness (tests/integration) plus the meta suite. Reuses the
// app base config (lingui macro shim, single-instance dedupe, development-
// conditions pin, Bun global facade, per-test IDB reset); the three CI cells
// map 1:1 onto vitest's native `--shard=1/3`, `--shard=2/3`, `--shard=3/3`.
@@ -17,11 +17,7 @@ export const appIntegrationVitestConfig = {
...appVitestConfig,
test: {
...appVitestConfig.test,
- include: [
- 'tests/integration/**/*.test.ts?(x)',
- 'tests/meta/**/*.test.ts?(x)',
- 'tests/lint-plugins/**/*.test.ts?(x)',
- ],
+ include: ['tests/integration/**/*.test.ts?(x)', 'tests/meta/**/*.test.ts?(x)'],
exclude: [...appVitestConfig.test.exclude, '**/per-session-um-perf.test.ts'],
// Per-test / per-hook budget for the CRDT convergence suite, carried over
// from the bun `--timeout 30000`. Declared here (not only inherited) so the
diff --git a/packages/desktop/tests/integration/no-loosely-typed-webcontents-ipc.test.ts b/packages/desktop/tests/integration/no-loosely-typed-webcontents-ipc.test.ts
deleted file mode 100644
index 1a713951d..000000000
--- a/packages/desktop/tests/integration/no-loosely-typed-webcontents-ipc.test.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-/** The `no-loosely-typed-webcontents-ipc` oxlint rule fixture test, per precedent #42. */
-
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL =
- 'lint-plugins/ok-rules/__fixtures__/no-loosely-typed-webcontents-ipc.fixture.tsx';
-
-describe('no-loosely-typed-webcontents-ipc oxlint rule', () => {
- test('fires on exactly 6 banned primitives (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (output.match(/Direct electron IPC primitive/g) ?? []).length;
- expect(fires).toBe(6);
- expect(output).toContain('route through createInvoker');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-loosely-typed-webcontents-ipc');
- });
-
- test('rule is registered, enabled, and deliberately unscoped', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-loosely-typed-webcontents-ipc');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-loosely-typed-webcontents-ipc');
- });
-});
diff --git a/packages/desktop/tests/integration/no-resolved-value-theme-source.test.ts b/packages/desktop/tests/integration/no-resolved-value-theme-source.test.ts
deleted file mode 100644
index b640ac6b8..000000000
--- a/packages/desktop/tests/integration/no-resolved-value-theme-source.test.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-/** The `no-resolved-value-theme-source` oxlint rule fixture test, per precedent #42. */
-
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/no-resolved-value-theme-source.fixture.tsx';
-
-describe('1-way theme contract — no-resolved-value-theme-source oxlint rule', () => {
- test('fires on exactly 3 positive cases (and on no negative case)', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
- const fires = (output.match(/1-way theme contract:/g) ?? []).length;
- expect(fires).toBe(3);
- expect(output).toContain('pass the unresolved CRDT value');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-resolved-value-theme-source');
- });
-
- test('rule is registered, enabled, and deliberately unscoped', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-resolved-value-theme-source');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-resolved-value-theme-source');
- });
-});
diff --git a/packages/desktop/tests/integration/no-uninstall-forbidden-import.test.ts b/packages/desktop/tests/integration/no-uninstall-forbidden-import.test.ts
deleted file mode 100644
index e2f0f5dbe..000000000
--- a/packages/desktop/tests/integration/no-uninstall-forbidden-import.test.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-import { spawnSync } from 'node:child_process';
-import { join } from 'node:path';
-import { describe, expect, test } from 'vitest';
-import {
- oxlintFixtureArgs,
- readEnabledRuleIds,
- readRegisteredRuleNames,
- readRuleScope,
-} from '../../../../test-support/read-ok-rules-config.test-helper';
-
-const REPO_ROOT = join(__dirname, '..', '..', '..', '..');
-const FIXTURE_REL = 'lint-plugins/ok-rules/__fixtures__/no-uninstall-forbidden-import.fixture.tsx';
-
-describe('no-uninstall-forbidden-import oxlint rule', () => {
- test('fires on exactly 13 cases (12 forbidden imports + 1 dynamic import), and on no negative case', () => {
- const result = spawnSync('pnpm', oxlintFixtureArgs(FIXTURE_REL), {
- cwd: REPO_ROOT,
- encoding: 'utf-8',
- });
- expect(result.status).not.toBe(0);
- const output = `${result.stdout}\n${result.stderr}`;
-
- const fires = (output.match(/ok\(no-uninstall-forbidden-import\)/g) ?? []).length;
- expect(fires).toBe(13);
- const forbidden = (output.match(/Forbidden module in the uninstall entry/g) ?? []).length;
- const dynamic = (output.match(/Dynamic import under src\/uninstall/g) ?? []).length;
- expect(forbidden).toBe(12);
- expect(dynamic).toBe(1);
-
- expect(output).toContain('must connect to nothing');
- expect(output).toContain('eager-load');
- expect(output).toMatch(/https?:\/\/[^\s]+/);
- expect(output).toContain('lint-plugins/ok-rules/README.md#no-uninstall-forbidden-import');
- });
-
- test('rule is registered, enabled, and scoped via its RULE_SCOPES entry', async () => {
- expect(await readRegisteredRuleNames(REPO_ROOT)).toContain('no-uninstall-forbidden-import');
- expect(await readEnabledRuleIds(REPO_ROOT)).toContain('ok/no-uninstall-forbidden-import');
- expect(readRuleScope(REPO_ROOT, 'no-uninstall-forbidden-import')).not.toEqual([]);
- });
-
- test('its scope table still carries every include and exclude the rule depends on', () => {
- const scope = readRuleScope(REPO_ROOT, 'no-uninstall-forbidden-import');
- expect(scope).toContain('packages/app/src/uninstall/**/*.ts');
- expect(scope).toContain('packages/app/src/uninstall/**/*.tsx');
- expect(scope).toContain('!packages/app/src/uninstall/**/*.test.ts');
- expect(scope).toContain('!packages/app/src/uninstall/**/*.test.tsx');
- expect(scope).toContain('!packages/app/src/uninstall/**/*.dom.test.tsx');
- });
-});
diff --git a/test-support/ok-rules-fixture-lint.ts b/test-support/ok-rules-fixture-lint.ts
new file mode 100644
index 000000000..7335c61f5
--- /dev/null
+++ b/test-support/ok-rules-fixture-lint.ts
@@ -0,0 +1,89 @@
+import { spawnSync } from 'node:child_process';
+import { readdirSync, readFileSync } from 'node:fs';
+import { createRequire } from 'node:module';
+import { dirname, join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import type { TestProject } from 'vitest/node';
+
+const OK_RULES_FIXTURES = 'lint-plugins/ok-rules/__fixtures__';
+
+const OK_RULES_FIXTURE_CONFIG = `${OK_RULES_FIXTURES}/oxlint.fixtures.json`;
+
+const OK_ROOT = fileURLToPath(new URL('..', import.meta.url));
+
+const OUTPUT_LIMIT = 4000;
+
+const FIXTURE_SUFFIX = '.fixture.tsx';
+
+interface ReportedDiagnostic {
+ code?: string;
+ filename?: string;
+ message?: string;
+ labels?: Array<{ span?: { line?: number; column?: number } }>;
+}
+
+export type OkRulesFixtureLint = { diagnostics: ReportedDiagnostic[] } | { error: string };
+
+declare module 'vitest' {
+ export interface ProvidedContext {
+ okRulesFixtureLint?: OkRulesFixtureLint;
+ }
+}
+
+function oxlintBin(): string {
+ const manifest = createRequire(import.meta.url).resolve('oxlint/package.json');
+ const { bin } = JSON.parse(readFileSync(manifest, 'utf8')) as { bin: Record<string, string> };
+ return join(dirname(manifest), bin.oxlint);
+}
+
+function clip(text: string | null | undefined): string {
+ const trimmed = text?.trim() || '(empty)';
+ return trimmed.length > OUTPUT_LIMIT
+ ? `${trimmed.slice(0, OUTPUT_LIMIT)}... (${trimmed.length - OUTPUT_LIMIT} more characters)`
+ : trimmed;
+}
+
+function lintOkRulesFixtures(): OkRulesFixtureLint {
+ const fixtures = readdirSync(join(OK_ROOT, OK_RULES_FIXTURES)).filter((name) =>
+ name.endsWith(FIXTURE_SUFFIX),
+ );
+ const result = spawnSync(
+ process.execPath,
+ [oxlintBin(), '-f', 'json', '-c', OK_RULES_FIXTURE_CONFIG, OK_RULES_FIXTURES],
+ { cwd: OK_ROOT, encoding: 'utf-8', windowsHide: true, maxBuffer: 256 * 1024 * 1024 },
+ );
+ const output = `stdout: ${clip(result.stdout)}\nstderr: ${clip(result.stderr)}`;
+ const run = `oxlint over ${OK_RULES_FIXTURES} with ${OK_RULES_FIXTURE_CONFIG}`;
+ if (result.error || result.status !== 1) {
+ return {
+ error: `ok-rules fixture lint: ${run} ${result.error ? `could not run (${result.error.message})` : `exited ${result.status ?? `on signal ${result.signal}`}, not 1`}, so no rule's fires can be read from it. Every fixture carries error-severity fires, so a clean lint exits 1.\n${output}`,
+ };
+ }
+ let report: { number_of_files?: number; diagnostics?: ReportedDiagnostic[] };
+ try {
+ report = JSON.parse(result.stdout);
+ } catch {
+ return { error: `ok-rules fixture lint: ${run} exited 1 without a JSON report.\n${output}` };
+ }
+ const linted = new Set(fixtures.map((name) => `${OK_RULES_FIXTURES}/${name}`));
+ const unattributed = (report.diagnostics ?? []).filter(
+ (diagnostic) => typeof diagnostic.filename !== 'string' || !linted.has(diagnostic.filename),
+ );
+ if (unattributed.length > 0) {
+ return {
+ error: `ok-rules fixture lint: ${run} reported ${unattributed.length} diagnostic(s) naming no fixture, which no rule test would read: ${JSON.stringify(unattributed.slice(0, 3))}`,
+ };
+ }
+ if (report.number_of_files !== fixtures.length) {
+ return {
+ error: `ok-rules fixture lint: ${run} linted ${report.number_of_files} files, but ${OK_RULES_FIXTURES} holds ${fixtures.length} *${FIXTURE_SUFFIX} fixtures (${fixtures.join(', ')}), so a fixture went unlinted or a lintable file that is not a fixture sits beside them.`,
+ };
+ }
+ return { diagnostics: report.diagnostics ?? [] };
+}
+
+export default function provideOkRulesFixtureLint(project: TestProject): void {
+ const provide = () => project.provide('okRulesFixtureLint', lintOkRulesFixtures());
+ provide();
+ project.onTestsRerun(provide);
+}
diff --git a/test-support/read-ok-rules-config.test-helper.ts b/test-support/read-ok-rules-config.test-helper.ts
index 11aeba6b0..e3b576678 100644
--- a/test-support/read-ok-rules-config.test-helper.ts
+++ b/test-support/read-ok-rules-config.test-helper.ts
@@ -1,26 +1,73 @@
-import { join } from 'node:path';
-import { pathToFileURL } from 'node:url';
+import { join, relative, sep } from 'node:path';
+import { fileURLToPath, pathToFileURL } from 'node:url';
+import { expect, inject } from 'vitest';
// @ts-expect-error untyped ESM lint-plugin module
import { RULE_SCOPES } from '../lint-plugins/ok-rules/scope.mjs';
+import type { OkRulesFixtureLint } from './ok-rules-fixture-lint.ts';
+import { UNCACHED_TIER_CONFIG } from './uncached-tier';
-const OK_RULES_FIXTURE_CONFIG = 'lint-plugins/ok-rules/__fixtures__/oxlint.fixtures.json';
+const OK_ROOT = fileURLToPath(new URL('..', import.meta.url));
-export function oxlintFixtureArgs(fixtureRel: string): string[] {
- return ['exec', 'oxlint', '-f', 'json', '-c', OK_RULES_FIXTURE_CONFIG, fixtureRel];
+interface OkRulesFixtureDiagnostic {
+ code: string;
+ position: string;
+ message: string;
}
-export interface OxlintDiagnostic {
- message: string;
- code: string;
- filename: string;
- labels?: Array<{ span?: { line?: number; column?: number } }>;
+function positionOf(line: number, column: number): string {
+ return `${line}:${column}`;
+}
+
+function comparePositions(a: OkRulesFixtureDiagnostic, b: OkRulesFixtureDiagnostic): number {
+ const [aLine, aColumn] = a.position.split(':').map(Number);
+ const [bLine, bColumn] = b.position.split(':').map(Number);
+ return (
+ a.code.localeCompare(b.code) ||
+ aLine - bLine ||
+ aColumn - bColumn ||
+ a.message.localeCompare(b.message)
+ );
+}
+
+function outsideTheTier(): Error {
+ const testPath = expect.getState().testPath;
+ const test = testPath
+ ? relative(OK_ROOT, testPath).split(sep).join('/')
+ : 'lint-plugins/ok-rules/tests';
+ return new Error(
+ `read-ok-rules-config: no ok-rules fixture lint was provided to this test, so it is running outside the uncached tier, whose global setup lints every fixture once. Run it from the Open Knowledge root with: pnpm exec vitest run --config ${UNCACHED_TIER_CONFIG} ${test}`,
+ );
}
-export function parseOxlintDiagnostics(output: string): OxlintDiagnostic[] {
- const start = output.indexOf('{');
- const end = output.lastIndexOf('}');
- if (start === -1 || end === -1) return [];
- return (JSON.parse(output.slice(start, end + 1)).diagnostics ?? []) as OxlintDiagnostic[];
+export function lintOkRulesFixture(fixtureRel: string): OkRulesFixtureDiagnostic[] {
+ const lint: OkRulesFixtureLint | undefined = inject('okRulesFixtureLint');
+ if (lint === undefined) throw outsideTheTier();
+ if ('error' in lint) throw new Error(lint.error);
+ return lint.diagnostics
+ .filter((diagnostic) => diagnostic.filename === fixtureRel)
+ .map((diagnostic) => {
+ const span = diagnostic.labels?.[0]?.span;
+ if (typeof diagnostic.code !== 'string') {
+ throw new Error(
+ `read-ok-rules-config: oxlint reported a diagnostic on ${fixtureRel} that names no rule, so a rule threw while linting it or oxlint could not parse it. oxlint says:\n${diagnostic.message ?? '(no message)'}\nFull diagnostic: ${JSON.stringify(diagnostic)}`,
+ );
+ }
+ if (
+ typeof diagnostic.message !== 'string' ||
+ typeof span?.line !== 'number' ||
+ typeof span.column !== 'number'
+ ) {
+ throw new Error(
+ `read-ok-rules-config: oxlint reported a ${diagnostic.code} diagnostic on ${fixtureRel} without a message or position: ${JSON.stringify(diagnostic)}`,
+ );
+ }
+ return {
+ code: diagnostic.code,
+ position: positionOf(span.line, span.column),
+ message: diagnostic.message,
+ };
+ })
+ .sort(comparePositions);
}
interface OxlintConfig {
diff --git a/turbo.json b/turbo.json
index 4f0ef574d..b95c9abb7 100644
--- a/turbo.json
+++ b/turbo.json
@@ -92,12 +92,7 @@
"test": {
"dependsOn": ["^build"],
"cache": true,
- "inputs": [
- "$TURBO_DEFAULT$",
- "$TURBO_ROOT$/test-support/**",
- "../../oxlint.config.ts",
- "../../lint-plugins/**"
- ]
+ "inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/test-support/**"]
},
"@inkeep/open-knowledge-docs#test": {
"dependsOn": ["^build", "build"],
@@ -133,8 +128,7 @@
"$TURBO_DEFAULT$",
"!CHANGELOG.md",
"!README.md",
- "../../oxlint.config.ts",
- "../../lint-plugins/**",
+ "$TURBO_ROOT$/lint-plugins/no-comments/**",
"$TURBO_ROOT$/test-support/**",
"../../scripts/verify-native-config-in-packaged-dmg.mjs",
"../../scripts/verify-keyring-in-packaged-dmg.mjs",
@@ -151,13 +145,7 @@
"@inkeep/md-conformance#test": {
"dependsOn": ["^build"],
"cache": true,
- "inputs": [
- "$TURBO_DEFAULT$",
- "$TURBO_ROOT$/test-support/**",
- "../server/src/**/*.ts",
- "../../oxlint.config.ts",
- "../../lint-plugins/**"
- ]
+ "inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/test-support/**", "../server/src/**/*.ts"]
},
"@inkeep/open-knowledge-core#test": {
"dependsOn": ["^build"],
@@ -185,11 +173,7 @@
"$TURBO_ROOT$/test-support/**",
"../server/src/**/*.ts",
"../core/src/**/*.ts",
- "../desktop/tests/**/*.{ts,tsx}",
- "../md-conformance/src/**/*.{ts,tsx,mjs,json,md}",
- "../../biome.jsonc",
- "../../lint-plugins/**",
- "../../oxlint.config.ts",
+ "$TURBO_ROOT$/lint-plugins/no-comments/**",
"$TURBO_ROOT$/packages/cli/src/**",
"$TURBO_ROOT$/packages/cli/package.json"
]
@@ -202,11 +186,7 @@
"$TURBO_ROOT$/test-support/**",
"../server/src/**/*.ts",
"../core/src/**/*.ts",
- "../desktop/tests/**/*.{ts,tsx}",
- "../md-conformance/src/**/*.{ts,tsx,mjs,json,md}",
- "../../biome.jsonc",
- "../../lint-plugins/**",
- "../../oxlint.config.ts",
+ "$TURBO_ROOT$/lint-plugins/no-comments/**",
"$TURBO_ROOT$/packages/cli/src/**",
"$TURBO_ROOT$/packages/cli/package.json"
]
@@ -219,11 +199,7 @@
"$TURBO_ROOT$/test-support/**",
"../server/src/**/*.ts",
"../core/src/**/*.ts",
- "../desktop/tests/**/*.{ts,tsx}",
- "../md-conformance/src/**/*.{ts,tsx,mjs,json,md}",
- "../../biome.jsonc",
- "../../lint-plugins/**",
- "../../oxlint.config.ts",
+ "$TURBO_ROOT$/lint-plugins/no-comments/**",
"$TURBO_ROOT$/packages/cli/src/**",
"$TURBO_ROOT$/packages/cli/package.json"
]
@@ -236,11 +212,7 @@
"$TURBO_ROOT$/test-support/**",
"../server/src/**/*.ts",
"../core/src/**/*.ts",
- "../desktop/tests/**/*.{ts,tsx}",
- "../md-conformance/src/**/*.{ts,tsx,mjs,json,md}",
- "../../biome.jsonc",
- "../../lint-plugins/**",
- "../../oxlint.config.ts",
+ "$TURBO_ROOT$/lint-plugins/no-comments/**",
"$TURBO_ROOT$/packages/cli/src/**",
"$TURBO_ROOT$/packages/cli/package.json"
]
diff --git a/vitest.uncached.config.ts b/vitest.uncached.config.ts
index e4a52827f..507044287 100644
--- a/vitest.uncached.config.ts
+++ b/vitest.uncached.config.ts
@@ -9,13 +9,22 @@ import { UNCACHED_TEST_GLOBS, UNCACHED_TIER_CONFIG } from './test-support/uncach
import { uncachedTierFloor } from './test-support/uncached-tier-floor';
import scriptsConfig from './vitest.scripts.config';
+const okRulesFixtureLint = fileURLToPath(
+ new URL('./test-support/ok-rules-fixture-lint.ts', import.meta.url),
+);
+
const SOURCES = [
{ name: 'packages/app/vitest.config.ts', dir: 'packages/app', config: appConfig },
{ name: 'packages/cli/vitest.config.ts', dir: 'packages/cli', config: cliConfig },
{ name: 'packages/core/vitest.config.ts', dir: 'packages/core', config: coreConfig },
{ name: 'packages/desktop/vitest.config.ts', dir: 'packages/desktop', config: desktopConfig },
{ name: 'packages/server/vitest.config.ts', dir: 'packages/server', config: serverConfig },
- { name: 'vitest.scripts.config.ts', dir: '.', config: scriptsConfig },
+ {
+ name: 'vitest.scripts.config.ts',
+ dir: '.',
+ config: scriptsConfig,
+ tierSetup: [okRulesFixtureLint],
+ },
];
const reconcile = fileURLToPath(
@@ -24,7 +33,7 @@ const reconcile = fileURLToPath(
export default defineConfig({
test: {
- projects: SOURCES.map(({ name, dir, config }) => {
+ projects: SOURCES.map(({ name, dir, config, tierSetup = [] }) => {
const include = config.test?.include ?? [];
const exclude = config.test?.exclude ?? [];
const missing = UNCACHED_TEST_GLOBS.filter((glob) => !exclude.includes(glob));
@@ -50,7 +59,11 @@ export default defineConfig({
name,
include: suffixed,
exclude: exclude.filter((glob) => !UNCACHED_TEST_GLOBS.includes(glob)),
- globalSetup: [reconcile, ...(Array.isArray(globalSetup) ? globalSetup : [globalSetup])],
+ globalSetup: [
+ reconcile,
+ ...tierSetup,
+ ...(Array.isArray(globalSetup) ? globalSetup : [globalSetup]),
+ ],
},
};
}),