@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/README.md
CHANGED
|
@@ -8,44 +8,54 @@
|
|
|
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`) that a repository extends from its `.oxlintrc.json`;
|
|
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;
|
|
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
|
+
- **`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
|
|
|
21
|
-
| Rule | Preset | Reports
|
|
22
|
-
| ----------------------------------------------------------------------- | -------------------------- |
|
|
23
|
-
| [`od/no-product-literal`](docs/rules/no-product-literal.md) | platform-boundary, product | branching on product identity (`=== "opengame"`, `currentProductId() === …`)
|
|
24
|
-
| [`od/no-shell-imports-product`](docs/rules/no-shell-imports-product.md) | platform-boundary | static imports from shell files into product directories (configured per repository)
|
|
25
|
-
| [`od/no-locale-branch`](docs/rules/no-locale-branch.md) | base | hard-coded copy in branches derived from the locale (`isZh ? "标题" : "Title"`)
|
|
26
|
-
| [`od/no-raw-storage`](docs/rules/no-raw-storage.md) | base | `localStorage` / `sessionStorage` outside the storage wrapper
|
|
27
|
-
| [`od/no-swallowed-catch`](docs/rules/no-swallowed-catch.md) | base | empty `
|
|
28
|
-
| [`od/no-raw-fetch`](docs/rules/no-raw-fetch.md) | base | global `fetch()` outside the API client
|
|
29
|
-
| [`od/no-api-path-literal`](docs/rules/no-api-path-literal.md) | base | hand-written `/api/…`, `/motion-api/…` paths outside the API client
|
|
30
|
-
| [`od/no-window-bus`](docs/rules/no-window-bus.md) | base | `window.dispatchEvent`, `new CustomEvent`, listeners for custom event names on global objects
|
|
31
|
-
| [`od/no-process-env`](docs/rules/no-process-env.md) | base | `process.env` outside the env registry
|
|
32
|
-
| [`od/no-error-message-match`](docs/rules/no-error-message-match.md) | base | decisions made by matching error message text
|
|
33
|
-
| [`od/no-cjk-literal`](docs/rules/no-cjk-literal.md) | base | CJK text in source literals and JSX text
|
|
34
|
-
| [`od/no-constant-flag`](docs/rules/no-constant-flag.md) | base | module-level `const xxxEnabled = true` feature toggles
|
|
21
|
+
| Rule | Preset | Reports |
|
|
22
|
+
| ----------------------------------------------------------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
23
|
+
| [`od/no-product-literal`](docs/rules/no-product-literal.md) | platform-boundary, product | branching on product identity (`=== "opengame"`, `currentProductId() === …`) |
|
|
24
|
+
| [`od/no-shell-imports-product`](docs/rules/no-shell-imports-product.md) | platform-boundary | static imports from shell files into product directories (configured per repository) |
|
|
25
|
+
| [`od/no-locale-branch`](docs/rules/no-locale-branch.md) | base | hard-coded copy in branches derived from the locale (`isZh ? "标题" : "Title"`) |
|
|
26
|
+
| [`od/no-raw-storage`](docs/rules/no-raw-storage.md) | base | `localStorage` / `sessionStorage` outside the storage wrapper |
|
|
27
|
+
| [`od/no-swallowed-catch`](docs/rules/no-swallowed-catch.md) | base | Empty or constant-only handlers. Exempts non-empty strings and probes with one call before `return true` and a `return false` catch. `// fail-open: <reason>` marks deliberate ones. |
|
|
28
|
+
| [`od/no-raw-fetch`](docs/rules/no-raw-fetch.md) | base | global `fetch()` outside the API client |
|
|
29
|
+
| [`od/no-api-path-literal`](docs/rules/no-api-path-literal.md) | base | hand-written `/api/…`, `/motion-api/…` paths outside the API client |
|
|
30
|
+
| [`od/no-window-bus`](docs/rules/no-window-bus.md) | base | `window.dispatchEvent`, `new CustomEvent`, listeners for custom event names on global objects |
|
|
31
|
+
| [`od/no-process-env`](docs/rules/no-process-env.md) | base | `process.env` outside the env registry |
|
|
32
|
+
| [`od/no-error-message-match`](docs/rules/no-error-message-match.md) | base | decisions made by matching error message text |
|
|
33
|
+
| [`od/no-cjk-literal`](docs/rules/no-cjk-literal.md) | base | CJK text in source literals and JSX text |
|
|
34
|
+
| [`od/no-constant-flag`](docs/rules/no-constant-flag.md) | base | module-level `const xxxEnabled = true` feature toggles |
|
|
35
|
+
| [`od/no-commented-out-code`](docs/rules/no-commented-out-code.md) | base | commented-out JavaScript, TypeScript and JSX |
|
|
35
36
|
|
|
36
37
|
Every rule is tested with ESLint's `RuleTester` and with the same cases run through the Oxlint CLI; both must report the same diagnostics. Together with `scripts/hit-compare.ts`, which compares ESLint and Oxlint hits on real code, that suite is the regression gate for Oxlint upgrades.
|
|
37
38
|
|
|
38
39
|
## Presets
|
|
39
40
|
|
|
40
|
-
| Preset | Contents
|
|
41
|
-
| -------------------------------- |
|
|
42
|
-
| `presets/base.json` | the
|
|
43
|
-
| `presets/platform-boundary.json` | `od/no-product-literal`, `od/no-shell-imports-product` (inactive until the repository sets `shell` and `product`)
|
|
44
|
-
| `presets/product.json` | `od/no-product-literal`; product-package rules (published-imports-only, manifest checks) arrive with stage 2
|
|
45
|
-
| `presets/react-compiler.json` | opt-in:
|
|
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)) |
|
|
46
50
|
|
|
47
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).
|
|
48
52
|
|
|
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)
|
|
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
|
+
|
|
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.
|
|
58
|
+
|
|
49
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.
|
|
50
60
|
|
|
51
61
|
```json
|
|
@@ -63,19 +73,40 @@ Presets are fragments: extend `base` plus the one that matches the repository. A
|
|
|
63
73
|
}
|
|
64
74
|
```
|
|
65
75
|
|
|
66
|
-
Oxlint resolves `extends` as file paths, so the `./node_modules/…` prefix is required. The base preset also turns on `reportUnusedDisableDirectives: "error"`, so the root config does not need to.
|
|
76
|
+
Oxlint resolves `extends` as file paths, so the `./node_modules/…` prefix is required. The base preset also turns on `reportUnusedDisableDirectives: "error"` and `denyWarnings: true`, so the root config does not need to.
|
|
77
|
+
|
|
78
|
+
### Typed configuration
|
|
79
|
+
|
|
80
|
+
`@opendesignai/harness/config` exports an `OxlintConfig` type for the root `.oxlintrc.json` and a `presets` object with preset paths. Use them in a TypeScript file to check `od/*` rule options and generate JSON. See the [typed configuration example](docs/adopting.md#typed-configuration).
|
|
67
81
|
|
|
68
82
|
## CLI
|
|
69
83
|
|
|
70
84
|
```text
|
|
85
|
+
od-harness lint-scope reject alternate lint configs and ignored tracked files
|
|
71
86
|
od-harness size [--update | --init] file size budget (800 lines; tests and CSS 1,500)
|
|
72
|
-
od-harness ratchet --base <ref>
|
|
87
|
+
od-harness ratchet --base <ref> check baseline changes relative to <ref>
|
|
88
|
+
--merge-base <ref> … relative to `git merge-base HEAD <ref>` (local runs)
|
|
73
89
|
od-harness clones --base <ref> no duplicated code that <ref> does not have (jscpd)
|
|
74
90
|
od-harness unused --base <ref> no unused files, exports, dependencies that <ref> does not have (knip)
|
|
91
|
+
od-harness comments --base <ref> report excess added comment lines as a notice
|
|
75
92
|
od-harness baseline move <from> <to> move baseline entries along with moved files
|
|
93
|
+
od-harness init [--check] generate or check repository agent configuration
|
|
94
|
+
od-harness doctor check the installed harness version and Codex hook trust
|
|
95
|
+
od-harness verify [--quick | --ci --base <ref>] [--skip lint-scope] [--format text|json|github]
|
|
96
|
+
od-harness --version print the version
|
|
76
97
|
```
|
|
77
98
|
|
|
78
|
-
See [docs/
|
|
99
|
+
See the [lint scope policy](docs/adopting.md#lint-scope) and the command guides for [size](docs/size.md), [ratchet](docs/ratchet.md), [clones](docs/clones.md), [unused](docs/unused.md), [baseline move](docs/baseline-move.md) and [verify](docs/verify.md).
|
|
100
|
+
|
|
101
|
+
Manage and check agent instructions with [the `agents` commands](docs/agents.md).
|
|
102
|
+
|
|
103
|
+
File-based checks support `--format text|json|github`. Consumer scripts can reuse the reporter from `@opendesignai/harness/report`. [CLI diagnostics](docs/diagnostics.md)
|
|
104
|
+
|
|
105
|
+
Generate and check repository hook configuration with [the agent setup commands](docs/agent-setup.md).
|
|
106
|
+
|
|
107
|
+
Run `od-harness verify` to check a change locally. It includes the lint scope gate by default and can run the agent reference check when configured. [Verify guide](docs/verify.md)
|
|
108
|
+
|
|
109
|
+
[od-harness comments](docs/comments.md) reports excess added comments as a notice.
|
|
79
110
|
|
|
80
111
|
## CI
|
|
81
112
|
|
|
@@ -87,16 +118,28 @@ jobs:
|
|
|
87
118
|
commands: pnpm test # optional: extra commands after the gates
|
|
88
119
|
```
|
|
89
120
|
|
|
90
|
-
The workflow picks pnpm or npm from the lockfile
|
|
121
|
+
The workflow picks pnpm or npm from the lockfile and sets up Node from `.node-version`. Before installing, `Check harness source` requires an exact registry version for `@opendesignai/harness` in dependency fields, overrides and resolutions, including npm workspace member pins. Exact `npm:` aliases and pnpm catalogs, including `catalog:default`, are supported. The checker matches harness names and protocol prefixes case-insensitively. Both lockfile formats require integrity. pnpm entries must omit `tarball`, `directory` and `repo`. The checker rejects harness patches and checks registry settings in `.npmrc` and `pnpm-workspace.yaml` through the repository root. npm entries must resolve under `https://registry.npmjs.org/@opendesignai/harness/-/`. Local, workspace, Git and direct HTTP(S) tarball sources fail the check.
|
|
122
|
+
|
|
123
|
+
After a frozen install, `Check harness bin` verifies that `node_modules/.bin/od-harness` resolves to the CLI declared inside the installed harness package.
|
|
124
|
+
|
|
125
|
+
Workflow revisions with lint scope run `od-harness lint-scope`, `oxlint --deny-warnings --format github`, `od-harness size` and `od-harness ratchet --base "$HARNESS_BASE_REF"` by default. Each can be disabled independently. `clones` and `unused` default to false and use the same base when enabled. Oxlint and the harness gates annotate offending files on GitHub pull requests.
|
|
126
|
+
|
|
127
|
+
`use-verify` defaults to `false`. With a workflow ref that supports it and harness `0.3.0-alpha.0` or newer, set `use-verify: true` to run `od-harness verify --ci --base "$HARNESS_BASE_REF"` using `.harness/config.json`. Verify runs lint scope by default and uses the base commit directly. It ignores the individual workflow inputs `lint-scope`, `lint`, `size`, `ratchet`, `clones` and `unused`. The workflow warns when their values differ from the defaults.
|
|
128
|
+
|
|
129
|
+
Both modes run through `pnpm exec` or `npx --no-install`, then run each line of `commands` and report all command failures. [Adoption guide](docs/adopting.md#5-call-the-gate-in-ci)
|
|
130
|
+
|
|
131
|
+
This repository's own workflows are linted by `.github/workflows/workflow-lint.yml` (actionlint with shellcheck, and zizmor; known findings are listed in `.github/zizmor.yml`), and Dependabot (`.github/dependabot.yml`) proposes updates of the pinned action SHAs once a week; the actionlint image digest and the zizmor version are updated by hand.
|
|
91
132
|
|
|
92
133
|
## Versioning
|
|
93
134
|
|
|
94
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.
|
|
95
|
-
-
|
|
96
|
-
-
|
|
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).
|
|
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.
|
|
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)
|
|
97
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.
|
|
140
|
+
- The eslint-comments plugin (`@eslint-community/eslint-plugin-eslint-comments`) and its two dependencies are bundled into `dist/eslint-comments.mjs`, so installing the harness does not install the plugin's peer dependency `eslint`. Their version is part of the harness release, and their licenses ship in `dist/THIRD-PARTY-LICENSES.md`.
|
|
98
141
|
- 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
|
|
142
|
+
- 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 has two jobs. `verify` (read-only, outside the `npm` environment) checks that the tag matches the version, that a prerelease version has a `publishConfig.tag` other than `latest`, and that the commit is on `main`; runs `pnpm check` and `pnpm smoke`; packs the tarball `pnpm pack` writes (never the checkout, which would ship `catalog:` and `workspace:` specifiers) and logs the dist-tag the tarball will be published under (npm's own log says `latest` even when `publishConfig.tag` overrides it); and hands the tarball to `publish` as an artifact, with its SHA-256 as a job output. `publish` runs in the `npm` environment, which the trusted publisher on npm is bound to, with only `id-token: write`: it checks out and installs nothing, verifies the tarball against the SHA-256 from `verify`, and runs `npm publish <tarball> --access public --ignore-scripts`.
|
|
100
143
|
- 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.
|
|
101
144
|
|
|
102
145
|
## Next steps
|
|
@@ -107,26 +150,29 @@ The workflow picks pnpm or npm from the lockfile, sets up Node from `.node-versi
|
|
|
107
150
|
|
|
108
151
|
## Development
|
|
109
152
|
|
|
153
|
+
Node 25 and later no longer ship corepack, so install pnpm with npm, at the version `packageManager` in `package.json` pins (12.26.0). A global install puts `pnpm` on the `PATH` for every command, including the scripts that call `pnpm` again (`pnpm check`, `pnpm smoke`); `npx pnpm@12.26.0` would have to prefix each command instead. Where corepack is still available (Node 24 and earlier), `corepack pnpm …` works as well.
|
|
154
|
+
|
|
110
155
|
```sh
|
|
111
|
-
|
|
156
|
+
npm install --global pnpm@12.26.0 # once; the version of packageManager in package.json
|
|
157
|
+
pnpm install
|
|
112
158
|
pnpm check # format, lint, size, build, typecheck, test, knip — what CI runs
|
|
113
159
|
pnpm smoke # pack, install into fresh npm and pnpm projects, lint with the presets (network)
|
|
114
160
|
pnpm trial <snapshot-dir>... # run the presets on git checkouts of product repositories (read-only; writes .trial/)
|
|
115
161
|
pnpm hit-compare <snapshot-dir>... # ESLint vs Oxlint hits on real code (after pnpm build); required before an Oxlint upgrade
|
|
116
162
|
```
|
|
117
163
|
|
|
118
|
-
| Path | Contents
|
|
119
|
-
| ------------------------- |
|
|
120
|
-
| `src/plugin/` | the `od` plugin: one file per rule in `rules/`, shared helpers in `utils/`
|
|
121
|
-
| `src/eslint-comments/` | the eslint-comments plugin as the presets load it: upstream rules with
|
|
122
|
-
| `src/cli/` | `od-harness size`, `ratchet`, `clones`, `unused` and `baseline move`
|
|
123
|
-
| `presets/` | consumer presets; `presets/rules/` holds the rule sets without the plugin binding
|
|
124
|
-
| `test/` | RuleTester cases (`test/rules/*.cases.ts`), Oxlint conformance, CLI, presets, workflow tests
|
|
125
|
-
| `docs/` | rule pages, adoption guide, decision records; upstream issue drafts (`docs/upstream/`, not packed)
|
|
126
|
-
| `tools/ts-eslint-parser/` | tests and `scripts/hit-compare.ts` only: typescript-eslint's parser pinned to TypeScript 6
|
|
127
|
-
| `scripts/` | `smoke-pack.ts`, `trial.ts`, `hit-compare.ts`
|
|
128
|
-
|
|
129
|
-
This repository lints itself with the base rule set (`.oxlintrc.json` loads both plugins from `src/`).
|
|
164
|
+
| Path | Contents |
|
|
165
|
+
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
166
|
+
| `src/plugin/` | the `od` plugin: one file per rule in `rules/`, shared helpers in `utils/` |
|
|
167
|
+
| `src/eslint-comments/` | the eslint-comments plugin as the presets load it (bundled into dist): upstream rules with the Oxlint fixes of `wrapper.ts` |
|
|
168
|
+
| `src/cli/` | `od-harness lint-scope`, `size`, `ratchet`, `clones`, `unused` and `baseline move` |
|
|
169
|
+
| `presets/` | consumer presets; `presets/rules/` holds the rule sets without the plugin binding |
|
|
170
|
+
| `test/` | RuleTester cases (`test/rules/*.cases.ts`), Oxlint conformance, CLI, presets, workflow tests |
|
|
171
|
+
| `docs/` | rule pages, adoption guide, decision records; upstream issue drafts (`docs/upstream/`, not packed) |
|
|
172
|
+
| `tools/ts-eslint-parser/` | tests and `scripts/hit-compare.ts` only: typescript-eslint's parser pinned to TypeScript 6 |
|
|
173
|
+
| `scripts/` | `smoke-pack.ts`, `trial.ts`, `hit-compare.ts`, `check-harness-source.ts` and `check-harness-bin.ts` |
|
|
174
|
+
|
|
175
|
+
This repository lints itself with the base rule set (`.oxlintrc.json` loads both plugins from `src/`) and, as od-platform does, the `import` and `vitest` plugins, the `suspicious` category, `typescript/no-explicit-any` and `import/no-cycle`. `vitest/valid-expect` allows Vitest's message argument (`expect(value, message)`), `vitest/expect-expect` counts helpers named `expect*` and `assert*` as assertions, and `vitest/valid-title` accepts test names taken from fixtures. `unicorn/no-array-sort` requires `toSorted()`. `vitest/no-conditional-expect` stays off because the table-driven tests only check a message in the cases that expect one. Splitting those tables would duplicate them.
|
|
130
176
|
|
|
131
177
|
## License
|
|
132
178
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Third-party licenses
|
|
2
|
+
|
|
3
|
+
Packages bundled into dist/ by the build.
|
|
4
|
+
|
|
5
|
+
## @eslint-community/eslint-plugin-eslint-comments@4.8.1 (MIT)
|
|
6
|
+
|
|
7
|
+
MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2016 Toru Nagashima
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
## escape-string-regexp@4.0.0 (MIT)
|
|
30
|
+
|
|
31
|
+
MIT License
|
|
32
|
+
|
|
33
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
34
|
+
|
|
35
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
36
|
+
|
|
37
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
38
|
+
|
|
39
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
40
|
+
|
|
41
|
+
## ignore@7.0.17 (MIT)
|
|
42
|
+
|
|
43
|
+
Copyright (c) 2013 Kael Zhang <i@kael.me>, contributors
|
|
44
|
+
http://kael.me/
|
|
45
|
+
|
|
46
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
47
|
+
a copy of this software and associated documentation files (the
|
|
48
|
+
"Software"), to deal in the Software without restriction, including
|
|
49
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
50
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
51
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
52
|
+
the following conditions:
|
|
53
|
+
|
|
54
|
+
The above copyright notice and this permission notice shall be
|
|
55
|
+
included in all copies or substantial portions of the Software.
|
|
56
|
+
|
|
57
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
58
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
59
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
60
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
61
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
62
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
63
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/cli/child-env.ts
|
|
2
|
+
function childEnv(extra) {
|
|
3
|
+
return {
|
|
4
|
+
...process.env,
|
|
5
|
+
...extra
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
function isGitHubActions() {
|
|
9
|
+
return process.env.GITHUB_ACTIONS === "true";
|
|
10
|
+
}
|
|
11
|
+
function hookEnv() {
|
|
12
|
+
return {
|
|
13
|
+
claudeProjectDir: process.env["CLAUDE_PROJECT_DIR"],
|
|
14
|
+
stopBase: process.env["OD_HARNESS_BASE"]
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export { hookEnv as n, isGitHubActions as r, childEnv as t };
|