@opendesignai/harness 0.3.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 +16 -12
- package/dist/cli.mjs +55 -27
- package/dist/config.d.mts +2 -0
- package/dist/config.mjs +2 -0
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.mjs +1 -1
- package/docs/adopting.md +24 -4
- package/docs/decisions/0005-test-weakening-rules.md +28 -0
- package/docs/ratchet.md +16 -19
- package/package.json +3 -1
- package/presets/rules/base.json +1 -0
- package/presets/strict-types.json +5 -0
- package/presets/testing.json +22 -0
package/README.md
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
Machine-checked rules for OpenDesign repositories (od-platform, openmotion, opengame), kept in one place and synced to every repository:
|
|
9
9
|
|
|
10
10
|
- **`od/*` lint rules** written in ESLint plugin format and run by [Oxlint](https://oxc.rs/docs/guide/usage/linter) through `jsPlugins` ([decision record](docs/decisions/0001-oxlint.md));
|
|
11
|
-
- **presets** (`base`, `platform-boundary`, `product`, and the opt-in `react-compiler` and `type-aware`) that a repository extends from its `.oxlintrc.json`;
|
|
11
|
+
- **presets** (`base`, `platform-boundary`, `product`, and the opt-in `react-compiler`, `testing`, `strict-types`, and `type-aware`) that a repository extends from its `.oxlintrc.json`;
|
|
12
12
|
- **`od-harness` CLI**: a lint scope check (`lint-scope`), a file size budget (`size`), a baseline ratchet (`ratchet`), incremental duplication and unused-code checks (`clones` with jscpd, `unused` with knip), and `baseline move` for files that move;
|
|
13
13
|
- **a reusable `harness-gates` workflow** (`.github/workflows/gates.yml`) that runs a repository's gate commands in CI.
|
|
14
14
|
|
|
15
|
-
Existing debt is frozen in baselines (`oxlint-suppressions.json`, `.harness/size-baseline.json`); new violations fail, and the
|
|
15
|
+
Existing debt is frozen in baselines (`oxlint-suppressions.json`, `.harness/size-baseline.json`); new violations fail, and baseline growth is limited to the [lint rule changes described in Versioning](#versioning). Duplicated code and unused files, exports and dependencies need no baseline: `clones` and `unused` compare a change with its base commit and fail on what it adds. Error messages are written for coding agents: what was violated, the correct way, and the legitimate exemption, plus a link to the rule's page.
|
|
16
16
|
|
|
17
|
-
Status: alpha (0.
|
|
17
|
+
Status: alpha (0.4.0-alpha.0). Distributed through the public npm registry as `@opendesignai/harness` under the `alpha` dist-tag (npm organization `opendesignai`). 0.1.0-alpha.0 was published by hand; later versions are published by CI through npm trusted publishing (see [Versioning](#versioning)). How a repository adopts it: [docs/adopting.md](docs/adopting.md).
|
|
18
18
|
|
|
19
19
|
## Rules
|
|
20
20
|
|
|
@@ -38,18 +38,22 @@ Every rule is tested with ESLint's `RuleTester` and with the same cases run thro
|
|
|
38
38
|
|
|
39
39
|
## Presets
|
|
40
40
|
|
|
41
|
-
| Preset | Contents
|
|
42
|
-
| -------------------------------- |
|
|
43
|
-
| `presets/base.json` | the
|
|
44
|
-
| `presets/platform-boundary.json` | `od/no-product-literal`, `od/no-shell-imports-product` (inactive until the repository sets `shell` and `product`)
|
|
45
|
-
| `presets/product.json` | `od/no-product-literal`; product-package rules (published-imports-only, manifest checks) arrive with stage 2
|
|
46
|
-
| `presets/react-compiler.json` | opt-in: nine React Compiler-derived rules (`react/refs`, `react/set-state-in-effect`, `react/immutability`, `react/preserve-manual-memoization`, `react/purity`, `react/use-memo`, `react/incompatible-library`, `react/static-components`, `react/unsupported-syntax`) as errors; extend it after `base` ([ADR 0002](docs/decisions/0002-react-compiler-rules.md))
|
|
47
|
-
| `presets/
|
|
41
|
+
| Preset | Contents |
|
|
42
|
+
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| `presets/base.json` | the 11 base `od/*` rules (`od/no-cjk-literal` off for tests and fixtures); Oxlint's `correctness` category (eslint, typescript, unicorn, oxc, react plugins); `typescript/ban-ts-comment` (Oxlint defaults); `react/rules-of-hooks`; `react/exhaustive-deps`; `eslint-comments/no-restricted-disable` forbidding inline disables of `od/*`, `eslint-comments/*`, `rules-of-hooks` and `no-abusive-eslint-disable` (bare names cover any `<prefix>/` form), and disable comments that name no rule (through od-harness's wrapper of the eslint-comments plugin, see [adopting](docs/adopting.md#3-clean-up-what-cannot-be-baselined)); `unicorn/no-abusive-eslint-disable` as a native second guard against disable comments that name no rule; unused disable directives reported as errors; warnings fail the run (`denyWarnings`); the eight compiler correctness rules in `react-compiler` and three noisy `suspicious` compiler rules (`react/exhaustive-effect-dependencies`, `react/hooks`, and `react/memo-dependencies`) turned off |
|
|
44
|
+
| `presets/platform-boundary.json` | `od/no-product-literal`, `od/no-shell-imports-product` (inactive until the repository sets `shell` and `product`) |
|
|
45
|
+
| `presets/product.json` | `od/no-product-literal`; product-package rules (published-imports-only, manifest checks) arrive with stage 2 |
|
|
46
|
+
| `presets/react-compiler.json` | opt-in: nine React Compiler-derived rules (`react/refs`, `react/set-state-in-effect`, `react/immutability`, `react/preserve-manual-memoization`, `react/purity`, `react/use-memo`, `react/incompatible-library`, `react/static-components`, `react/unsupported-syntax`) as errors; extend it after `base` ([ADR 0002](docs/decisions/0002-react-compiler-rules.md)) |
|
|
47
|
+
| `presets/testing.json` | opt-in for Vitest: `vitest/no-focused-tests` and `vitest/no-disabled-tests` as errors. Extend after `base` and before presets that enable other Vitest rules. [Adoption guide](docs/adopting.md#testing-and-strict-types) |
|
|
48
|
+
| `presets/strict-types.json` | opt-in: `typescript/no-explicit-any` as an error. Extend after `base`. [Adoption guide](docs/adopting.md#testing-and-strict-types) |
|
|
49
|
+
| `presets/type-aware.json` | opt-in: `typescript/no-floating-promises`, `typescript/no-misused-promises`, and `typescript/await-thenable` as errors with `oxlint-tsgolint`; extend it after `base` ([adoption guide](docs/adopting.md#type-aware-linting)) |
|
|
48
50
|
|
|
49
51
|
Presets are fragments: extend `base` plus the one that matches the repository. A repository that uses React Compiler also extends `react-compiler`, after `base` (od-platform from the start; a product repository in the change that turns React Compiler on). See [ADR 0002](docs/decisions/0002-react-compiler-rules.md).
|
|
50
52
|
|
|
51
53
|
To opt into type-aware linting, install the pinned `oxlint-tsgolint` backend and extend `type-aware` after `base`. [Adoption guide](docs/adopting.md#type-aware-linting)
|
|
52
54
|
|
|
55
|
+
Extend `testing` to catch skipped or focused Vitest tests and `strict-types` to catch explicit TypeScript `any`. [Adoption guide](docs/adopting.md#testing-and-strict-types)
|
|
56
|
+
|
|
53
57
|
With `categories.suspicious: "error"`, `base` keeps `react/exhaustive-effect-dependencies`, `react/hooks`, and `react/memo-dependencies` off. The category still enables `react/capitalized-calls`. See [optional `react/capitalized-calls`](docs/decisions/0002-react-compiler-rules.md#optional-reactcapitalized-calls) to enable it directly or configure exceptions.
|
|
54
58
|
|
|
55
59
|
> **`od/no-shell-imports-product` is silent until it is configured.** `platform-boundary` turns it on, but it only reports once the repository's `.oxlintrc.json` sets both `shell` and `product` (as below). Without them it checks nothing and says nothing, so set them in the adoption change and check that a known shell-to-product import is reported.
|
|
@@ -80,7 +84,7 @@ Oxlint resolves `extends` as file paths, so the `./node_modules/…` prefix is r
|
|
|
80
84
|
```text
|
|
81
85
|
od-harness lint-scope reject alternate lint configs and ignored tracked files
|
|
82
86
|
od-harness size [--update | --init] file size budget (800 lines; tests and CSS 1,500)
|
|
83
|
-
od-harness ratchet --base <ref>
|
|
87
|
+
od-harness ratchet --base <ref> check baseline changes relative to <ref>
|
|
84
88
|
--merge-base <ref> … relative to `git merge-base HEAD <ref>` (local runs)
|
|
85
89
|
od-harness clones --base <ref> no duplicated code that <ref> does not have (jscpd)
|
|
86
90
|
od-harness unused --base <ref> no unused files, exports, dependencies that <ref> does not have (knip)
|
|
@@ -129,7 +133,7 @@ This repository's own workflows are linted by `.github/workflows/workflow-lint.y
|
|
|
129
133
|
## Versioning
|
|
130
134
|
|
|
131
135
|
- New rules, and changes that make a rule or a preset report more (for example putting the React Compiler rules back into `base`), only ship in minor or major versions (`0.x`: the second number). Patch versions fix false positives, messages and tooling, and may turn rules off. A patch that turns a rule off makes `oxlint` fail in a repository that baselined the rule ("There are suppressions that do not occur anymore") and turns that rule's disable comments into unused directives: the upgrade change runs `oxlint --prune-suppressions` and deletes those comments.
|
|
132
|
-
-
|
|
136
|
+
- When an upgrade adds a rule or makes an existing rule report more, commit the suppressions for existing files with the upgrade (`oxlint --suppress-all` on an otherwise clean branch). A repository without `oxlint-suppressions.json` fixes the new violations because only the adoption change may create a baseline file. `od-harness ratchet` allows existing rule totals to grow only in an owner-reviewed `@opendesignai/harness` upgrade. A change to `.oxlintrc.json` alone can admit only new rule IDs that the owner-reviewed change turns on. See [the ratchet policy](docs/ratchet.md#why-a-config-or-version-change-admits-new-rule-ids).
|
|
133
137
|
- The public API includes the package's export `.` (`dist/plugin.mjs`: the `od` plugin as the default export, `VERSION`, and the types `Plugin`, `PluginRule`, `RuleContextLike` and `RuleMeta`), `./config` (`OxlintConfig` and `presets`), `./hook`, `./report`, `presets/*`, and the `od-harness` command. Other files in `dist/` are internal: the presets load `dist/eslint-comments.mjs` by path, and it exports the plugin and nothing else. Changes after 0.2.0-alpha.0: `dist/eslint-comments.mjs` no longer exports `clampLoc`, `parseRustDirective` and `wrapRule`, and the package no longer ships the declaration files `dist/cli.d.mts` (which was empty) and `dist/eslint-comments.d.mts`. The export `.` is unchanged. The build checks the packed package with publint and attw (`esm-only` profile) and fails on any warning.
|
|
134
138
|
- Oxlint and the optional peer `oxlint-tsgolint` are pinned exactly. Every PR that upgrades Oxlint must also upgrade `oxlint-tsgolint`. An Oxlint upgrade is its own release, after the conformance suite, `pnpm smoke` and `pnpm hit-compare` agree. [ADR 0001](docs/decisions/0001-oxlint.md)
|
|
135
139
|
- knip and jscpd are `dependencies`, pinned exactly: only od-harness runs them, so their versions are part of the harness release ([why](docs/unused.md#why-knip-is-a-dependency-of-od-harness)). So is oxc-parser, at the version knip depends on: `unused` reads comments with it.
|
package/dist/cli.mjs
CHANGED
|
@@ -6,10 +6,11 @@ import path from "node:path";
|
|
|
6
6
|
import { Visitor, parseSync } from "oxc-parser";
|
|
7
7
|
import { closeSync, constants, copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { createHash, randomUUID } from "node:crypto";
|
|
9
|
-
import { LineCounter, isMap, isScalar, parseAllDocuments, parseDocument } from "yaml";
|
|
9
|
+
import { LineCounter, isMap, isScalar, parse, parseAllDocuments, parseDocument } from "yaml";
|
|
10
10
|
import { tmpdir } from "node:os";
|
|
11
11
|
import { runJscpd } from "jscpd";
|
|
12
12
|
import { createInterface } from "node:readline";
|
|
13
|
+
import semver from "semver";
|
|
13
14
|
import { createRequire } from "node:module";
|
|
14
15
|
// src/plugin/meta.ts
|
|
15
16
|
const DOCS_BASE = "https://github.com/nexu-io/od-harness/blob/main/docs/rules";
|
|
@@ -1650,7 +1651,7 @@ const noWindowBus = {
|
|
|
1650
1651
|
};
|
|
1651
1652
|
// src/plugin/version.ts
|
|
1652
1653
|
/** Kept in sync with package.json by test/plugin.test.ts. */
|
|
1653
|
-
const VERSION = "0.
|
|
1654
|
+
const VERSION = "0.4.0-alpha.0";
|
|
1654
1655
|
// src/plugin/index.ts
|
|
1655
1656
|
const plugin = {
|
|
1656
1657
|
meta: {
|
|
@@ -3911,7 +3912,7 @@ function runComments(cwd, ref, format) {
|
|
|
3911
3912
|
}
|
|
3912
3913
|
// src/cli/agent-project.ts
|
|
3913
3914
|
const CODEX_HOOKS = ".codex/hooks.json";
|
|
3914
|
-
const HARNESS_PACKAGE
|
|
3915
|
+
const HARNESS_PACKAGE = "@opendesignai/harness";
|
|
3915
3916
|
function record$2(value) {
|
|
3916
3917
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
3917
3918
|
}
|
|
@@ -4084,8 +4085,8 @@ const DEPENDENCY_SECTIONS = [
|
|
|
4084
4085
|
"optionalDependencies"
|
|
4085
4086
|
];
|
|
4086
4087
|
const EXACT_VERSION = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
4087
|
-
const ALIAS = `npm:${HARNESS_PACKAGE
|
|
4088
|
-
const REGISTRY = `https://registry.npmjs.org/${HARNESS_PACKAGE
|
|
4088
|
+
const ALIAS = `npm:${HARNESS_PACKAGE}@`;
|
|
4089
|
+
const REGISTRY = `https://registry.npmjs.org/${HARNESS_PACKAGE}/-/`;
|
|
4089
4090
|
const LOCAL_DEPENDENCY = /^(?:link|file|portal):/;
|
|
4090
4091
|
function yamlDocuments(root, file) {
|
|
4091
4092
|
const content = readProjectFile(root, file);
|
|
@@ -4126,7 +4127,7 @@ function readManifest(root) {
|
|
|
4126
4127
|
}
|
|
4127
4128
|
function declaredHarnessVersions(root) {
|
|
4128
4129
|
const [workspace] = yamlDocuments(root, "pnpm-workspace.yaml");
|
|
4129
|
-
return dependencyEntries(readManifest(root)).filter(([name]) => name === HARNESS_PACKAGE
|
|
4130
|
+
return dependencyEntries(readManifest(root)).filter(([name]) => name === HARNESS_PACKAGE).map(([name, value]) => pin(resolveSpecifier(record$2(workspace), name, value)));
|
|
4130
4131
|
}
|
|
4131
4132
|
function overrideEntries(value) {
|
|
4132
4133
|
const overrides = [];
|
|
@@ -4173,7 +4174,7 @@ function checkNpmLock(content, pins) {
|
|
|
4173
4174
|
}
|
|
4174
4175
|
function namesLocalHarness(value) {
|
|
4175
4176
|
if (typeof value !== "string" || !LOCAL_DEPENDENCY.test(value)) return false;
|
|
4176
|
-
return `/${value.slice(value.indexOf(":") + 1).replaceAll("\\", "/")}/`.includes(`/${HARNESS_PACKAGE
|
|
4177
|
+
return `/${value.slice(value.indexOf(":") + 1).replaceAll("\\", "/")}/`.includes(`/${HARNESS_PACKAGE}/`);
|
|
4177
4178
|
}
|
|
4178
4179
|
function checkPnpmLock(documents, pins, workspace) {
|
|
4179
4180
|
const lock = documents.map(record$2).findLast((doc) => record$2(doc?.["importers"])?.["."] !== void 0 && record$2(doc?.["packages"]) !== void 0);
|
|
@@ -4193,7 +4194,7 @@ function checkPnpmLock(documents, pins, workspace) {
|
|
|
4193
4194
|
versions.add(version);
|
|
4194
4195
|
}
|
|
4195
4196
|
const matched = /* @__PURE__ */ new Set();
|
|
4196
|
-
const prefix = `${HARNESS_PACKAGE
|
|
4197
|
+
const prefix = `${HARNESS_PACKAGE}@`;
|
|
4197
4198
|
for (const [directory, importer] of Object.entries(importers)) for (const [name, value] of dependencyEntries(record$2(importer) ?? {})) {
|
|
4198
4199
|
const entry = record$2(value);
|
|
4199
4200
|
const locked = entry?.["version"];
|
|
@@ -4218,7 +4219,7 @@ function checkHarnessSource(root) {
|
|
|
4218
4219
|
const resolved = resolveSpecifier(workspace, name, specifier);
|
|
4219
4220
|
if (name !== "@opendesignai/harness" && !isAlias(resolved)) continue;
|
|
4220
4221
|
const version = pin(resolved);
|
|
4221
|
-
if (!version || pins.has(name) && pins.get(name) !== version) errors.push(`package.json must pin ${HARNESS_PACKAGE
|
|
4222
|
+
if (!version || pins.has(name) && pins.get(name) !== version) errors.push(`package.json must pin ${HARNESS_PACKAGE} to one exact npm version or catalog entry.`);
|
|
4222
4223
|
else pins.set(name, version);
|
|
4223
4224
|
}
|
|
4224
4225
|
for (const overrides of [
|
|
@@ -4229,32 +4230,32 @@ function checkHarnessSource(root) {
|
|
|
4229
4230
|
]) for (const [selector, specifier] of overrideEntries(overrides)) {
|
|
4230
4231
|
const name = overridePackage(selector);
|
|
4231
4232
|
const resolved = resolveSpecifier(workspace, name, specifier);
|
|
4232
|
-
if ((name === "@opendesignai/harness" || pins.has(name) || isAlias(resolved)) && !pin(resolved)) errors.push(`package.json overrides and resolutions for ${HARNESS_PACKAGE
|
|
4233
|
+
if ((name === "@opendesignai/harness" || pins.has(name) || isAlias(resolved)) && !pin(resolved)) errors.push(`package.json overrides and resolutions for ${HARNESS_PACKAGE} must use an exact npm version.`);
|
|
4233
4234
|
}
|
|
4234
4235
|
if (errors.length > 0) return errors;
|
|
4235
|
-
if (!pins.has("@opendesignai/harness")) return [`Declare ${HARNESS_PACKAGE
|
|
4236
|
+
if (!pins.has("@opendesignai/harness")) return [`Declare ${HARNESS_PACKAGE} under its original name in package.json and pin it to an exact npm version or catalog entry.`];
|
|
4236
4237
|
const npmLock = readProjectFile(root, "package-lock.json");
|
|
4237
4238
|
const pnpmLock = yamlDocuments(root, "pnpm-lock.yaml");
|
|
4238
|
-
if (npmLock === void 0 && pnpmLock.length === 0) return [`Commit package-lock.json or pnpm-lock.yaml with the registry resolution for ${HARNESS_PACKAGE
|
|
4239
|
-
if (npmLock !== void 0 && !checkNpmLock(npmLock, pins)) errors.push(`package-lock.json must resolve ${HARNESS_PACKAGE
|
|
4240
|
-
if (pnpmLock.length > 0 && !checkPnpmLock(pnpmLock, pins, workspace)) errors.push(`pnpm-lock.yaml must resolve ${HARNESS_PACKAGE
|
|
4239
|
+
if (npmLock === void 0 && pnpmLock.length === 0) return [`Commit package-lock.json or pnpm-lock.yaml with the registry resolution for ${HARNESS_PACKAGE}.`];
|
|
4240
|
+
if (npmLock !== void 0 && !checkNpmLock(npmLock, pins)) errors.push(`package-lock.json must resolve ${HARNESS_PACKAGE} from registry.npmjs.org at the pinned version with integrity.`);
|
|
4241
|
+
if (pnpmLock.length > 0 && !checkPnpmLock(pnpmLock, pins, workspace)) errors.push(`pnpm-lock.yaml must resolve ${HARNESS_PACKAGE} from the npm registry at the pinned version with integrity.`);
|
|
4241
4242
|
return errors;
|
|
4242
4243
|
}
|
|
4243
4244
|
// src/cli/doctor.ts
|
|
4244
4245
|
function checkInstallation(root) {
|
|
4245
|
-
const file = `node_modules/${HARNESS_PACKAGE
|
|
4246
|
+
const file = `node_modules/${HARNESS_PACKAGE}/package.json`;
|
|
4246
4247
|
const content = readProjectFile(root, file);
|
|
4247
|
-
if (content === void 0) return [`${HARNESS_PACKAGE
|
|
4248
|
+
if (content === void 0) return [`${HARNESS_PACKAGE} is missing. Run npm ci or pnpm install --frozen-lockfile.`];
|
|
4248
4249
|
const manifest = parseProjectJson(content, file);
|
|
4249
4250
|
const versions = declaredHarnessVersions(root);
|
|
4250
|
-
if (versions.length === 0 || versions.some((version) => !version)) return [`Pin ${HARNESS_PACKAGE
|
|
4251
|
-
if (manifest["name"] !== "@opendesignai/harness" || versions.some((version) => version !== manifest["version"])) return [`Installed ${HARNESS_PACKAGE
|
|
4251
|
+
if (versions.length === 0 || versions.some((version) => !version)) return [`Pin ${HARNESS_PACKAGE} to an exact npm version in package.json or the pnpm catalog.`];
|
|
4252
|
+
if (manifest["name"] !== "@opendesignai/harness" || versions.some((version) => version !== manifest["version"])) return [`Installed ${HARNESS_PACKAGE} does not match the declared version (${[...new Set(versions)].join(", ")}). Reinstall from the lockfile.`];
|
|
4252
4253
|
return [];
|
|
4253
4254
|
}
|
|
4254
4255
|
async function runDoctor(cwd) {
|
|
4255
4256
|
const root = projectRoot(cwd);
|
|
4256
4257
|
const errors = checkInstallation(root);
|
|
4257
|
-
const notes = errors.length === 0 ? [`${HARNESS_PACKAGE
|
|
4258
|
+
const notes = errors.length === 0 ? [`${HARNESS_PACKAGE} is installed at the declared version.`] : [];
|
|
4258
4259
|
try {
|
|
4259
4260
|
const trustErrors = await checkCodexTrust(root);
|
|
4260
4261
|
errors.push(...trustErrors);
|
|
@@ -4887,7 +4888,6 @@ function ruleChanges(cwd, commit, lintConfig) {
|
|
|
4887
4888
|
}
|
|
4888
4889
|
// src/cli/ratchet.ts
|
|
4889
4890
|
const RATCHET_DOCS = "https://github.com/nexu-io/od-harness/blob/main/docs/ratchet.md";
|
|
4890
|
-
const HARNESS_PACKAGE = "@opendesignai/harness";
|
|
4891
4891
|
/** How an accepted move was recognised, in notes and messages. */
|
|
4892
4892
|
const RENAMED = "git sees the rename";
|
|
4893
4893
|
/** The one condition under which baseline entries follow a file to a new path. */
|
|
@@ -4935,13 +4935,14 @@ function harnessVersion(packageJson, origin) {
|
|
|
4935
4935
|
} catch (error) {
|
|
4936
4936
|
throw new EnvironmentError(`${origin} is not valid JSON: ${String(error)}`);
|
|
4937
4937
|
}
|
|
4938
|
-
return pkg.devDependencies?.[
|
|
4938
|
+
return pkg.devDependencies?.["@opendesignai/harness"] ?? pkg.dependencies?.["@opendesignai/harness"] ?? null;
|
|
4939
4939
|
}
|
|
4940
4940
|
/** The nearest pnpm-workspace.yaml from `cwd` up to the repository root, relative to `cwd`. */
|
|
4941
|
-
function workspaceFile(cwd) {
|
|
4941
|
+
function workspaceFile(cwd, commit) {
|
|
4942
4942
|
for (let dir = cwd;; dir = path.dirname(dir)) {
|
|
4943
4943
|
const file = path.join(dir, "pnpm-workspace.yaml");
|
|
4944
|
-
|
|
4944
|
+
const relative = path.relative(cwd, file).split(path.sep).join("/");
|
|
4945
|
+
if (commit ? showFile(cwd, commit, relative) !== null : existsSync(file)) return relative;
|
|
4945
4946
|
if (existsSync(path.join(dir, ".git")) || path.dirname(dir) === dir) return null;
|
|
4946
4947
|
}
|
|
4947
4948
|
}
|
|
@@ -4959,6 +4960,24 @@ function release(spec, workspace) {
|
|
|
4959
4960
|
const entry = new RegExp(`^\\s*["']?${name}["']?\\s*:\\s*["']?([^"'\\s#]+)`, "gm");
|
|
4960
4961
|
return `${spec} (pnpm-workspace.yaml: ${[...workspace.matchAll(entry)].map((match) => match[1]).join(", ") || "no entry"})`;
|
|
4961
4962
|
}
|
|
4963
|
+
function parsedVersion(spec, workspace) {
|
|
4964
|
+
if (!spec?.startsWith("catalog:")) return semver.parse(spec);
|
|
4965
|
+
if (workspace === null) return null;
|
|
4966
|
+
try {
|
|
4967
|
+
const config = record$2(parse(workspace, { logLevel: "silent" }));
|
|
4968
|
+
const catalog = config?.["catalog"];
|
|
4969
|
+
const catalogs = record$2(config?.["catalogs"]);
|
|
4970
|
+
const defaultCatalog = catalogs?.["default"];
|
|
4971
|
+
if (catalog !== void 0 && defaultCatalog !== void 0) return null;
|
|
4972
|
+
const version = resolveSpecifier({
|
|
4973
|
+
catalog: catalog ?? defaultCatalog,
|
|
4974
|
+
catalogs
|
|
4975
|
+
}, HARNESS_PACKAGE, spec);
|
|
4976
|
+
return typeof version === "string" ? semver.parse(version) : null;
|
|
4977
|
+
} catch {
|
|
4978
|
+
return null;
|
|
4979
|
+
}
|
|
4980
|
+
}
|
|
4962
4981
|
function runRatchet(options) {
|
|
4963
4982
|
const { cwd } = options;
|
|
4964
4983
|
const found = baseCommit(options);
|
|
@@ -4989,15 +5008,20 @@ function runRatchet(options) {
|
|
|
4989
5008
|
const harnessBefore = harnessVersion(showFile(cwd, commit, "package.json"), `package.json@${ref}`);
|
|
4990
5009
|
const harnessAfter = harnessVersion(readWorking(cwd, "package.json"), "package.json");
|
|
4991
5010
|
const workspace = workspaceFile(cwd);
|
|
5011
|
+
const workingWorkspace = workspace && readWorking(cwd, workspace);
|
|
4992
5012
|
const releaseBefore = release(harnessBefore, workspace && showFile(cwd, commit, workspace));
|
|
4993
|
-
const releaseAfter = release(harnessAfter,
|
|
4994
|
-
const
|
|
5013
|
+
const releaseAfter = release(harnessAfter, workingWorkspace);
|
|
5014
|
+
const versionChange = releaseBefore === releaseAfter ? null : `${HARNESS_PACKAGE} ${releaseBefore ?? "(none)"} → ${releaseAfter ?? "(none)"}`;
|
|
5015
|
+
const baseWorkspace = harnessBefore?.startsWith("catalog:") ? workspaceFile(cwd, commit) : null;
|
|
5016
|
+
const versionBefore = parsedVersion(harnessBefore, baseWorkspace && showFile(cwd, commit, baseWorkspace));
|
|
5017
|
+
const versionAfter = parsedVersion(harnessAfter, workingWorkspace);
|
|
5018
|
+
const upgrade = versionBefore && versionAfter && versionAfter.compare(versionBefore) > 0 ? `${HARNESS_PACKAGE} ${versionBefore.raw} → ${versionAfter.raw}` : null;
|
|
4995
5019
|
const configChanged = showFile(cwd, commit, lintConfig) !== readWorking(cwd, lintConfig);
|
|
4996
5020
|
let changes = null;
|
|
4997
5021
|
const admits = (rule) => {
|
|
4998
|
-
if (
|
|
5022
|
+
if (versionChange !== null) return {
|
|
4999
5023
|
ok: true,
|
|
5000
|
-
why: `${
|
|
5024
|
+
why: `${versionChange} in this change`
|
|
5001
5025
|
};
|
|
5002
5026
|
if (!configChanged) return null;
|
|
5003
5027
|
changes ??= ruleChanges(cwd, commit, lintConfig);
|
|
@@ -5100,6 +5124,10 @@ function runRatchet(options) {
|
|
|
5100
5124
|
if (headTotal < baseTotal) notes.push(`${rule}: ${baseTotal} → ${headTotal}`);
|
|
5101
5125
|
continue;
|
|
5102
5126
|
}
|
|
5127
|
+
if (baseTotal > 0 && upgrade !== null) {
|
|
5128
|
+
notes.push(`${rule}: ${baseTotal} → ${headTotal} (allowed: ${upgrade} in this change, which the owner reviews).`);
|
|
5129
|
+
continue;
|
|
5130
|
+
}
|
|
5103
5131
|
const admitted = baseTotal === 0 ? admits(rule) : null;
|
|
5104
5132
|
if (admitted?.ok) {
|
|
5105
5133
|
notes.push(`${rule}: enters the baseline with ${headTotal} (allowed: ${admitted.why}, which the owner reviews).`);
|
package/dist/config.d.mts
CHANGED
|
@@ -61,6 +61,8 @@ export declare const presets: {
|
|
|
61
61
|
readonly "platform-boundary": "./node_modules/@opendesignai/harness/presets/platform-boundary.json";
|
|
62
62
|
readonly product: "./node_modules/@opendesignai/harness/presets/product.json";
|
|
63
63
|
readonly "react-compiler": "./node_modules/@opendesignai/harness/presets/react-compiler.json";
|
|
64
|
+
readonly "strict-types": "./node_modules/@opendesignai/harness/presets/strict-types.json";
|
|
65
|
+
readonly testing: "./node_modules/@opendesignai/harness/presets/testing.json";
|
|
64
66
|
readonly "type-aware": "./node_modules/@opendesignai/harness/presets/type-aware.json";
|
|
65
67
|
};
|
|
66
68
|
export {};
|
package/dist/config.mjs
CHANGED
|
@@ -5,6 +5,8 @@ const presets = {
|
|
|
5
5
|
"platform-boundary": "./node_modules/@opendesignai/harness/presets/platform-boundary.json",
|
|
6
6
|
product: "./node_modules/@opendesignai/harness/presets/product.json",
|
|
7
7
|
"react-compiler": "./node_modules/@opendesignai/harness/presets/react-compiler.json",
|
|
8
|
+
"strict-types": "./node_modules/@opendesignai/harness/presets/strict-types.json",
|
|
9
|
+
testing: "./node_modules/@opendesignai/harness/presets/testing.json",
|
|
8
10
|
"type-aware": "./node_modules/@opendesignai/harness/presets/type-aware.json"
|
|
9
11
|
};
|
|
10
12
|
export { presets };
|
package/dist/plugin.d.mts
CHANGED
|
@@ -36,6 +36,6 @@ interface Plugin {
|
|
|
36
36
|
rules: Record<string, PluginRule>;
|
|
37
37
|
}
|
|
38
38
|
/** Kept in sync with package.json by test/plugin.test.ts. */
|
|
39
|
-
export declare const VERSION = "0.
|
|
39
|
+
export declare const VERSION = "0.4.0-alpha.0";
|
|
40
40
|
declare const plugin: Plugin;
|
|
41
41
|
export { type Plugin, type PluginRule, type RuleContextLike, type RuleMeta, plugin as default };
|
package/dist/plugin.mjs
CHANGED
|
@@ -1640,7 +1640,7 @@ const noWindowBus = {
|
|
|
1640
1640
|
};
|
|
1641
1641
|
// src/plugin/version.ts
|
|
1642
1642
|
/** Kept in sync with package.json by test/plugin.test.ts. */
|
|
1643
|
-
const VERSION = "0.
|
|
1643
|
+
const VERSION = "0.4.0-alpha.0";
|
|
1644
1644
|
// src/plugin/index.ts
|
|
1645
1645
|
const plugin = {
|
|
1646
1646
|
meta: {
|
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
|
|
|
@@ -59,7 +59,7 @@ Create `.oxlintrc.json` at the repository root:
|
|
|
59
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`.
|
|
60
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.
|
|
61
61
|
- Exemptions are `overrides` entries in this file. The file belongs to the platform owner (CODEOWNERS); every exemption is reviewed there, never inline.
|
|
62
|
-
- 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)).
|
|
63
63
|
- Run Oxlint from the repository root: path options (`shell`, `product`) are relative to the working directory.
|
|
64
64
|
|
|
65
65
|
Add scripts:
|
|
@@ -104,6 +104,26 @@ After type-checking, run `node lint-config.mts > .oxlintrc.json` from the reposi
|
|
|
104
104
|
|
|
105
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
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
|
+
|
|
107
127
|
### Type-aware linting
|
|
108
128
|
|
|
109
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.
|
|
@@ -150,7 +170,7 @@ With a non-root `working-directory` in `gates.yml`, keep `.oxlintrc.json` at the
|
|
|
150
170
|
|
|
151
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).
|
|
152
172
|
|
|
153
|
-
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.
|
|
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).
|
|
154
174
|
|
|
155
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:
|
|
156
176
|
|
|
@@ -294,7 +314,7 @@ Set `clones: true` and `unused: true` in the change that adopts or upgrades to a
|
|
|
294
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). |
|
|
295
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. |
|
|
296
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. |
|
|
297
|
-
|
|
|
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. |
|
|
298
318
|
| Upgrading od-harness turns a rule off | Run `oxlint --prune-suppressions` and delete the disable comments that became unused, in the upgrade change. |
|
|
299
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). |
|
|
300
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,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)
|
package/docs/ratchet.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# od-harness ratchet
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`od-harness ratchet --base <ref>` compares the working tree with the base commit (in CI: `"$HARNESS_BASE_REF"`, the PR base). For a local run, `od-harness ratchet --merge-base origin/main` compares with the commit the branch left `origin/main` at (below).
|
|
4
4
|
|
|
5
5
|
It fails when:
|
|
6
6
|
|
|
7
|
-
| Check
|
|
8
|
-
|
|
|
9
|
-
| `oxlint-suppressions.json`,
|
|
10
|
-
| `oxlint-suppressions.json`, new rule IDs
|
|
11
|
-
| `oxlint-suppressions.json`, new files
|
|
12
|
-
| both baselines, stale entries
|
|
13
|
-
| `.harness/size-baseline.json`
|
|
14
|
-
| both baselines, new baseline file
|
|
7
|
+
| Check | Fails when |
|
|
8
|
+
| --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| `oxlint-suppressions.json`, existing rule IDs | a rule's total count across all files grows from a positive count at the base, unless the same change upgrades `@opendesignai/harness` ([below](#why-a-config-or-version-change-admits-new-rule-ids)). |
|
|
10
|
+
| `oxlint-suppressions.json`, new rule IDs | a rule appears that the base did not have, unless the harness version declaration changes or `.oxlintrc.json` turns that rule on ([below](#why-a-config-or-version-change-admits-new-rule-ids), both owner-reviewed). |
|
|
11
|
+
| `oxlint-suppressions.json`, new files | an entry names a file that the base commit does not have. New files do not get a baseline, also not in the adoption change or together with a new rule ID. A moved file keeps the entry of its old path ([moved files](#moved-files)). |
|
|
12
|
+
| both baselines, stale entries | an entry names a file that no longer exists. |
|
|
13
|
+
| `.harness/size-baseline.json` | an entry was raised, or a file was added (except a [moved file](#moved-files)). |
|
|
14
|
+
| both baselines, new baseline file | the base commit has no such file, unless the same change adds `@opendesignai/harness` to `package.json` (the adoption change). Upgrading the harness or changing `.oxlintrc.json` does not count. |
|
|
15
15
|
|
|
16
16
|
A baseline file may only appear in the adoption change: the change that adds `@opendesignai/harness` to `package.json`, where the base lists it in neither `dependencies` nor `devDependencies`. Then the comparison with the base is skipped and reported. Any later change that creates `oxlint-suppressions.json` or `.harness/size-baseline.json` fails, also one that upgrades the harness or changes `.oxlintrc.json`: a repository that was adopted without a baseline (no existing debt) keeps it that way, and the violations an upgrade or a config change brings are fixed in that change instead of frozen. This does not depend on review, so it holds even when a change is merged without the owner's approval, as long as the caller's workflow keeps `ratchet` on (turning a gate off is a reviewed workflow change).
|
|
17
17
|
|
|
@@ -25,28 +25,25 @@ Entries may follow a file to a new path; [`od-harness baseline move`](baseline-m
|
|
|
25
25
|
- the old path had an entry in the same baseline at the base and no longer exists (spelled exactly so, also on file systems that ignore case);
|
|
26
26
|
- the moved entry holds no more than the old one did (per rule, or in lines), and each old entry moves to one file only.
|
|
27
27
|
|
|
28
|
-
The rule
|
|
28
|
+
The same rule total checks apply to moves. Accepted moves are listed in the output (`baseline entry moved from …`, `frozen size moved from …`); rejected ones say which condition failed.
|
|
29
29
|
|
|
30
30
|
## Why a config or version change admits new rule IDs
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
- **
|
|
35
|
-
- **Otherwise, `.oxlintrc.json` changed**: a new rule ID is admitted only when this change turns that rule on. The rule is on in the change's effective configuration, at the top level or in an override, and its settings differ from the base's: another severity or other options, or an override with other `files`. An unrelated edit (an `ignorePatterns` entry, another rule) admits nothing, and neither does restating a rule that a preset or a category already turns on.
|
|
36
|
-
- **Neither changed**: no new rule ID is admitted.
|
|
32
|
+
- **The harness version increased.** Existing rule totals may grow only when both versions resolve to exact SemVer versions and the new version is higher, including prerelease precedence. A minor or major release can make an existing rule report more, so the upgrade can include the resulting suppressions for existing files. Ratchet reports the old and new totals and versions.
|
|
33
|
+
- **The harness version declaration changed.** This admits every new rule ID.
|
|
34
|
+
- **Otherwise, `.oxlintrc.json` can admit a new rule ID.** The rule must be on in the change's effective configuration, at the top level or in an override, and its settings must differ from the base's in severity, options or override `files`. An unrelated edit (an `ignorePatterns` entry, another rule) admits nothing, and neither does restating a rule that a preset or a category already turns on.
|
|
37
35
|
|
|
38
36
|
The effective configurations come from Oxlint 1.96.0: `oxlint -c <file> --print-config` prints a configuration file with `extends` resolved and categories expanded into rules; `overrides` keep their globs, so an override counts by its `files` and settings. For the base, `ratchet` writes the base commit to a temporary directory (as `unused` does) and links the working tree's `node_modules` into it, so the base's `.oxlintrc.json` extends the installed presets and loads the installed plugins. That is exact because the harness version did not change. If Oxlint cannot print either configuration (it cannot load a plugin, or it is not installed), `ratchet` compares the rule settings written in the two files instead, and says so in the output; then only rules the change sets itself are admitted. Only the file `--lint-config` names counts: nested `.oxlintrc.json` files are separate configurations, which Oxlint prints separately.
|
|
39
37
|
|
|
40
38
|
In an effective configuration where `options.typeAware` is unset or false, type-aware rules count as off at the top level and in overrides. When either side has type-aware linting off, `ratchet` reads the rule metadata once from `oxlint --rules --format json` to identify those rules. Enabling `options.typeAware` can therefore admit a type-aware rule that a category already listed as enabled. It must still be enabled in the change's effective configuration. If the metadata command fails, `ratchet` reports an environment error.
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
CI installs the change's dependencies only. Reading the base's configuration with the new harness's presets would make a rule added by the upgrade look enabled at the base. Identifying which rule IDs an upgrade adds needs the rule list of every harness version in the package ([Next steps](../README.md#next-steps)).
|
|
43
41
|
|
|
44
|
-
-
|
|
45
|
-
- `.oxlintrc.json`, `package.json` and `pnpm-workspace.yaml` belong to the platform owner in CODEOWNERS, so every change that admits a new rule ID is reviewed by the owner.
|
|
42
|
+
New files are excluded from baselines in both version and configuration changes. `.oxlintrc.json`, `package.json` and `pnpm-workspace.yaml` belong to the platform owner in CODEOWNERS. The owner reviews the changes to version declarations and lint configuration that affect baselines.
|
|
46
43
|
|
|
47
44
|
This condition does not admit a new baseline file: only the adoption change may create one (above), so a repository without baselines cannot gain one through a config change or an upgrade, reviewed or not.
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
Ratchet reads the version declaration from `dependencies` or `devDependencies` in `package.json`. To compare SemVer versions, it resolves the referenced catalog in the nearest `pnpm-workspace.yaml` on each side. For new rule IDs, it also checks for changes to the lines that name `@opendesignai/harness` in the working tree's nearest `pnpm-workspace.yaml` and the same path at the base. Only the change that adds the harness to `package.json` is the adoption change, also with a catalog.
|
|
50
47
|
|
|
51
48
|
## Options
|
|
52
49
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opendesignai/harness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-alpha.0",
|
|
4
4
|
"description": "OpenDesign harness: od/* lint rules for Oxlint (ESLint plugin format), presets, file size budget, baseline ratchet and incremental duplication and unused-code gates",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint-plugin",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"jscpd": "5.4.3",
|
|
55
55
|
"knip": "6.50.0",
|
|
56
56
|
"oxc-parser": "0.160.0",
|
|
57
|
+
"semver": "7.8.6",
|
|
57
58
|
"yaml": "2.9.1"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"@eslint-community/eslint-plugin-eslint-comments": "4.8.1",
|
|
62
63
|
"@od-harness/ts-eslint-parser": "0.0.0",
|
|
63
64
|
"@types/node": "26.6.11",
|
|
65
|
+
"@types/semver": "7.8.0",
|
|
64
66
|
"@typescript-eslint/types": "8.74.0",
|
|
65
67
|
"eslint": "10.16.0",
|
|
66
68
|
"oxfmt": "0.81.0",
|
package/presets/rules/base.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"plugins": ["vitest"],
|
|
3
|
+
"rules": {
|
|
4
|
+
"vitest/expect-expect": "off",
|
|
5
|
+
"vitest/hoisted-apis-on-top": "off",
|
|
6
|
+
"vitest/no-conditional-expect": "off",
|
|
7
|
+
"vitest/no-conditional-tests": "off",
|
|
8
|
+
"vitest/no-disabled-tests": "error",
|
|
9
|
+
"vitest/no-focused-tests": "error",
|
|
10
|
+
"vitest/no-standalone-expect": "off",
|
|
11
|
+
"vitest/prefer-snapshot-hint": "off",
|
|
12
|
+
"vitest/require-awaited-expect-poll": "off",
|
|
13
|
+
"vitest/require-local-test-context-for-concurrent-snapshots": "off",
|
|
14
|
+
"vitest/require-mock-type-parameters": "off",
|
|
15
|
+
"vitest/require-to-throw-message": "off",
|
|
16
|
+
"vitest/valid-describe-callback": "off",
|
|
17
|
+
"vitest/valid-expect": "off",
|
|
18
|
+
"vitest/valid-expect-in-promise": "off",
|
|
19
|
+
"vitest/valid-title": "off",
|
|
20
|
+
"vitest/warn-todo": "off"
|
|
21
|
+
}
|
|
22
|
+
}
|