@opendesignai/harness 0.2.0-alpha.0 → 0.4.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -44
- package/dist/THIRD-PARTY-LICENSES.md +63 -0
- package/dist/child-env-cPBUueQI.mjs +17 -0
- package/dist/cli.mjs +4916 -209
- package/dist/config.d.mts +68 -0
- package/dist/config.mjs +12 -0
- package/dist/eslint-comments.mjs +1679 -4
- package/dist/hook.d.mts +19 -0
- package/dist/hook.mjs +9843 -0
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.mjs +283 -27
- package/dist/report.d.mts +40 -0
- package/dist/report.mjs +34 -0
- package/docs/adopting.md +107 -11
- package/docs/agent-setup.md +21 -0
- package/docs/agents.md +42 -0
- package/docs/comments.md +33 -0
- package/docs/decisions/0001-oxlint.md +28 -1
- package/docs/decisions/0002-react-compiler-rules.md +39 -0
- package/docs/decisions/0004-type-aware-rules.md +43 -0
- package/docs/decisions/0005-test-weakening-rules.md +28 -0
- package/docs/diagnostics.md +58 -0
- package/docs/hooks.md +152 -36
- package/docs/ratchet.md +23 -21
- package/docs/rules/no-commented-out-code.md +47 -0
- package/docs/rules/no-swallowed-catch.md +18 -7
- package/docs/size.md +3 -1
- package/docs/verify.md +80 -0
- package/package.json +30 -6
- package/presets/react-compiler.json +2 -1
- package/presets/rules/base.json +5 -0
- package/presets/strict-types.json +5 -0
- package/presets/testing.json +22 -0
- package/presets/type-aware.json +69 -0
- package/skills/od-feature-intake/SKILL.md +22 -0
- package/skills/od-pre-pr-review/SKILL.md +46 -0
- package/dist/cli.d.mts +0 -1
- package/dist/eslint-comments.d.mts +0 -40
- package/dist/paths-DBoYPrGy.mjs +0 -59
package/docs/adopting.md
CHANGED
|
@@ -11,7 +11,7 @@ pnpm add -D --save-exact @opendesignai/harness@alpha oxlint@1.96.0
|
|
|
11
11
|
# or: npm install -D --save-exact @opendesignai/harness@alpha oxlint@1.96.0
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
pnpm 12 checks every version it installs against `minimumReleaseAge` (1,440 minutes unless the repository sets it): a version published more recently needs an entry in `minimumReleaseAgeExclude` in `pnpm-workspace.yaml`, and CI's frozen install checks the lockfile against both. To adopt or upgrade to an od-harness release within that window, install the exact version and commit its entry, for example `"@opendesignai/harness@0.
|
|
14
|
+
pnpm 12 checks every version it installs against `minimumReleaseAge` (1,440 minutes unless the repository sets it): a version published more recently needs an entry in `minimumReleaseAgeExclude` in `pnpm-workspace.yaml`, and CI's frozen install checks the lockfile against both. To adopt or upgrade to an od-harness release within that window, install the exact version and commit its entry, for example `"@opendesignai/harness@0.4.0-alpha.0"`. Under pnpm's built-in setting, which is not strict, `pnpm install` writes the entry itself; a repository that sets `minimumReleaseAge` approves it at pnpm's prompt or adds it by hand. The entry can go once the release is older than the window; the pnpm documentation describes these settings.
|
|
15
15
|
|
|
16
16
|
Releases are published to npm under the `opendesignai` organization with the `alpha` dist-tag, by the release workflow through npm trusted publishing ([README, Versioning](../README.md#versioning)). To try an unreleased change, run `pnpm pack` in an od-harness checkout and install the tarball it writes (never the checkout itself, which has `catalog:` and `workspace:` specifiers), for example `"@opendesignai/harness": "file:vendor/opendesignai-harness-0.1.0-alpha.0.tgz"`.
|
|
17
17
|
|
|
@@ -52,12 +52,14 @@ Create `.oxlintrc.json` at the repository root:
|
|
|
52
52
|
|
|
53
53
|
- Presets: always `base`; add `platform-boundary` where shell and product code share the repository (od-platform, the openmotion pilot branch, opengame); add `product` in product packages.
|
|
54
54
|
- `od/no-product-literal` defaults to the full product names (`opengame`, `openmotion`), because the short ids `game` and `motion` are also ordinary words in product code. Platform repositories, where the short ids are product identities (manifest `name`, `/api/<name>/`), list them explicitly: `"od/no-product-literal": ["error", { "products": ["opengame", "openmotion", "game", "motion"] }]`.
|
|
55
|
-
- `react-compiler`: add `./node_modules/@opendesignai/harness/presets/react-compiler.json`
|
|
55
|
+
- `react-compiler`: add `./node_modules/@opendesignai/harness/presets/react-compiler.json` after `base` in `extends`. od-platform extends it from the start. A product repository adds it in the change that turns React Compiler on. The preset enables the eight compiler correctness rules that `base` disables, plus `react/unsupported-syntax`. See [ADR 0002](decisions/0002-react-compiler-rules.md).
|
|
56
|
+
- With `categories.suspicious: "error"`, `base` keeps `react/exhaustive-effect-dependencies`, `react/hooks`, and `react/memo-dependencies` off. That category still enables `react/capitalized-calls`. For direct opt-in and factory exceptions, see [optional `react/capitalized-calls`](decisions/0002-react-compiler-rules.md#optional-reactcapitalized-calls).
|
|
57
|
+
- `type-aware`: opt in after `base` once lint can resolve your project's types. See [Type-aware linting](#type-aware-linting).
|
|
56
58
|
- `extends` takes file paths, not package names, so keep the `./node_modules/…` prefix.
|
|
57
|
-
- The base preset reports unused disable directives as errors (`options.reportUnusedDisableDirectives`); there is no need to repeat
|
|
59
|
+
- The base preset reports unused disable directives as errors (`options.reportUnusedDisableDirectives`) and fails the run on warnings (`options.denyWarnings`); there is no need to repeat either here. A rule this file sets to `"warn"` therefore fails the run like an error: during adoption, baseline its findings or turn it off rather than leave it at `warn`.
|
|
58
60
|
- The base preset already turns `od/no-cjk-literal` off in tests and fixtures (`*.test.*`, `*.spec.*`, `__tests__/`, `__fixtures__/`, `fixtures/`). Exclude the repository's own i18n catalog, as `ignorePatterns` does above.
|
|
59
61
|
- Exemptions are `overrides` entries in this file. The file belongs to the platform owner (CODEOWNERS); every exemption is reviewed there, never inline.
|
|
60
|
-
- CODEOWNERS also gives the platform owner `package.json` (the harness version), `.harness/config.json` and the knip configuration (step 3a). `od-harness ratchet`
|
|
62
|
+
- CODEOWNERS also gives the platform owner `package.json` (the harness version), `.harness/config.json` and the knip configuration (step 3a). `od-harness ratchet` allows existing rule totals to grow only in the harness upgrade change. New rule IDs may enter an existing baseline when upgrading the harness or when a change to `.oxlintrc.json` turns them on. Give the platform owner `pnpm-workspace.yaml` too if a pnpm catalog holds the harness version. A new baseline file is allowed only in the adoption change ([ratchet](ratchet.md#why-a-config-or-version-change-admits-new-rule-ids)).
|
|
61
63
|
- Run Oxlint from the repository root: path options (`shell`, `product`) are relative to the working directory.
|
|
62
64
|
|
|
63
65
|
Add scripts:
|
|
@@ -76,11 +78,101 @@ Add scripts:
|
|
|
76
78
|
|
|
77
79
|
The scripts also tell knip that `oxlint` and `@opendesignai/harness` are in use, so `od-harness unused` does not report the two new devDependencies in the adoption change.
|
|
78
80
|
|
|
81
|
+
### Typed configuration
|
|
82
|
+
|
|
83
|
+
Oxlint 1.96.0 supports `oxlint.config.ts` and exports its own `defineConfig` and `OxlintConfig` for it. That format takes configuration objects in `extends`. The harness export builds on Oxlint's `Oxlintrc` type for JSON and reuses the `od/*` rule option types for both top-level rules and overrides. The `presets` object gives you checked preset names and paths relative to the repository root.
|
|
84
|
+
|
|
85
|
+
For optional TypeScript checking, put a script such as `lint-config.mts` at the root and include it in your TypeScript check.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { presets, type OxlintConfig } from "@opendesignai/harness/config";
|
|
89
|
+
|
|
90
|
+
const config = {
|
|
91
|
+
extends: [presets.base, presets["platform-boundary"]],
|
|
92
|
+
rules: {
|
|
93
|
+
"od/no-shell-imports-product": [
|
|
94
|
+
"error",
|
|
95
|
+
{ shell: ["studio/src/"], product: ["studio/src/motion/game/"] },
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
} satisfies OxlintConfig;
|
|
99
|
+
|
|
100
|
+
console.log(JSON.stringify(config, null, 2));
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
After type-checking, run `node lint-config.mts > .oxlintrc.json` from the repository root and commit the JSON output. Both `lint-scope` and `ratchet` expect the root `.oxlintrc.json` by default. `lint-scope` rejects files named `oxlint.config.*`, and the fallback used by `ratchet --lint-config` when Oxlint cannot print a config reads JSON.
|
|
104
|
+
|
|
105
|
+
If you also commit `lint-config.mts` and run `od-harness unused`, register the file as a knip entry point. Add `"lint:config": "node lint-config.mts > .oxlintrc.json"` under `scripts` in `package.json`, or add `lint-config.mts` to `entry` in `knip.json`. Without an entry point, `unused` reports the script as a new unused file.
|
|
106
|
+
|
|
107
|
+
### Testing and strict types
|
|
108
|
+
|
|
109
|
+
Add either or both optional presets after `base` in the root `.oxlintrc.json`:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"extends": [
|
|
114
|
+
"./node_modules/@opendesignai/harness/presets/base.json",
|
|
115
|
+
"./node_modules/@opendesignai/harness/presets/testing.json",
|
|
116
|
+
"./node_modules/@opendesignai/harness/presets/strict-types.json"
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
- `base` already checks TypeScript directives. It reports `@ts-ignore`, `@ts-nocheck`, and `@ts-expect-error` without a description. Use a described `@ts-expect-error` for a deliberate negative type test. `@ts-check` is allowed.
|
|
122
|
+
- `testing` reports skipped and focused Vitest tests. It explicitly turns off the other Vitest rules inherited from `correctness`, including `vitest/expect-expect`. Keep any Vitest rules your repository explicitly enables in its root `rules` or in a preset listed after `testing`. Oxlint uses the last `extends` entry for conflicting settings, then applies root `rules`. Additional categories selected by the repository can enable Vitest rules in those categories.
|
|
123
|
+
- `strict-types` reports any explicit TypeScript `any`. It runs with the ordinary Oxlint binary and can be adopted independently of `type-aware`.
|
|
124
|
+
|
|
125
|
+
On the three pilot snapshots, the new `base` check and `testing` each added zero diagnostics. `strict-types` reported 1,691 violations of `typescript/no-explicit-any` in opengame, 203 in openmotion, and zero in od-platform. Nine previously unused disable directives in each product snapshot began suppressing the rule, so total diagnostics increased by 1,682 in opengame and 194 in openmotion. Measure the final configuration in your repository to size the adoption change. Fix the findings, or record the newly enabled rules in an existing baseline as part of the reviewed configuration change. Repositories that adopted without a baseline fix the findings in that change. [ADR 0005](decisions/0005-test-weakening-rules.md) · [Ratchet rules](ratchet.md#why-a-config-or-version-change-admits-new-rule-ids)
|
|
126
|
+
|
|
127
|
+
### Type-aware linting
|
|
128
|
+
|
|
129
|
+
Install the exact backend version as a direct dev dependency when opting in. The harness declares it as an optional peer. Oxlint exits with status 1 if it cannot find the backend executable. Oxlint 1.95 and 1.96 require tsgolint 7.0.2008 or later. Every harness PR that upgrades Oxlint must upgrade the tsgolint pin in the same PR.
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
pnpm add -D --save-exact oxlint-tsgolint@7.0.2009
|
|
133
|
+
# or: npm install -D --save-exact oxlint-tsgolint@7.0.2009
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Add `./node_modules/@opendesignai/harness/presets/type-aware.json` to the root `.oxlintrc.json`'s `extends` array after `base`. The preset sets `options.typeAware: true` for ordinary lint, hooks and baseline generation. It enables `typescript/no-floating-promises`, `typescript/no-misused-promises` and `typescript/await-thenable` as errors.
|
|
137
|
+
|
|
138
|
+
1. **Resolve cross-package types on a clean checkout.** Point `compilerOptions.paths` at workspace package sources, or add a `"source"` condition to package `exports` and enable it with `customConditions: ["source"]`. If lint reads built `.d.ts` files instead, build before lint in CI and locally. With `gates.yml`, a caller can set `lint: false` and put `pnpm build && pnpm exec oxlint --deny-warnings --format github` on one line in `commands`. Without source mappings or built declarations, unresolved types can silently hide violations.
|
|
139
|
+
2. **Make TS 7 compiler options explicit.** Give tsgolint a root `tsconfig.json` that covers the linted projects. A solution config can use `"files": []` and reference the frontend and backend configs. Set `rootDir` to the common source root when a project spans directories. TypeScript 7 defaults to an empty `types` list and enables `strict`, so list needed ambient types explicitly and set `strict` to the intended value for each project. In the product snapshots, tracking needed `rootDir: ".."` and `types: ["node"]`, and the backend needed `strict: false` to preserve its compiler settings. Include linted test helpers in a suitable tsconfig so single-file hooks and full runs use the same project settings.
|
|
140
|
+
3. **Set a backend override if the backend still uses `strict: false`.** In the root `.oxlintrc.json`, make the override's `files` globs cover every path included by that non-strict tsconfig. The example below covers the paths in the openmotion and opengame backend tsconfigs from the trial. With non-strict null checking, conditionals produced false positives in the product snapshots. Leave `checksVoidReturn.attributes` at its default, `true`.
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"files": ["*.ts", "src/**", "shared/**", "gateway/**", "tracking/**"],
|
|
145
|
+
"rules": {
|
|
146
|
+
"typescript/no-misused-promises": ["error", { "checksConditionals": false }]
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
4. **Generate suppressions with the final tsconfigs and lint overrides.** If the repository already has `oxlint-suppressions.json`, run `pnpm exec oxlint --suppress-all` on an otherwise clean branch with the same type resolution and lint scope that CI uses, then verify with `pnpm exec oxlint`. Commit the suppressions with the opt-in `.oxlintrc.json` change. Even at the same harness version, `ratchet` recognizes the type-aware rules this change turns on and accepts their first entries in existing files. Existing rule totals can only shrink. A repository without a suppressions baseline fixes the findings in the opt-in change. [Ratchet rules](ratchet.md#why-a-config-or-version-change-admits-new-rule-ids)
|
|
152
|
+
|
|
153
|
+
See [ADR 0004](decisions/0004-type-aware-rules.md) for the trial results and decision.
|
|
154
|
+
|
|
155
|
+
### Lint scope
|
|
156
|
+
|
|
157
|
+
Run `pnpm exec od-harness lint-scope` or `npx --no-install od-harness lint-scope` with a harness version that provides the command. It checks the entire Git working tree and allows only the repository-root `.oxlintrc.json`, even when invoked from a package directory.
|
|
158
|
+
|
|
159
|
+
- Keep the Oxlint configuration in the root `.oxlintrc.json`. Remove other `.oxlintrc*` and `oxlint.config.*` files and move needed settings into the root file.
|
|
160
|
+
- Remove `.eslintignore` files. Ask the repository owner to review a scoped `overrides` or `ignorePatterns` entry in the root `.oxlintrc.json` for any justified exception. Document the reason in the repository's harness documentation.
|
|
161
|
+
- Keep tracked files out of Git ignore rules. The gate uses `git ls-files -ci --exclude-standard`, which includes `.gitignore`, `.git/info/exclude` and global Git excludes. Run `git check-ignore -v --no-index -- <path>` to find the rule. Narrow its pattern, or untrack an artifact that should only be generated locally or in CI. If Oxlint needs to skip a file that stays tracked, remove its Git ignore match and ask the repository owner to review an `ignorePatterns` entry in the root configuration. Document the reason.
|
|
162
|
+
|
|
163
|
+
The gate checks tracked lint configuration files and untracked ones that Git does not ignore. Ignored untracked files such as dependency installs and build artifacts are allowed.
|
|
164
|
+
|
|
165
|
+
Use `--format json` for scripts and `--format github` to print only the annotations and a short status. The default text output also attaches file annotations in GitHub Actions. [CLI diagnostics](diagnostics.md)
|
|
166
|
+
|
|
167
|
+
With a non-root `working-directory` in `gates.yml`, keep `.oxlintrc.json` at the repository root and keep the baselines in the working directory. The built-in `ratchet` step looks for the lint configuration relative to the working directory and has no input for `--lint-config`. If `ratchet` needs to recognize rule changes in the root config, set `ratchet: false` and run it in `commands` with the path to the root config relative to the working directory. For example, with `working-directory: packages/web`, use `pnpm exec od-harness ratchet --base "$HARNESS_BASE_REF" --lint-config ../../.oxlintrc.json` (or use `npx --no-install` for npm). Have the repository owner review the workflow change.
|
|
168
|
+
|
|
79
169
|
## 3. Clean up what cannot be baselined
|
|
80
170
|
|
|
81
171
|
Unused disable directives are reported as errors but cannot go into `oxlint-suppressions.json` (opengame had 44, openmotion 43). Run `oxlint --fix` (removes some) and delete the remaining reported comments by hand. This includes disable comments for rules the presets turn off, such as `oxlint-disable-line react/refs` without the `react-compiler` preset (3 in each of the two).
|
|
82
172
|
|
|
83
|
-
|
|
173
|
+
The `base` preset's `od/no-swallowed-catch` reports empty catch blocks and rejection handlers, as well as handlers that only return a constant such as `null`, `undefined`, an empty string, or a boolean. A probe is exempt when `try` contains one direct call (optionally `await`ed) followed by `return true`, and `catch` contains only `return false`. The call must be free of assignments, increments, decrements, inline functions and chained calls. Non-empty string literals and non-empty template literals without interpolations are exempt in catch blocks and promise rejection handlers. If an upgrade reports more violations and the repository has `oxlint-suppressions.json`, run `oxlint --suppress-all` on an otherwise clean branch and commit the additional suppressions for existing files with the upgrade. Ratchet allows the increase only in that change. A repository without a baseline fixes the violations in the upgrade change. Run `oxlint --prune-suppressions` to remove any stale entries after fixes. See [the rule page](rules/no-swallowed-catch.md).
|
|
174
|
+
|
|
175
|
+
Also remove disable comments that name no rule (`/* eslint-disable */`, `// eslint-disable-next-line`, `/* oxlint-disable */`). They switch off every rule in their range, `od/*` included, and both `eslint-comments/no-restricted-disable` and `unicorn/no-abusive-eslint-disable` reject them, one report each. Do not baseline them: the baseline would then hold those two entries while the violations they hide never show up in it. To find them:
|
|
84
176
|
|
|
85
177
|
```sh
|
|
86
178
|
git grep -n -E '(eslint|oxlint)-disable(-next-line|-line)?[[:space:]]*(\*/|--|$)'
|
|
@@ -170,7 +262,7 @@ A repository whose code already passes (od-platform) adopts without baselines:
|
|
|
170
262
|
|
|
171
263
|
- do not run `oxlint --suppress-all` or `od-harness size --init`, and do not commit `oxlint-suppressions.json` or `.harness/size-baseline.json`;
|
|
172
264
|
- every violation fails CI from the first day and is fixed, never frozen;
|
|
173
|
-
- `od-harness ratchet` rejects any later change that creates either baseline file, also a harness upgrade or a change to `.oxlintrc.json`, and also when an administrator merges without owner review, as long as the caller's workflow keeps `ratchet` on (turning a gate off is a reviewed workflow change). This keeps the repository at zero: violations that an upgrade or a config change brings, including a newly extended `react-compiler` preset, are fixed in that change, not frozen.
|
|
265
|
+
- `od-harness ratchet` rejects any later change that creates either baseline file, also a harness upgrade or a change to `.oxlintrc.json`, and also when an administrator merges without owner review, as long as the caller's workflow keeps `ratchet` on (turning a gate off is a reviewed workflow change). This keeps the repository at zero: violations that an upgrade or a config change brings, including a newly extended `react-compiler` or `type-aware` preset, are fixed in that change, not frozen.
|
|
174
266
|
|
|
175
267
|
## 5. Call the gate in CI
|
|
176
268
|
|
|
@@ -200,12 +292,15 @@ jobs:
|
|
|
200
292
|
Set `clones: true` and `unused: true` in the change that adopts or upgrades to a version of `@opendesignai/harness` that has these gates, together with the configuration of step 3a.
|
|
201
293
|
|
|
202
294
|
- The workflow picks pnpm (`pnpm-lock.yaml`) or `npm ci` (`package-lock.json`), sets up Node from `.node-version` and checks out the full history so `ratchet` can read the base commit.
|
|
203
|
-
-
|
|
295
|
+
- `Check harness source` validates exact registry pins and lockfile integrity before the frozen install. With pnpm, it checks project registry settings and rejects harness patches. After the install, `Check harness bin` verifies the real path of the CLI.
|
|
296
|
+
- Workflow revisions with lint-scope run `od-harness lint-scope` before `oxlint --deny-warnings --format github`. Both produce file annotations on GitHub pull requests. The workflow then runs `od-harness size` and runs `ratchet`, `clones` and `unused` with `--base "$HARNESS_BASE_REF"`. It runs enabled gates through `pnpm exec` or `npx --no-install`, then runs each line of `commands`. Every command runs even after a failure, and the job fails if any failed.
|
|
204
297
|
- `HARNESS_BASE_REF` is the PR base, the merge-queue base, or the previous commit on push.
|
|
205
|
-
-
|
|
206
|
-
-
|
|
298
|
+
- `use-verify` defaults to `false`. With a workflow ref that supports it and harness `0.3.0-alpha.0` or newer, set it to `true` to run `od-harness verify --ci --base "$HARNESS_BASE_REF"`, followed by `commands`. Verify runs lint-scope by default and ignores the individual gate inputs. The workflow warns when those inputs differ from their defaults. [Verify configuration](verify.md#repository-configuration)
|
|
299
|
+
- `lint`, `size` and `ratchet` default to `true`. `clones` and `unused` default to `false` in `v1`. In revisions with lint-scope, `lint-scope` defaults to `true` and can be disabled independently with `lint-scope: false` when `use-verify` is off. Turning a gate on or off goes through owner review.
|
|
300
|
+
- Other inputs are `commands` (default empty), `working-directory`, `node-version-file`, `fetch-depth`, `timeout-minutes` and `runs-on`. For a non-root working directory, see [Lint scope](#lint-scope) for the root configuration and `ratchet` setup. Keep `fetch-depth` at `0` so `verify`, `ratchet`, `clones` and `unused` can read the base commit. They exit with code 2 when it is missing.
|
|
301
|
+
- Use `commands` for checks that the enabled gates do not already run.
|
|
207
302
|
- Make the check `harness-gates / harness-gates` required in the branch ruleset.
|
|
208
|
-
- Reference the workflow by the git tag `v1` (`gates.yml@v1`), as above.
|
|
303
|
+
- Reference the workflow by the git tag `v1` (`gates.yml@v1`), as above. To adopt lint-scope, upgrade to a package version and workflow ref that both include it. The workflow versioning policy keeps new default-on gates out of `v1`.
|
|
209
304
|
|
|
210
305
|
## Day to day
|
|
211
306
|
|
|
@@ -219,6 +314,7 @@ Set `clones: true` and `unused: true` in the change that adopts or upgrades to a
|
|
|
219
314
|
| A file or directory is moved | `git mv` (the move must be staged), fix the imports, then, before committing, `od-harness baseline move <old path> <new path>`; commit the baselines with the moved files in the same change. Each new file must still be its old file: a rename git sees (`git diff -M30% -l0`), nothing else counts. The move is reviewed with the change that makes it: `ratchet` lists each moved entry in its output, and where CODEOWNERS covers every path the owner reviews it like any other change. See [baseline move](baseline-move.md). |
|
|
220
315
|
| `od-harness clones` reports a clone | Extract the shared code instead of copying it. Generated or vendored code goes into `clones.ignore` (owner review); the marker text `jscpd:ignore-start` or `jscpd:ignore-end` on added or edited lines (in a comment, a string or code) of the files jscpd scans—`.es`, `.es6` and files without those extensions whose first line is a shebang that contains `node` included—and tracked files among them that `.gitignore` or `.ignore` excludes, fail the gate. |
|
|
221
316
|
| `od-harness unused` reports a finding | Delete the unused file, export or dependency, or use it. Code used where knip cannot see it is declared in the knip configuration (owner review); the tags `@public`, `@beta` and `@alias` in a comment (a block comment, or a line comment on a line of its own), and tracked files that `.gitignore` excludes, fail the gate. |
|
|
222
|
-
|
|
|
317
|
+
| An upgrade reports more violations | If the repository already has `oxlint-suppressions.json`, run `oxlint --suppress-all` on an otherwise clean branch and commit the additional suppressions for existing files with the upgrade. Ratchet allows existing rule totals to grow only in that change. A repository without a baseline fixes the violations in the upgrade change. |
|
|
223
318
|
| Upgrading od-harness turns a rule off | Run `oxlint --prune-suppressions` and delete the disable comments that became unused, in the upgrade change. |
|
|
224
319
|
| Turning on React Compiler | Extend `react-compiler` after `base` in the same change. Fix what it reports, or, in a repository that has `oxlint-suppressions.json`, baseline it there (`oxlint --suppress-all` on an otherwise clean branch); `ratchet` accepts the new rule IDs because this `.oxlintrc.json` change turns them on (it compares the effective configurations; an unrelated edit to `.oxlintrc.json` admits nothing). |
|
|
320
|
+
| Turning on type-aware linting | Install the pinned backend and extend `type-aware` after `base`. Fix the findings or add the newly enabled rules to an existing baseline in the same change. [Type-aware linting](#type-aware-linting) |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Set up the agent harness
|
|
2
|
+
|
|
3
|
+
Pin `@opendesignai/harness` to an exact registry version in the repository, commit the npm or pnpm lockfile, and install the dependencies with `npm ci` or `pnpm install --frozen-lockfile`. Run `od-harness init` from the repository root through `npm exec -- od-harness init` or `pnpm exec od-harness init`.
|
|
4
|
+
|
|
5
|
+
Declare the dependency as `@opendesignai/harness` in `package.json` so the launchers and `doctor` can find the installation.
|
|
6
|
+
|
|
7
|
+
Review and commit `.claude/settings.json`, `.codex/hooks.json`, `.codex/rules/od-harness.rules`, `.agents/hooks.json`, `CLAUDE.md`, and `.gitattributes`. Keep shared instructions in `AGENTS.md`, which the generated `CLAUDE.md` imports. `init` merges Claude Code hooks and deny rules with existing settings. It regenerates the other agents' hook files and the harness rules file. Put repository-specific Codex rules in a separate `.rules` file.
|
|
8
|
+
|
|
9
|
+
Give each generated path an owner in CODEOWNERS. `od-harness init --check` checks the generated configuration, the last matching CODEOWNERS rule for each generated file, and the harness pin and registry resolution. It reads files without writing them.
|
|
10
|
+
|
|
11
|
+
If either command reports `disableAllHooks`, remove the setting from `.claude/settings.json` to enable the Claude Code hooks.
|
|
12
|
+
|
|
13
|
+
## Trust each checkout
|
|
14
|
+
|
|
15
|
+
- **Claude Code.** Start `claude` from the repository root and accept the workspace trust prompt after reviewing the repository. Claude Code loads the committed `.claude/settings.json` from the launch directory, so starting in a subdirectory leaves the project hooks and deny rules inactive.
|
|
16
|
+
- **Codex.** Start `codex` in the checkout and trust the project. Open `/hooks`, review each repository hook, and trust it. If a hook definition changes or you create a new clone, recheck trust with `od-harness doctor` and review any pending entries in `/hooks`.
|
|
17
|
+
- **Antigravity CLI.** Start `agy` in the workspace and approve folder trust when prompted. Use `/hooks` to check that the `od-harness` hooks from `.agents/hooks.json` are active.
|
|
18
|
+
|
|
19
|
+
`od-harness doctor` checks the package under the repository's `node_modules` against the declared version. It reads project configuration and hook trust from the local Codex app-server. It starts no agent session and changes no trust settings.
|
|
20
|
+
|
|
21
|
+
The repository's CI gates determine merge eligibility. Keep root `AGENTS.md` within 12,288 bytes, each instruction file within 24,000 bytes, and each instruction chain within 28,672 bytes.
|
package/docs/agents.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Agent instructions
|
|
2
|
+
|
|
3
|
+
Run these commands from a Git working tree. Paths in configuration and findings are relative to the repository root.
|
|
4
|
+
|
|
5
|
+
| Command | What it does |
|
|
6
|
+
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
7
|
+
| `od-harness agents sync` | Generates the managed block in the root `AGENTS.md`, routes to nested `AGENTS.md` files, and adjacent `CLAUDE.md` stubs. Move handwritten Claude instructions to the adjacent `AGENTS.md` before replacing the corresponding `CLAUDE.md` with `@AGENTS.md`. |
|
|
8
|
+
| `od-harness agents sync --check` | Reports missing or changed generated content and leaves files untouched. The managed block hash and its 2,048 B limit use LF line endings on every platform. |
|
|
9
|
+
| `od-harness agents docs [--json]` | Checks repository paths, package scripts, `od/*` rule IDs, Markdown links and file imports in `AGENTS.md`, `CLAUDE.md`, and `SKILL.md` under `.agents/skills/` and `.claude/skills/`. It skips fenced examples and the managed block in the root `AGENTS.md`. |
|
|
10
|
+
| `od-harness agents size [--json]` | Checks the three instruction budgets below. |
|
|
11
|
+
|
|
12
|
+
`agents docs` and `agents size` return 0 on success, 1 when they report findings and 2 for usage or environment errors. Both accept `--format text|json|github` and annotate findings automatically in GitHub Actions in the default text format. [CLI diagnostics](diagnostics.md)
|
|
13
|
+
|
|
14
|
+
The existing `--json` spelling prints a Finding array on stdout, including `[]` on success. Every finding includes `file`, `line`, `kind`, `target`, `message`, and `fix`. Size findings also include `bytes` and `limit`. Select `--format json` for the shared report object. Use either `--json` or `--format`.
|
|
15
|
+
|
|
16
|
+
Both checks scan `AGENTS.md` and `CLAUDE.md` at any depth and `SKILL.md` in skill directories under `.agents/skills/` and `.claude/skills/`.
|
|
17
|
+
|
|
18
|
+
## Configuration
|
|
19
|
+
|
|
20
|
+
The repository owner reviews these settings in `.harness/config.json`.
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"agents": { "exclude": ["integrations/adapters/**"], "packageManager": "pnpm" },
|
|
25
|
+
"agentsDocs": { "ignore": ["dist/generated-report.md"] }
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- `agents.exclude` accepts repository-relative paths and globs with `*`, `**`, and `?`. Matching files are omitted from routes, stub generation, both check inventories, and import expansion for size. Excluding an `AGENTS.md` also skips generation of its adjacent stub. The managed block is always generated in the root `AGENTS.md`.
|
|
30
|
+
- `agents.packageManager` selects `npm` or `pnpm` for commands in the block. Omit it to use the declaration in `package.json`, then pnpm lockfile or workspace detection, then npm by default.
|
|
31
|
+
- `agentsDocs.ignore` accepts patterns for individual references. Use it for repository-specific references that `agents docs` cannot verify, such as generated artifacts. It has no effect on routing or size.
|
|
32
|
+
- `verify.clones` and `verify.unused` each enable the corresponding instruction in the managed block when set to `true`.
|
|
33
|
+
|
|
34
|
+
## Instruction budgets
|
|
35
|
+
|
|
36
|
+
| Scope | Maximum |
|
|
37
|
+
| ----------------------------------------------------- | -------: |
|
|
38
|
+
| Expanded root `AGENTS.md` | 12,288 B |
|
|
39
|
+
| Each expanded `AGENTS.md`, `CLAUDE.md`, or `SKILL.md` | 24,000 B |
|
|
40
|
+
| Each root-to-leaf chain of expanded `AGENTS.md` files | 28,672 B |
|
|
41
|
+
|
|
42
|
+
Size uses UTF-8 bytes with LF line endings. The check recursively replaces local `@path` imports and `@[label](path)` inlines with their file contents. Imports inside HTML comments also expand and count toward the budgets. A generated `CLAUDE.md` stub takes the expanded size of its adjacent `AGENTS.md`. Missing, excluded, and cyclic targets leave the original reference text in the byte count. `agents docs` reports broken references. Each chain adds the instructions along one directory path. Sibling directories have separate chains.
|
package/docs/comments.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Comment budget
|
|
2
|
+
|
|
3
|
+
Run the standalone check from the repository root.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
od-harness comments --base origin/main
|
|
7
|
+
od-harness comments --base origin/main --format json
|
|
8
|
+
od-harness comments --base origin/main --format github
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The check compares the working tree with the base commit, including committed, staged, unstaged
|
|
12
|
+
and untracked changes. It counts added or edited lines in `.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`,
|
|
13
|
+
`.cjs` and `.css` files. Renames retain their original lines, and deleted lines are ignored.
|
|
14
|
+
|
|
15
|
+
An added line counts as a comment when it contains only comment text. A line with code and a
|
|
16
|
+
trailing comment counts as code. Blank lines, JSDoc, tool markers, license blocks and
|
|
17
|
+
`// fail-open:` comments do not count toward the budget. Test and spec files and common test and
|
|
18
|
+
fixture directories are skipped. `comments.ignore` in `.harness/config.json` can exclude more
|
|
19
|
+
paths using the same Git glob syntax as `clones.ignore`. When `comments.ignore` is omitted,
|
|
20
|
+
the check uses `clones.ignore`.
|
|
21
|
+
|
|
22
|
+
The command emits one notice when the change adds more than 20 counted comment lines and their
|
|
23
|
+
number exceeds 5% of the added code lines. A diff with zero added code lines has no ratio and
|
|
24
|
+
emits no notice. A completed check exits 0 regardless of the result. Usage and environment
|
|
25
|
+
errors exit 2.
|
|
26
|
+
|
|
27
|
+
The command uses the [shared diagnostic formats](diagnostics.md). Text is the default. The
|
|
28
|
+
GitHub format emits a `::notice` workflow command on stderr when the threshold is exceeded.
|
|
29
|
+
JSON returns a `DiagnosticReport` with `addedCodeLines`, `addedCommentLines` and the
|
|
30
|
+
`commentLines` list of repository-relative paths and 1-based line numbers. The budget diagnostic
|
|
31
|
+
has `kind: "comment-budget"` and `severity: "notice"`. A completed check reports `ok: true`,
|
|
32
|
+
including when it emits a notice. Use the listed locations to remove comments that repeat the code,
|
|
33
|
+
narrate steps, label sections or describe the change. Keep one-line explanations of why.
|
|
@@ -37,6 +37,7 @@ Survey (65 hand-picked active repositories, 2026-12-03): 20 use Oxlint as their
|
|
|
37
37
|
4. **No bypass**: `@eslint-community/eslint-plugin-eslint-comments` is loaded as a JS plugin to reject `eslint-disable` and `oxlint-disable` comments for `od/*` and `rules-of-hooks`; unused disable directives are reported.
|
|
38
38
|
5. **No Biome; ESLint is the fallback only.** CI never runs two linters.
|
|
39
39
|
6. Type-aware rules (for example floating promises) stay off. Oxlint's type-aware mode depends on TypeScript 7; revisit once the repositories are on TypeScript 7.
|
|
40
|
+
[ADR 0004](0004-type-aware-rules.md) supersedes the deferral with an opt-in preset.
|
|
40
41
|
|
|
41
42
|
## Consequences
|
|
42
43
|
|
|
@@ -48,12 +49,38 @@ Benefits:
|
|
|
48
49
|
|
|
49
50
|
Costs and follow-ups:
|
|
50
51
|
|
|
51
|
-
- **Upgrade risk
|
|
52
|
+
- **Upgrade risk.** The JS plugin API is outside semver and the bulk suppression flags are undocumented. Before an Oxlint upgrade merges, Oxlint must match ESLint's RuleTester on every rule case (`test/oxlint-conformance.test.ts`). The two linters must also match on the file-and-line multiset of hits for every exported `od/*` rule on opengame and openmotion.
|
|
52
53
|
- **Noise when a baseline is exceeded**: once a file × rule count is exceeded, the whole group is reported (in the evaluation: one new hit, 68 lines). Hooks and local verification must filter by changed lines before showing results to an agent.
|
|
53
54
|
- **Unused disable directives** are not accepted into the ESLint baseline (opengame 39, openmotion 38); check the same for Oxlint and clean them up in the adoption change if needed.
|
|
54
55
|
- **Baselines are keyed by file path**: moving a file resurfaces its debt, so a `baseline move` command is needed before directories move.
|
|
55
56
|
- **`exhaustive-deps` is Oxlint's own implementation**, so counts change (opengame: ESLint 152, Oxlint 165); the differences were not reviewed one by one.
|
|
56
57
|
|
|
58
|
+
### Upgrade risk: full rule comparison
|
|
59
|
+
|
|
60
|
+
Run `pnpm build`, then `node scripts/hit-compare.ts <opengame-snapshot> <openmotion-snapshot>`. Oxlint loads the built plugin through the published `base`, `platform-boundary` and `product` presets. ESLint uses the source plugin and typescript-eslint and takes its rule settings, options and file overrides from the same configuration resolved by `oxlint --print-config`. The consumer configuration supplies the shell and product paths and the storage wrapper exemption. Each rule appears once in the report, with every preset that enables it.
|
|
61
|
+
|
|
62
|
+
Both linters use the trial's archived TypeScript file list, which excludes `*.test.*`, declaration files and the studio i18n directory. The base preset's CJK exemptions still apply to any selected spec files, test helpers and fixtures.
|
|
63
|
+
|
|
64
|
+
ESLint 10.16.0 and Oxlint 1.96.0 matched on all 12 rules in both snapshots:
|
|
65
|
+
|
|
66
|
+
- opengame `85b8351bc97ebb25d78482fc8667654675957cb5` (1,743 files)
|
|
67
|
+
- openmotion `69f15883f73694b7506282e4662cc071b6923b45` (1,857 files)
|
|
68
|
+
|
|
69
|
+
| Rule | Enabling presets | opengame ESLint / Oxlint | openmotion ESLint / Oxlint |
|
|
70
|
+
| ----------------------------- | ------------------------------ | -----------------------: | -------------------------: |
|
|
71
|
+
| `od/no-api-path-literal` | `base` | 329 / 329 | 405 / 405 |
|
|
72
|
+
| `od/no-cjk-literal` | `base` | 1538 / 1538 | 1720 / 1720 |
|
|
73
|
+
| `od/no-constant-flag` | `base` | 1 / 1 | 2 / 2 |
|
|
74
|
+
| `od/no-error-message-match` | `base` | 367 / 367 | 20 / 20 |
|
|
75
|
+
| `od/no-locale-branch` | `base` | 51 / 51 | 71 / 71 |
|
|
76
|
+
| `od/no-process-env` | `base` | 141 / 141 | 57 / 57 |
|
|
77
|
+
| `od/no-product-literal` | `platform-boundary`, `product` | 9 / 9 | 0 / 0 |
|
|
78
|
+
| `od/no-raw-fetch` | `base` | 92 / 92 | 51 / 51 |
|
|
79
|
+
| `od/no-raw-storage` | `base` | 111 / 111 | 119 / 119 |
|
|
80
|
+
| `od/no-shell-imports-product` | `platform-boundary` | 49 / 49 | 15 / 15 |
|
|
81
|
+
| `od/no-swallowed-catch` | `base` | 1179 / 1179 | 1062 / 1062 |
|
|
82
|
+
| `od/no-window-bus` | `base` | 66 / 66 | 54 / 54 |
|
|
83
|
+
|
|
57
84
|
## Review triggers (any one of them reopens running the rules with ESLint)
|
|
58
85
|
|
|
59
86
|
- After an Oxlint upgrade, the rule cases or the hit comparison diverge and cannot be fixed within one release cycle.
|
|
@@ -32,3 +32,42 @@ The diagnostics are the baseline entries (openmotion 4,259, opengame 7,448) plus
|
|
|
32
32
|
- Turning `react-compiler` on later changes `.oxlintrc.json`, so `od-harness ratchet` accepts the new rule IDs in that change. A repository that has `oxlint-suppressions.json` can freeze the existing hits there (`oxlint --suppress-all` on an otherwise clean branch); a repository without it fixes them, because only the adoption change may create a baseline file.
|
|
33
33
|
- This decision covers the eight rules above only. Oxlint 1.96.0's `correctness` category has further React rules in the same area (`react/set-state-in-render`, `react/globals`, `react/error-boundaries`, `react/void-use-memo`); they stay in `base` and report nothing on either snapshot.
|
|
34
34
|
- Versioning (README, "Versioning"): a change that makes a preset report more, such as putting these rules back into `base`, only ships in a minor or major version; a change that only turns rules off, like this one, may ship in a patch version.
|
|
35
|
+
|
|
36
|
+
## Follow-up (2026-12-04)
|
|
37
|
+
|
|
38
|
+
Oxlint 1.79.0 split `react/react-compiler` into individual rules and aligned their categories with the upstream presets. Oxlint 1.96.0 still has 22 of these rules. Twelve are in `correctness` and ten are in other categories, including the compiler's `invariant`, `syntax`, and `todo` diagnostics. [Oxlint 1.79.0 release notes](https://github.com/oxc-project/oxc/releases/tag/oxlint_v1.79.0)
|
|
39
|
+
|
|
40
|
+
The follow-up trial ran the ten rules on openmotion `69f15883f7`, opengame `f1119f03c6`, and od-platform `ed94b40`. The product counts use the same file scope as the original trial.
|
|
41
|
+
|
|
42
|
+
| Rule | Oxlint category | Upstream preset | openmotion | opengame | od-platform | Decision |
|
|
43
|
+
| -------------------------------------- | --------------- | --------------- | ---------: | -------: | ----------: | ------------------------------------------------------------------------------------------ |
|
|
44
|
+
| `react/unsupported-syntax` | restriction | recommended | 0 | 0 | 0 | Enable in `react-compiler`. |
|
|
45
|
+
| `react/capitalized-calls` | suspicious | off | 0 | 0 | 0 | Leave optional for consumers. |
|
|
46
|
+
| `react/no-deriving-state-in-effects` | perf | off | 1 | 2 | 0 | Omit. `set-state-in-effect` reported the same three lines. |
|
|
47
|
+
| `react/exhaustive-effect-dependencies` | suspicious | off | 279 | 340 | 0 | Set to `off` in `base`. All ten sampled reports were false positives. |
|
|
48
|
+
| `react/hooks` | suspicious | off | 18 | 18 | 0 | Set to `off` in `base`. In each repo, `rules-of-hooks` covered all three real findings. |
|
|
49
|
+
| `react/memo-dependencies` | suspicious | off | 59 | 59 | 0 | Set to `off` in `base`. All ten sampled reports were false positives. |
|
|
50
|
+
| `react/rule-suppression` | restriction | off | 0 | 0 | 0 | Omit. Oxlint always enables hooks and memo validation, so the compiler skips suppressions. |
|
|
51
|
+
| `react/invariant` | restriction | off | 4 | 1 | 0 | Omit. Reports internal compiler failures. |
|
|
52
|
+
| `react/syntax` | restriction | off | 0 | 0 | 0 | Omit. Reports compiler syntax diagnostics. |
|
|
53
|
+
| `react/todo` | restriction | off | 271 | 335 | 0 | Omit. Reports compiler features that have yet to be implemented. |
|
|
54
|
+
|
|
55
|
+
`react/unsupported-syntax` is the only upstream `recommended` rule in this group. It catches constructs such as `eval` in a component that prevent the compiler from analyzing it. Adding it as an error to `react-compiler` requires zero fixes in od-platform. On the product snapshots, the compiler rules would still add 681 baseline entries in openmotion and 890 in opengame when those repositories adopt the preset. [React rule documentation](https://react.dev/reference/eslint-plugin-react-hooks/lints/unsupported-syntax)
|
|
56
|
+
|
|
57
|
+
od-platform enables `categories.suspicious: "error"`, which otherwise activates four rules in this group. An explicit rule setting in an extended preset takes precedence over a consumer's category setting. `base` sets `exhaustive-effect-dependencies`, `hooks`, and `memo-dependencies` to `off`. The effect rule often reports dependencies intentionally used to rerun effects. The hooks rule reported 15 false positives in each product repository, including 13 Zustand `getState()` calls. `capitalized-calls` still runs with `suspicious`.
|
|
58
|
+
|
|
59
|
+
### Optional `react/capitalized-calls`
|
|
60
|
+
|
|
61
|
+
Calling a component as `Child()` during render bypasses React's component handling. This rule flags the call so it can be rendered as `<Child />`. The trial found zero reports across the three repositories and confirmed the rule on a fixture. Upstream defaults it to `off`. To opt in, add the following rule to the consumer's `.oxlintrc.json` alongside its existing rules.
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"rules": {
|
|
66
|
+
"react/capitalized-calls": "error"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The `allow` and `allowPattern` options match only the function names in direct calls. Use `allow` for exact names and `allowPattern` for a naming convention. For example, replace `"error"` with `["error", { "allow": ["CreateSchema"], "allowPattern": "Event$" }]`. [Oxlint rule options](https://github.com/oxc-project/oxc/blob/oxlint_v1.96.0/crates/oxc_linter/src/rules/react/capitalized_calls.rs)
|
|
72
|
+
|
|
73
|
+
In Oxlint 1.96.0, namespace member calls such as `Ns.CreateSchema()` still trigger the rule with these options. Set `react/capitalized-calls` to `"off"` for the affected files in `overrides`, or keep the rule off across the repository.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# 0004: Offer an opt-in type-aware preset
|
|
2
|
+
|
|
3
|
+
- Status: accepted (2026-12-05)
|
|
4
|
+
- Evidence: the 2026-12-04 trial for od-harness #4, using Oxlint 1.96.0, openmotion `69f15883f7`, opengame `f1119f03c6` and od-platform `ed94b40ee4`
|
|
5
|
+
|
|
6
|
+
## Decision
|
|
7
|
+
|
|
8
|
+
Repositories can extend `presets/type-aware.json` after `base`. It sets `options.typeAware: true` and enables three rules as errors.
|
|
9
|
+
|
|
10
|
+
- `typescript/no-floating-promises`
|
|
11
|
+
- `typescript/no-misused-promises`
|
|
12
|
+
- `typescript/await-thenable`
|
|
13
|
+
|
|
14
|
+
This supersedes the deferral in item 6 of [ADR 0001](0001-oxlint.md#decision). Opting in requires a backend dependency and explicit TypeScript project settings, so the base preset keeps type-aware linting off.
|
|
15
|
+
|
|
16
|
+
Use `oxlint-tsgolint` 7.0.2009, the stable backend based on TypeScript 7.0.2. The trial also ran `tsrs` 7.1.0-beta.tsrs9, which is based on the TypeScript 7.1 beta. Its diagnostics matched at every location and its warm full-repository runs were 22–36% faster. The choice prioritizes the stable backend. The harness declares an exact optional peer and installs it for its integration test. Each Oxlint upgrade PR also upgrades the tsgolint pin because Oxlint's minimum backend version can change.
|
|
17
|
+
|
|
18
|
+
Type-aware mode activates rules from enabled categories. With only the three errors declared, the base configuration produced findings from nine more rules, adding 412 diagnostics in openmotion and 428 in opengame. od-platform gained 54–60 extra findings depending on whether dependencies were built. It adopts without a baseline. The preset explicitly disables all 59 other type-aware rules, and the test compares the preset with the pinned Oxlint's `--rules --format json` output.
|
|
19
|
+
|
|
20
|
+
Setting `typeAware` in the preset makes plain lint, file hooks and `--suppress-all` use the same rules. The trial found that a later run without the CLI flag rejected type-aware suppressions as stale when only `--type-aware` enabled the rules. Oxlint reports a related failure for inline disable directives. [Upstream issue #26281](https://github.com/oxc-project/oxc/issues/26281)
|
|
21
|
+
|
|
22
|
+
## Findings
|
|
23
|
+
|
|
24
|
+
The first two count columns below use TypeScript 7's implicit `strict: true` for the backend. The last two preserve the products' backend `strict: false` and disable `checksConditionals` there.
|
|
25
|
+
|
|
26
|
+
| Rule | openmotion implicit | opengame implicit | openmotion recommended | opengame recommended |
|
|
27
|
+
| ---------------------- | ------------------: | ----------------: | ---------------------: | -------------------: |
|
|
28
|
+
| `no-floating-promises` | 64 | 60 | 64 | 60 |
|
|
29
|
+
| `no-misused-promises` | 116 | 127 | 113 | 127 |
|
|
30
|
+
| `await-thenable` | 4 | 9 | 3 | 9 |
|
|
31
|
+
| Total | 184 | 196 | 180 | 196 |
|
|
32
|
+
|
|
33
|
+
Of 53 sampled diagnostics from the implicit configuration, seven identified bugs at two code sites. One ignored a fullscreen request that could reject. The other typed a callback as returning `void` even though it returned a promise, producing six findings across both products. One diagnostic out of 53 was a false positive, five were inconclusive and 40 were valid findings with no observed runtime impact.
|
|
34
|
+
|
|
35
|
+
Single-file lint on the median openmotion file went from 0.10 s to 0.35 s, within the 1 s limit from ADR 0001. The observed single-file runs with type-aware lint took 0.31–0.36 s. The trial estimated an extra 5–10 s per `gates.yml` run for installation and lint on a GitHub-hosted runner. It measured local timings and estimated the runner cost from those timings.
|
|
36
|
+
|
|
37
|
+
## Adoption prerequisites
|
|
38
|
+
|
|
39
|
+
- Resolve workspace types before lint. Prefer `paths` to the source or an `exports` condition named `source` with `customConditions`. A caller can also arrange for build to run first. The od-platform trial showed that lint could silently miss unhandled promises across packages when declarations in `dist` were absent.
|
|
40
|
+
- Give linted files a tsconfig that specifies their intended TypeScript 7 settings, including `rootDir`, `types` and `strict`. Files that use an inferred project can produce different diagnostics in single-file hooks and full runs.
|
|
41
|
+
- Use a consumer override for `no-misused-promises` with `checksConditionals: false` in backends that still set `strict: false`. Keep `checksVoidReturn.attributes` enabled by default. Generate any allowed baseline with `--suppress-all` once the tsconfigs, overrides and type resolution match CI.
|
|
42
|
+
|
|
43
|
+
Installation, a sample override and the build-first workflow configuration are in the [adoption guide](../adopting.md#type-aware-linting).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# 0005: Check test weakening and TypeScript escapes with separate presets
|
|
2
|
+
|
|
3
|
+
- Status: accepted (2026-12-05)
|
|
4
|
+
- Evidence: harness-bench 1F at `583c3a3465cfd3d45905b94994528d1f9a1903db` and read-only lint runs with Oxlint 1.96.0 on the snapshots below.
|
|
5
|
+
|
|
6
|
+
## Decision
|
|
7
|
+
|
|
8
|
+
1. Enable `typescript/ban-ts-comment` as an error in `base` with Oxlint's default options. It rejects `@ts-ignore` and `@ts-nocheck`, requires a description for `@ts-expect-error`, and allows `@ts-check`. The owner chose to allow rule-specific lint disables for this rule under the existing disable policy.
|
|
9
|
+
2. Offer `testing` as an opt-in preset with `vitest/no-disabled-tests` and `vitest/no-focused-tests` as errors. The owner kept `base` framework-agnostic. Loading Vitest with `correctness` would enable 17 rules by default. Beyond the two selected rules and `expect-expect`, the other 14 produced 6,185 diagnostics in opengame, 6,163 in openmotion, and zero in od-platform. The preset explicitly disables those 14 rules and `expect-expect`. Consumers can enable their own Vitest rules in root `rules` or a later `extends` entry.
|
|
10
|
+
3. Offer `strict-types` as a separate opt-in preset with `typescript/no-explicit-any` as an error. The owner chose separate adoption because the rollout costs differ. Explicit `any` is widespread in the two product snapshots and includes deliberate invalid inputs and simplified mocks in tests.
|
|
11
|
+
|
|
12
|
+
Assertion policy belongs to the consumer. With its default options, `vitest/expect-expect` reported 51 diagnostics each in opengame and openmotion and zero in od-platform. In the sample of ten findings per product, nine in opengame and eight in openmotion came from helpers that already performed assertions. Each sample also included a render smoke test. Consumers can configure the assertion helpers they rely on when they choose to enable the rule.
|
|
13
|
+
|
|
14
|
+
## Verified impact
|
|
15
|
+
|
|
16
|
+
| Snapshot | Revision | Linted files | Added by `base` | Added by `testing` | Added by `strict-types` |
|
|
17
|
+
| ----------- | ------------------------------------------ | -----------: | --------------: | -----------------: | ----------------------: |
|
|
18
|
+
| opengame | `85b8351bc97ebb25d78482fc8667654675957cb5` | 5,033 | 0 | 0 | 1,691 in 209 files |
|
|
19
|
+
| openmotion | `69f15883f73694b7506282e4662cc071b6923b45` | 5,185 | 0 | 0 | 203 in 66 files |
|
|
20
|
+
| od-platform | `ed94b40ee45779fc9fa44c873d4666d77b6f0894` | 93 | 0 | 0 | 0 |
|
|
21
|
+
|
|
22
|
+
The counts compare each configuration with the previous `base` on the same source revision using `oxlint -c <config> --disable-nested-config --format json .` from the snapshot root. Each optional preset was measured with `base`. In each product, nine previously unused disable directives started matching `typescript/no-explicit-any`. Those nine reports drop out of the full output, so the net increases are 1,682 and 194. The openmotion snapshot has a duplicate declaration in `studio/src/motion/SettingsCenter.test.tsx` in all runs, so counts reflect the files and rules Oxlint could analyze.
|
|
23
|
+
|
|
24
|
+
The harness-bench fixture confirms that `base` reports TW-04 and TW-05, `testing` adds TW-01 and TW-02, and `strict-types` adds TW-06. The assertion probe TW-03 and the controls TW-07 and TW-08 pass in all four configurations. Effective-config tests verify the two Vitest errors and the precedence of root `rules` and `extends`. [Adopting the presets](../adopting.md#testing-and-strict-types)
|
|
25
|
+
|
|
26
|
+
## Release
|
|
27
|
+
|
|
28
|
+
Ship this in a minor release because `base` can report new errors. [Versioning policy](../../README.md#versioning)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# CLI diagnostics
|
|
2
|
+
|
|
3
|
+
`lint-scope`, `size`, `ratchet`, `clones`, `unused`, [`comments`](comments.md), `agents docs`, `agents size`, and [`verify`](verify.md) accept `--format text|json|github`.
|
|
4
|
+
|
|
5
|
+
| Format | Output |
|
|
6
|
+
| ---------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
7
|
+
| `text` (default) | Prints the usual gate summary and details. When `GITHUB_ACTIONS=true`, it also prints file annotations to stderr. |
|
|
8
|
+
| `json` | Prints one `DiagnosticReport` object on stdout, including in GitHub Actions. |
|
|
9
|
+
| `github` | Prints `::error` or `::notice` annotations on stderr and a short gate status. This format also works outside Actions. |
|
|
10
|
+
|
|
11
|
+
Exit code 0 means the check passed, was skipped or emitted only advisory notices. Exit code 1 means the check reported blocking findings. Exit code 2 reports a usage or environment error on stderr and produces no JSON report.
|
|
12
|
+
|
|
13
|
+
## JSON report
|
|
14
|
+
|
|
15
|
+
`ok` and `diagnostics` are always present. A passing or skipped check has `ok: true`. Its `diagnostics` array is empty or contains advisory diagnostics with `severity: "notice"`. A report can also include a `summary` string and a `notes` array of strings.
|
|
16
|
+
|
|
17
|
+
Every diagnostic has a repository-relative `file` (empty for repository-wide diagnostics), a one-based `line`, a `kind` identifier, and a human-readable `message`. The line defaults to 1 when the check has no more precise location. Optional `rule`, `fix`, `exemption`, and `docs` fields are omitted when unavailable. Use the command and `kind` to group findings. `rule`, when present, identifies the underlying lint rule.
|
|
18
|
+
|
|
19
|
+
For example, `od-harness size --format json` can produce this report:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"ok": false,
|
|
24
|
+
"diagnostics": [
|
|
25
|
+
{
|
|
26
|
+
"file": "src/editor.ts",
|
|
27
|
+
"line": 801,
|
|
28
|
+
"kind": "size-limit",
|
|
29
|
+
"message": "805 lines, over the 800-line budget for source files.",
|
|
30
|
+
"fix": "split it into smaller modules by responsibility (keep each under 800 lines). New files cannot be added to the baseline; only files that were over budget when the repository adopted od-harness are frozen there.",
|
|
31
|
+
"docs": "https://github.com/nexu-io/od-harness/blob/main/docs/size.md"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"summary": "1 files checked"
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`agents docs --json` and `agents size --json` print the legacy findings array. Use `--format json` for the shared report object. The `--json` and `--format` flags are mutually exclusive.
|
|
39
|
+
|
|
40
|
+
## Use the reporter in repository scripts
|
|
41
|
+
|
|
42
|
+
Import `reportDiagnostic` from `@opendesignai/harness/report`. The subpath also exports the TypeScript types `Diagnostic`, `DiagnosticReport`, `VerifyReport` and `VerifyCheck`.
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
import { reportDiagnostic } from "@opendesignai/harness/report";
|
|
46
|
+
|
|
47
|
+
reportDiagnostic({
|
|
48
|
+
file: "src/editor.ts",
|
|
49
|
+
line: 42,
|
|
50
|
+
kind: "missing-entry",
|
|
51
|
+
message: "The editor is missing from the registry.",
|
|
52
|
+
fix: "Register it in src/registry.ts.",
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Supply `file`, `kind`, and `message`. The `kind` and `rule` fields appear only in JSON output, where consumers can use them to group findings. `reportDiagnostic` writes the file and `Violation / Fix / Exemption / Docs` text to stderr and adds an escaped annotation in GitHub Actions. Set `severity: "notice"` to print `Notice` and emit a `::notice` annotation. Empty `fix`, `exemption`, and `docs` strings are treated as omitted.
|
|
57
|
+
|
|
58
|
+
Annotations use line 1 if `line` is omitted or is anything other than a positive integer. Pass `{ format: "github" }` as the second argument to emit just the annotation in any environment. The caller controls the script's exit code.
|