@opendesignai/harness 0.1.0-alpha.0 → 0.2.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 +17 -12
- package/dist/cli.mjs +1438 -95
- package/dist/eslint-comments.d.mts +17 -1
- package/dist/eslint-comments.mjs +134 -2
- package/dist/plugin.d.mts +20 -4
- package/dist/plugin.mjs +429 -59
- package/docs/adopting.md +84 -17
- package/docs/baseline-move.md +56 -0
- package/docs/clones.md +51 -0
- package/docs/decisions/0003-agent-harness.md +37 -0
- package/docs/hooks.md +128 -0
- package/docs/ratchet.md +25 -9
- package/docs/rules/no-api-path-literal.md +1 -1
- package/docs/rules/no-cjk-literal.md +1 -1
- package/docs/rules/no-error-message-match.md +11 -3
- package/docs/rules/no-locale-branch.md +9 -5
- package/docs/rules/no-process-env.md +11 -1
- package/docs/rules/no-product-literal.md +6 -0
- package/docs/rules/no-raw-storage.md +4 -2
- package/docs/rules/no-shell-imports-product.md +4 -2
- package/docs/rules/no-swallowed-catch.md +5 -4
- package/docs/size.md +1 -0
- package/docs/unused.md +76 -0
- package/package.json +6 -4
- package/presets/rules/base.json +5 -3
package/README.md
CHANGED
|
@@ -9,12 +9,12 @@ Machine-checked rules for OpenDesign repositories (od-platform, openmotion, open
|
|
|
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
11
|
- **presets** (`base`, `platform-boundary`, `product`, and the opt-in `react-compiler`) that a repository extends from its `.oxlintrc.json`;
|
|
12
|
-
- **`od-harness` CLI**: a file size budget (`size`)
|
|
12
|
+
- **`od-harness` CLI**: 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 baselines may only shrink. 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.
|
|
15
|
+
Existing debt is frozen in baselines (`oxlint-suppressions.json`, `.harness/size-baseline.json`); new violations fail, and the baselines may only shrink. 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:
|
|
17
|
+
Status: alpha (0.2.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
|
|
|
@@ -70,9 +70,12 @@ Oxlint resolves `extends` as file paths, so the `./node_modules/…` prefix is r
|
|
|
70
70
|
```text
|
|
71
71
|
od-harness size [--update | --init] file size budget (800 lines; tests and CSS 1,500)
|
|
72
72
|
od-harness ratchet --base <ref> baselines may only shrink relative to <ref>
|
|
73
|
+
od-harness clones --base <ref> no duplicated code that <ref> does not have (jscpd)
|
|
74
|
+
od-harness unused --base <ref> no unused files, exports, dependencies that <ref> does not have (knip)
|
|
75
|
+
od-harness baseline move <from> <to> move baseline entries along with moved files
|
|
73
76
|
```
|
|
74
77
|
|
|
75
|
-
See [docs/size.md](docs/size.md)
|
|
78
|
+
See [docs/size.md](docs/size.md), [docs/ratchet.md](docs/ratchet.md), [docs/clones.md](docs/clones.md), [docs/unused.md](docs/unused.md) and [docs/baseline-move.md](docs/baseline-move.md).
|
|
76
79
|
|
|
77
80
|
## CI
|
|
78
81
|
|
|
@@ -84,21 +87,23 @@ jobs:
|
|
|
84
87
|
commands: pnpm test # optional: extra commands after the gates
|
|
85
88
|
```
|
|
86
89
|
|
|
87
|
-
The workflow picks pnpm or npm from the lockfile, sets up Node from `.node-version`, installs with the frozen lockfile and runs the gates itself: `oxlint --deny-warnings`, `od-harness size
|
|
90
|
+
The workflow picks pnpm or npm from the lockfile, sets up Node from `.node-version`, installs with the frozen lockfile and runs the gates itself: `oxlint --deny-warnings`, `od-harness size`, then `od-harness ratchet`, `clones` and `unused` with `--base "$HARNESS_BASE_REF"` (through `pnpm exec` or `npx --no-install`), then each line of `commands`, reporting every failure. Each gate is a boolean input: `lint`, `size` and `ratchet` default to on; `clones` and `unused` are off by default in `v1`, and a caller turns them on (`clones: true`, `unused: true`) in the change that upgrades the harness to a version that has them. Full walkthrough: [docs/adopting.md](docs/adopting.md).
|
|
88
91
|
|
|
89
92
|
## Versioning
|
|
90
93
|
|
|
91
94
|
- 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.
|
|
92
|
-
- An upgrade that adds a rule commits the new rule's baseline entries in the same change (`oxlint --suppress-all` on an otherwise clean branch); a repository without `oxlint-suppressions.json` fixes the new violations instead, because only the adoption change may create a baseline file. `od-harness ratchet` accepts new rule IDs only
|
|
95
|
+
- An upgrade that adds a rule commits the new rule's baseline entries in the same change (`oxlint --suppress-all` on an otherwise clean branch); a repository without `oxlint-suppressions.json` fixes the new violations instead, because only the adoption change may create a baseline file. `od-harness ratchet` accepts new rule IDs only in a change that upgrades `@opendesignai/harness`, or whose `.oxlintrc.json` change turns those rules on, both owner-reviewed ([docs/ratchet.md](docs/ratchet.md#why-a-config-or-version-change-admits-new-rule-ids)).
|
|
93
96
|
- Oxlint is pinned exactly (`peerDependencies`); 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)).
|
|
94
|
-
-
|
|
95
|
-
-
|
|
97
|
+
- 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.
|
|
98
|
+
- Releases go to the public npm registry under the dist-tag in `publishConfig.tag` (`alpha`). npm set `latest` to 0.1.0-alpha.0 on the first publish and alpha releases do not move it, so install with `@alpha` until the first stable release.
|
|
99
|
+
- Releases are published by `.github/workflows/release.yml` through npm trusted publishing: OIDC, no npm token stored anywhere, provenance added by npm. To release, a pull request sets the new `version` in `package.json`; once it is merged, a repository admin pushes the tag `v<version>` on that commit of `main` (the `v*` tag ruleset restricts creating and moving `v*` tags to admins). The workflow checks that the tag matches the version and that the commit is on `main`, runs `pnpm check` and `pnpm smoke`, and publishes the tarball `pnpm pack` writes (never the checkout, which would ship `catalog:` and `workspace:` specifiers). The job runs in the `npm` environment, which the trusted publisher on npm is bound to.
|
|
100
|
+
- Callers reference `gates.yml` by the git tag `v1`, which never publishes. Move `v1` to a release commit only after that release has been published successfully, and only if it keeps `gates.yml` compatible for callers: a gate added in `v1` is off by default (as `clones` and `unused` are) and stays off until a caller turns it on, so moving the tag fails no caller. A gate on by default needs a new tag, `v2`. Moving `v1` also takes a repository admin.
|
|
96
101
|
|
|
97
102
|
## Next steps
|
|
98
103
|
|
|
99
|
-
- **`
|
|
100
|
-
-
|
|
101
|
-
- **
|
|
104
|
+
- **`budget-exception`**: an owner-approved way through the gates for a single change (for example a PR label that `gates.yml` reads). Not built yet; today the only exemptions are owner-reviewed configuration (`overrides` in the lint config, `.harness/config.json`, the knip configuration).
|
|
105
|
+
- **A narrower condition for new rule IDs in upgrades**: a change to `.oxlintrc.json` admits only the rules it turns on (`ratchet` compares the effective configurations), but an upgrade of `@opendesignai/harness` still admits every new rule ID, because CI only has the new presets ([why](docs/ratchet.md#why-a-config-or-version-change-admits-new-rule-ids)). One way: ship the rule list of every harness version in the package, so `ratchet` knows which rules an upgrade turned on.
|
|
106
|
+
- **More baseline kinds**: stylelint counts per file, when they exist, join `ratchet` and `baseline move` as a third baseline ([how](docs/baseline-move.md#more-baseline-kinds)).
|
|
102
107
|
|
|
103
108
|
## Development
|
|
104
109
|
|
|
@@ -114,7 +119,7 @@ pnpm hit-compare <snapshot-dir>... # ESLint vs Oxlint hits on real code (after
|
|
|
114
119
|
| ------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
115
120
|
| `src/plugin/` | the `od` plugin: one file per rule in `rules/`, shared helpers in `utils/` |
|
|
116
121
|
| `src/eslint-comments/` | the eslint-comments plugin as the presets load it: upstream rules with a fix for Oxlint |
|
|
117
|
-
| `src/cli/` | `od-harness size` and `
|
|
122
|
+
| `src/cli/` | `od-harness size`, `ratchet`, `clones`, `unused` and `baseline move` |
|
|
118
123
|
| `presets/` | consumer presets; `presets/rules/` holds the rule sets without the plugin binding |
|
|
119
124
|
| `test/` | RuleTester cases (`test/rules/*.cases.ts`), Oxlint conformance, CLI, presets, workflow tests |
|
|
120
125
|
| `docs/` | rule pages, adoption guide, decision records; upstream issue drafts (`docs/upstream/`, not packed) |
|