@hailstails/hone 2.0.0-pre.1 → 2.0.0-pre.3

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/ADOPTING.md CHANGED
@@ -10,11 +10,11 @@ Hone reads `hone.config.json` in `<repo>`, runs the listed checks over every git
10
10
  node --version
11
11
  ```
12
12
 
13
- It must print `v22.18.0` or a later 22.x, or `v24.0.0` or later. A rule set of your own may write its piece modules as `.ts` files, which Hone runs with Node's built-in type stripping, so they are limited to what [Node's TypeScript support](https://nodejs.org/docs/latest-v22.x/api/typescript.html) allows: only syntax that can be erased, so no enums, no namespaces that hold values and no parameter properties; relative imports that spell the `.ts` extension; and `import type` (or `type` on each name) for anything that is only a type. Node does not strip types from files under `node_modules`, so a rule set installed as a package must ship `.js`. Also needed: git 2.24 or later and npm. `<repo>` must be a git repository, and the files to check must be committed or staged: untracked files are not checked.
13
+ It must be in the `engines.node` range that `npm view @hailstails/hone engines` prints. A rule set of your own may write its piece modules as `.ts` files, which Hone runs with Node's built-in type stripping, so they are limited to what [Node's TypeScript support](https://nodejs.org/docs/latest-v22.x/api/typescript.html) allows; Node does not strip types under `node_modules`, so a rule set installed as a package must ship `.js`. Also needed: git and npm. `<repo>` must be a git repository, and the files to check must be committed or staged: untracked files are not checked.
14
14
 
15
15
  ## 2. Install the Hone package
16
16
 
17
- Hone ships as one npm package tarball of built JavaScript, so it needs no TypeScript support from Node. It has three dependencies of its own, `zod`, `jsonc-parser` and `@eslint/plugin-kit`, each declared as a caret range starting at the version Hone is tested on, which the package manager installs from the registry. Your repository's lockfile, and any override you set, decides which release inside each range is installed, so you can take a patched release of one of them without waiting for a new Hone.
17
+ Hone ships as one npm package of built JavaScript, so it needs no TypeScript support from Node. Its own dependencies are declared as caret ranges, so your repository's lockfile, and any override you set, decides which release inside each range is installed.
18
18
 
19
19
  **The npm package is named `@hailstails/hone`.** The unscoped name `hone` on npm belongs to an unrelated package: never run `npm install hone`. The package `@hailstails/hone` installs one command, `hone`. Its tarball is named `hailstails-hone-<version>.tgz`, the file name `npm pack` gives a scoped package. Its first pre-release was released under the old name `honed`; [MIGRATING.md](MIGRATING.md#11-moving-from-honed-to-hailstailshone) says how to move from it.
20
20
 
@@ -44,7 +44,7 @@ git -C /tmp/hone-source checkout <pinned-sha>
44
44
  cd /tmp/hone-source && corepack pnpm install --frozen-lockfile && corepack pnpm run pack-package && cd -
45
45
  ```
46
46
 
47
- The last command prints `pack package: wrote <path>/artefacts/hailstails-hone-<version>.tgz`. Copy the downloaded or built tarball into `<repo>/vendor/hailstails-hone/` and commit it with a message naming the release tag or the pinned SHA. The commands in this guide are POSIX shell; on Windows run them in Git Bash.
47
+ The last command writes the tarball under `artefacts/`. Copy the downloaded or built tarball into `<repo>/vendor/hailstails-hone/` and commit it with a message naming the release tag or the pinned SHA. The commands in this guide are POSIX shell; on Windows run them in Git Bash.
48
48
 
49
49
  Install it as a development dependency of the repository root, beside the toolchain:
50
50
 
@@ -71,18 +71,9 @@ Add the two commands to the root `package.json` scripts:
71
71
 
72
72
  Options for one run go after the script name. npm needs `--` before them, as in `npm run --silent hone:check -- --base-revision origin/main`. pnpm takes them straight after the script name, as in `pnpm run --silent hone:check --base-revision origin/main`. This guide shows both wherever a command takes options.
73
73
 
74
- `hone` is the package's one command, with six subcommands: `hone check` runs the check, `hone project` writes the ESLint projection, `hone record-debt` writes the debt records of an adopting repository, for its findings and for the inline disables that hide findings (step 7a), `hone prune-debt` removes the records of debt that is paid, `hone authorise` writes an authorised location (step 7), and `hone upgrade` moves a version 1 repository to version 2 (step 10). A seventh command, `hone split-records`, belongs to version 1: on a version 2 repository it prints `load failure: not-ready-yet` and exits `2`, and `hone split-records --help` prints its version 1 help on every repository. `hone` with no subcommand, or with a name that is none of the seven, exits `2` with one `load failure: arguments-invalid` line that names all seven and points at `hone --help`, which prints the usage.
74
+ `hone --help` lists the commands, and `hone <command> --help` gives each one's options and exit codes.
75
75
 
76
- Hone runs on the toolchain the repository already uses, which the package declares as peer dependencies: `typescript` is a required peer, because every check on the `walker` engine needs it, and the ESLint packages are optional peers, needed only for checks on the `eslint` engine. npm 7 and later install a missing required peer on their own, and some other package managers only warn about one, so declare `typescript` yourself at the repository root, at the version the repository already uses, rather than let the package manager choose or skip it. Keep the versions you have; Hone supports these ranges:
77
-
78
- | Package | Needed for | Range |
79
- | --- | --- | --- |
80
- | `typescript` | any `walker` check | `>=4.8.4 <7.0.0` |
81
- | `eslint` | any `eslint` check | `^9.39.5 \|\| ^10.15.0` |
82
- | `@typescript-eslint/parser` | any `eslint` check | `^8.73.0` |
83
- | `@typescript-eslint/eslint-plugin` | any `eslint` check | `^8.73.0` |
84
-
85
- A repository that already has them in range needs nothing more. A package that is missing or out of range is named when the check runs; add it at a version inside its range and inside the range your other tooling accepts, without moving ESLint or TypeScript to another major for Hone's sake.
76
+ Hone runs on the toolchain the repository already uses, which the package declares as `peerDependencies`: `typescript` is required, because every check on the `walker` engine needs it, and the ESLint packages are optional, needed only for checks on the `eslint` engine. The supported ranges are those in the installed package's `package.json`. Declare `typescript` yourself at the repository root, at the version the repository already uses, rather than let the package manager choose or skip it. A package that is missing or out of range is named when the check runs; add it at a version inside its range, without moving ESLint or TypeScript to another major for Hone's sake.
86
77
 
87
78
  Hone finds these by Node's resolution upward from where the package is installed, so in a monorepo they must resolve from the repository root: declare them in the root `package.json` (with pnpm, `pnpm add -Dw` at the versions the packages already use), even where packages also declare their own. Yarn Plug'n'Play is not supported, because Hone resolves the toolchain through `node_modules`.
88
79
 
@@ -90,7 +81,7 @@ Commit `package.json`, the lockfile and the tarball if it is a file in the repos
90
81
 
91
82
  ## 3. Read what each discipline means
92
83
 
93
- [rules/numbers.md](rules/numbers.md#every-numbered-discipline) lists every discipline, and [rules/README.md](rules/README.md) explains how the named pages read. Rules are referred to by name; a number is only a clause address. Each check has its own page under its symptom, `rules/typescript/symptoms/<symptom>/<check>.md`: exactly what it flags, its settings, a violation and its fix. Read the named pages first; [the spirit of the rules](rules/SPIRIT.md) explains the approach for the whole set. Each check is listed in `hone.config.json` by its address, `<symptom>#<check>`, such as `authored-class-or-this#class-keyword`; the table in step 4 lists every one beside the rule's clause address, such as `CD-14#class-syntax`. A clause whose mechanism is `review` is a judgement clause: it has no check and is applied in review, with the review lens its rule item names (step 9).
84
+ [rules/numbers.md](rules/numbers.md#every-numbered-discipline) lists every discipline, and [rules/README.md](rules/README.md) explains how the named pages read. Rules are referred to by name; a number is only a clause address. Each check has its own page under its symptom, `rules/typescript/symptoms/<symptom>/<check>.md`: exactly what it flags, its settings, a violation and its fix. Read the named pages first; [the spirit of the rules](rules/SPIRIT.md) explains the approach for the whole set. Each check is listed in `hone.config.json` by its address, `<symptom>#<check>`, such as `authored-class-or-this#class-keyword`; [the checks page](rules/typescript/checks.md) lists every one. A clause whose mechanism is `review` is a judgement clause: it has no check and is applied in review, with the review lens its rule item names (step 9).
94
85
 
95
86
  A check covers only what its page says it flags. Read the whole rule, not only the check: where a rule asks for more than its check can see, the check page says which part is left to review, and the rule's review lens covers that part.
96
87
 
@@ -112,73 +103,23 @@ Create `<repo>/hone.config.json`. List every check you adopt with the engine tha
112
103
  }
113
104
  ```
114
105
 
115
- - `checks` keys are check addresses, `<symptom>#<check>`, listed in the table below and on the check pages; the value is an engine the check lists, `walker` or `eslint`, `"not-run"` or `"not-adopted"`. A check of a rule set of your own is written `<ruleSet>/<symptom>#<check>`.
106
+ - `checks` keys are check addresses, `<symptom>#<check>`, listed on [the checks page](rules/typescript/checks.md); the value is an engine the check lists, `walker` or `eslint`, `"not-run"` or `"not-adopted"`. A check of a rule set of your own is written `<ruleSet>/<symptom>#<check>`.
116
107
  - Listing a check adopts it. Only a listed check runs. A check of a symptom that a listed check sees, listed nowhere, is offered under `available` and never fails the run. The symptom [Strictness weakened](rules/typescript/symptoms.md#strictness-weakened) has seven checks, one per compiler flag; list the ones you want. Checks that are one rule today run together: listing one of the six test-body checks without the others stops the run with `checks-run-together` naming them.
117
108
  - A symptom may span engines; list each of its checks on an engine that has it, or mark it. `authored-class-or-this#class-keyword` runs on `walker` or `eslint` but `authored-class-or-this#static-members-only` only on `eslint`, so adopting that symptom means adopting the ESLint engine for at least that check; see [README.md](README.md#adopting-the-eslint-mechanism). If ESLint cannot work in this repository, list such a check as `"not-run"`, as below.
118
109
  - A check's value in `checks` is one of three:
119
110
  - an engine id, such as `walker`: the check runs and its findings fail the run;
120
- - `"not-run"`: the check is adopted, but its engine is not run; the report lists it under `not-run` as `<check> adopted, engine not run: enforced by review`;
111
+ - `"not-run"`: the check is adopted, but its engine is not run; the report lists it under `not-run`;
121
112
  - `"not-adopted"`: the check is not adopted; the report lists it under `not-adopted`.
122
113
  - A `"not-run"` or `"not-adopted"` check is never run and never projected, not even as `"off"`, and its engine is not loaded unless another check uses it, so a repository that lists every ESLint check this way needs no ESLint installed. Both leave the run a whole assessment.
123
114
  - When a check cannot simply run clean, [the spirit of the rules](rules/SPIRIT.md#not-adopted-not-run-carved-out-escaped) names three declared states. Choose one deliberately, with reasons:
124
115
  - Not adopted: the rule does not apply to this codebase; a tech lead declares that, in the open. Set the check to `"not-adopted"`.
125
116
  - Adopted, engine not run: the rule binds, but its check is not a true measure of the rule's intent here, or cannot work here for a technical reason. The check is set aside; the intent is still owed, through review. Set the check to `"not-run"`. The ESLint-only checks of `name-off-its-casing` in a repository without ESLint are the usual case: `"name-off-its-casing#naming-convention": "not-run", "name-off-its-casing#filename-case": "not-run"`.
126
117
  - Debt: the rule binds and its check is sound, but the codebase has debt it cannot address right now. Keep the check's engine, so it still runs, and record the debt file by file as debt records, which `hone record-debt` writes for you (step 7a).
127
- - `exclude` lists folders or exact files that no engine checks, as repository paths with forward slashes; an entry containing `*` is refused, because globs are not supported. A folder entry excludes everything under it. It is the only way to narrow what Hone checks: there is no include list, and every tracked file outside `exclude` is checked, including any folder added later. Use it for generated or third-party code, and, to check only part of a repository, list every other folder. The walker already skips `node_modules`, `dist`, `build`, `coverage`, `.git` and a top-level `vendor` folder. The ESLint engine lints every tracked TypeScript file outside `exclude`, including any the repository's own ESLint config ignores: an ignore in that config does not narrow what Hone checks, and each selected check lists such a file under `unrecorded` as `<check> eslint ignore <file>` until the ignore is removed or the file is listed in `exclude`.
128
- - `checkSettings` gives a check the settings its check page lists under Settings, keyed by check address. `outside-import-past-a-boundary#import-or-require`, for example, flags only imports of the packages you list in its `confinedOutsideDependencies`, which its check page still calls `confinedPackages`; `trackerPatterns` on `untracked-escape#directive-pointers` narrows tracked references to your tracker's format. See [README.md](README.md#honeconfigjson).
129
- - `checkEditions` stays out, or `"pinned"`, unless you want stricter checks as soon as they ship. When Hone tightens a check, the stricter check arrives as a new edition, listed on the check's page, and becomes the default only in a major release. `"latest"` runs the newest edition of every listed check, so a minor upgrade can add findings. To take one check's newer edition only, give it `"edition"` in its `checkSettings` entry. The report lists the edition each such check ran under `editions`.
118
+ - `exclude` lists folders or exact files that no engine checks, as repository paths with forward slashes; an entry containing `*` is refused, because globs are not supported. A folder entry excludes everything under it. It is the only way to narrow what Hone checks: there is no include list, and every tracked file outside `exclude` is checked, including any folder added later. Use it for generated or third-party code, and, to check only part of a repository, list every other folder. The ESLint engine lints every tracked TypeScript file outside `exclude`, including any the repository's own ESLint config ignores: an ignore in that config does not narrow what Hone checks, and each selected check lists such a file under `unrecorded` until the ignore is removed or the file is listed in `exclude`.
119
+ - `checkSettings` gives a check the settings its check page lists, keyed by check address. See [README.md](README.md#honeconfigjson).
120
+ - `checkEditions` stays out, or `"pinned"`, unless you want stricter checks as soon as they ship. When Hone tightens a check, the stricter check arrives as a new edition, listed on the check's page, and becomes the default only in a major release. `"latest"` runs the newest edition of every listed check, so a minor upgrade can add findings. To take one check's newer edition only, give it `"edition"` in its `checkSettings` entry.
130
121
  - `ruleSets` stays `{}` unless you write disciplines of your own; see [docs/extending.md](docs/extending.md).
131
122
 
132
- Every check Hone ships, with the engines that can run it and the clause address its rule's pages know it by:
133
-
134
- | Check to list | Engines | Clause address on the rule pages |
135
- |---|---|---|
136
- | `claimed-type#cast-to-any` | `walker` | `CD-1#any-cast` |
137
- | `untyped-value#explicit-any` | `eslint` | `CD-1#explicit-any` |
138
- | `untyped-value#implicit-any-let` | `eslint` | `CD-1#implicit-any-let` |
139
- | `claimed-type#unlisted-cast-site` | `walker` | `CD-2#cast-expressions` |
140
- | `claimed-type#non-null-assertions` | `eslint` | `CD-2#non-null-assertions` |
141
- | `strictness-weakened#strict` | `walker` | `CD-3#strict` |
142
- | `strictness-weakened#no-unchecked-indexed-access` | `walker` | `CD-3#no-unchecked-indexed-access` |
143
- | `strictness-weakened#exact-optional-property-types` | `walker` | `CD-3#exact-optional-property-types` |
144
- | `strictness-weakened#no-implicit-override` | `walker` | `CD-3#no-implicit-override` |
145
- | `strictness-weakened#no-fallthrough-cases-in-switch` | `walker` | `CD-3#no-fallthrough-cases-in-switch` |
146
- | `strictness-weakened#no-property-access-from-index-signature` | `walker` | `CD-3#no-property-access-from-index-signature` |
147
- | `strictness-weakened#use-unknown-in-catch-variables` | `walker` | `CD-3#use-unknown-in-catch-variables` |
148
- | `untracked-escape#directive-pointers` | `walker` | `CD-5#comments-directives` |
149
- | `shorthand-name#identifier-names` | `walker` | `CD-6#identifier-names` |
150
- | `name-off-its-casing#naming-convention` | `eslint` | `CD-6#naming-convention` |
151
- | `drawer-path#drawer-names` | `walker` | `CD-7#categorical-paths` |
152
- | `name-off-its-casing#filename-case` | `eslint` | `CD-7#filename-case` |
153
- | `type-derived-from-code#factory-return-types` | `walker` | `CD-7a#factory-return-types` |
154
- | `default-on-a-closed-union#default-arm` | `walker` | `CD-8#switch-defaults` |
155
- | `throw-or-catch-in-a-test#throw-statement` | `walker` | `CD-10#throws-in-tests` |
156
- | `thrown-non-error#throw-only-error` | `eslint` | `CD-10#throw-only-error` |
157
- | `authored-class-or-this#class-keyword` | `walker` or `eslint` | `CD-14#class-syntax` |
158
- | `authored-class-or-this#static-members-only` | `eslint` | `CD-14#static-only-class` |
159
- | `loop-keyword#loop-statement` | `walker` | `CD-15#loops` |
160
- | `date-used-directly#clock-sources` | `walker` | `CD-17#clock-sources` |
161
- | `outside-import-past-a-boundary#import-or-require` | `walker` | `CD-19#import-boundaries` |
162
- | `unit-without-a-running-test#companion-test-file` | `walker` | `CD-23#export-test-sibling` |
163
- | `double-with-a-body#stub-implementation` | `walker` | `CD-25#dependency-isolation` |
164
- | `module-or-global-patched#module-mock-call` | `walker` | `CD-26#module-mocking` |
165
- | `branch-in-a-test#test-body` | `walker` | `CD-27#test-body-logic` |
166
- | `throw-or-catch-in-a-test#try-block` | `walker` | `CD-27#test-body-logic` |
167
- | `rebinding#test-body` | `walker` | `CD-27#test-body-logic` |
168
- | `computed-value-in-a-test#test-body` | `walker` | `CD-27#test-body-logic` |
169
- | `text-past-its-reader#test-body` | `walker` | `CD-27#test-body-logic` |
170
- | `double-with-a-body#logic-in-a-passed-function` | `walker` | `CD-27#test-body-logic` |
171
- | `test-switched-off#focused-tests` | `eslint` | `CD-27#focused-tests` |
172
- | `test-switched-off#skipped-tests` | `eslint` | `CD-27#skipped-tests` |
173
- | `positional-parameters#parameter-count` | `eslint` | `CD-40#parameter-count` |
174
- | `tangled-function#cognitive-complexity` | `eslint` | `CD-41#cognitive-complexity` |
175
- | `long-function#function-length` | `eslint` | `CD-41#function-length` |
176
- | `work-inside-a-condition#else-after-an-exit` | `eslint` | `CD-42#useless-else` |
177
- | `boolean-in-a-signature#boolean-annotation` | `walker` | `CD-43#boolean-signatures` |
178
- | `write-into-a-parameter#parameter-mutation` | `walker` | `CD-44#parameter-mutation` |
179
- | `rebinding#parameter-reassignment` | `eslint` | `CD-44#parameter-reassignment` |
180
- | `inherited-environment-in-a-subprocess#git-spawn-environment` | `walker` | `CD-47#hermetic-git-spawns` |
181
-
182
123
  Adopting a symptom with a check whose only engine is `eslint` needs the ESLint engine, or that check listed as `"not-run"`.
183
124
 
184
125
  Starting with a few disciplines and adding more once the run passes is easier than fixing everything at once.
@@ -191,7 +132,7 @@ Skip this if every listed check runs on the `walker`. Otherwise, after writing `
191
132
  npm run --silent hone:project
192
133
  ```
193
134
 
194
- It prints `hone.eslint.mjs written` and `hone.eslint.d.mts written`; the second file types the first as ESLint's `Linter.Config[]`, so a TypeScript config can import it. Spread its default export last in the repository's flat config. The projection sets rules only, so the config must also parse TypeScript, with the `@typescript-eslint/parser` that step 2 installs; without it the repository's own `eslint` run fails on the first type annotation while Hone's check still passes. A repository with no ESLint config yet can start from this `eslint.config.mjs`:
135
+ It writes `hone.eslint.mjs` and `hone.eslint.d.mts`, which types it for a TypeScript config. Spread its default export last in the repository's flat config. The projection sets rules only, so the config must also parse TypeScript, with the `@typescript-eslint/parser` that step 2 installs; without it the repository's own `eslint` run fails on the first type annotation while Hone's check still passes. A repository with no ESLint config yet can start from this `eslint.config.mjs`:
195
136
 
196
137
  ```js
197
138
  import typescriptParser from "@typescript-eslint/parser";
@@ -205,7 +146,7 @@ export default [
205
146
 
206
147
  To confirm it, run the repository's own `eslint` on one TypeScript file with a type annotation, for example `node_modules/.bin/eslint src/index.ts` with a file of your own; it must report findings or nothing, never `Parsing error`.
207
148
 
208
- In a monorepo where ESLint resolves each file from its nearest config, `hone:project` also writes a `hone.eslint.mjs` slice, with its `hone.eslint.d.mts` declaration of the type, beside each package's tracked `eslint.config.*`, holding only that package's records with paths relative to the package. Where one ESLint 9 run applies the root config to every file, package configs are never loaded and get no slice. A package config keeps its slice even in a folder the root config ignores, since a lint run from that package loads its own config without the root's ignores. A folder holding its own `hone.config.json` is a nested Hone configuration, which is not supported yet ([#72](https://github.com/HailsTails/hone/issues/72)): when the ESLint engine would check a file under it, `check` and `project` stop with `load failure: not-ready-yet eslint-config-roots: this release does not run a repository that holds other version 2 repositories yet; …` before anything is checked or written, and the line says to move the folder out and run it on its own with `--repo`. A run that lists only walker checks does not stop, and a folder with no such file gets no slice. The root config spreads the root projection last, and each package config spreads its own slice last, never the root one:
149
+ In a monorepo where ESLint resolves each file from its nearest config, `hone:project` also writes a `hone.eslint.mjs` slice, with its `hone.eslint.d.mts` declaration of the type, beside each package's tracked `eslint.config.*`, holding only that package's records with paths relative to the package. Where one ESLint 9 run applies the root config to every file, package configs are never loaded and get no slice. A package config keeps its slice even in a folder the root config ignores, since a lint run from that package loads its own config without the root's ignores. A folder holding its own `hone.config.json` is a nested Hone configuration, which is not supported yet ([#72](https://github.com/HailsTails/hone/issues/72)): when the ESLint engine would check a file under it, `check` and `project` stop before anything is checked or written, and say to move the folder out and run it on its own with `--repo`. A run that lists only walker checks does not stop, and a folder with no such file gets no slice. The root config spreads the root projection last, and each package config spreads its own slice last, never the root one:
209
150
 
210
151
  ```js
211
152
  import projection from "./hone.eslint.mjs";
@@ -216,7 +157,7 @@ export default [
216
157
  ];
217
158
  ```
218
159
 
219
- A package whose `eslint.config.*` is generated and not tracked needs its folder listed so Hone writes its slice, and the slice spread where the tool takes extra configuration. Each listed folder must be one git tracks files under, spelled exactly as git spells it, or the check stops with `config-root-untracked`. sku 16.6.1 is such a tool: its `packages/sku/src/utils/configureApp.ts` writes `eslint.config.mjs` into the project on every sku command and adds it to `.gitignore`, and that config applies the `dangerouslySetESLintConfig` function that `packages/sku/src/types/types.ts` declares as taking and returning `Linter.Config[]`. For sku, list the package in `hone.config.json` and spread the slice in `sku.config.ts`:
160
+ A package whose `eslint.config.*` is generated and not tracked needs its folder listed so Hone writes its slice, and the slice spread where the tool takes extra configuration. Each listed folder must be one git tracks files under, spelled exactly as git spells it, or the check stops. sku is such a tool: it writes an ignored `eslint.config.mjs` on every command and applies `dangerouslySetESLintConfig` to it. For sku, list the package in `hone.config.json` and spread the slice in `sku.config.ts`:
220
161
 
221
162
  ```json
222
163
  { "eslintConfigRoots": ["packages/web"] }
@@ -230,7 +171,7 @@ export default {
230
171
  };
231
172
  ```
232
173
 
233
- The check names a slice that is missing or out of date, and names a listed folder whose `eslint.config.*` is not on disk as `unconfigured`: until the tool has written it, nothing loads the slice, so run the tool's configure step (for sku, any sku command or `sku configure`) before the check. A package that spreads nothing at all has its checks out of effect at once, and the check reports `engine-not-run eslint not-included` rather than trust what it could not have measured. A package that spreads the root projection instead of its slice is reported the same way only once a record answers a file in it; until then both projections give it the same rules, so the check says nothing, and silence is not proof the spread is right. To confirm the spread before recording debt, run ESLint from the package folder on a file the check flags and see the same finding. [README.md](README.md#package-slices) has the details. Hone detects which config the team's ESLint run applies from the installed `eslint` version and the lint scripts; see [README.md](README.md#runtime). Detection is wrong when a task runner (turbo, nx, `pnpm -r`) starts ESLint 9 inside each package, because each package then uses its own config, and when ESLint 9 gets the lookup flag outside the scripts. In those repositories set the lookup in `hone.config.json`:
174
+ Run the tool's configure step (for sku, any sku command or `sku configure`) before the check, or nothing loads the slice. A package that spreads the root projection instead of its slice is reported only once a record answers a file in it, so silence is not proof the spread is right: run ESLint from the package folder on a file the check flags and see the same finding. [README.md](README.md#package-slices) has the details. Hone detects which config the team's ESLint run applies from the installed `eslint` version and the lint scripts; see [README.md](README.md#runtime). Detection is wrong when a task runner (turbo, nx, `pnpm -r`) starts ESLint 9 inside each package, because each package then uses its own config, and when ESLint 9 gets the lookup flag outside the scripts. In those repositories set the lookup in `hone.config.json`:
234
175
 
235
176
  ```json
236
177
  { "eslintConfigLookup": "nearest-to-file" }
@@ -238,7 +179,7 @@ The check names a slice that is missing or out of date, and names a listed folde
238
179
 
239
180
  Use `"nearest-to-file"` when ESLint runs per package, with ESLint 10, or with ESLint 9 and `--flag v10_config_lookup_from_file`. Use `"repository-root"` for one ESLint 9 run from the repository root, whose root `eslint.config.*` then applies to every file. To confirm the setting, lint a package file the way the team does (for example `pnpm exec eslint packages/a/src/x.ts` from where the lint script runs) and check that it reports the same finding the Hone check lists for that file.
240
181
 
241
- Commit the projection, every slice and the configs. Hone's check reads this configuration and fails if the projection or a slice is missing, not in effect, or out of date, so re-run `hone:project` whenever `hone.config.json` or `hone-records` changes or Hone is updated. The projection imports one plugin, `@hailstails/hone/eslint-plugin`, registered under the namespace `hone`, so the repository's ESLint must resolve `@hailstails/hone` from the repository root. Hone's own ESLint run uses the repository's root `eslint` from step 2, the same copy the projection's pieces load; its verdict is the same on 9.x and 10.x. [README.md](README.md#adopting-the-eslint-mechanism) has the details.
182
+ Commit the projection, every slice and the configs. Hone's check reads this configuration and fails if the projection or a slice is missing, not in effect, or out of date, so re-run `hone:project` whenever `hone.config.json` or `hone-records` changes or Hone is updated. The repository's ESLint must resolve `@hailstails/hone` from the repository root. [README.md](README.md#adopting-the-eslint-mechanism) has the details.
242
183
 
243
184
  ## 5. Run the check
244
185
 
@@ -246,13 +187,7 @@ Commit the projection, every slice and the configs. Hone's check reads this conf
246
187
  npm run --silent hone:check
247
188
  ```
248
189
 
249
- | Exit code | Meaning |
250
- | --- | --- |
251
- | `0` | `verdict: pass` |
252
- | `1` | `verdict: fail`: the report says why |
253
- | `2` | an input could not be loaded or a check crashed; the output is one line starting `load failure:` or names the failing piece |
254
-
255
- `npm run` passes the exit code through. `sh: hone: not found` or `'hone' is not recognized` means step 2's install is missing; run `npm install`. A `load failure: engine-failed <engine> toolchain-unavailable <package> ...` line names every toolchain package that is missing from the repository root or outside its range; install a version of each in the range it prints. For a `typescript` that is not installed, the line says the install is incomplete, since a supported install always has its required peer: add `typescript` to the root's `devDependencies` and reinstall. An `engine-failed <engine> toolchain-shadowed <package> resolved from ...` line means a copy of that package sits inside Hone's own install folder, which the line names: delete that `node_modules` folder and reinstall.
190
+ It exits `0` on `verdict: pass`, `1` on `verdict: fail` and `2` when an input cannot be loaded; [docs/output-contract.md](docs/output-contract.md) has every exit code and line. `npm run` passes the exit code through. `sh: hone: not found` or `'hone' is not recognized` means step 2's install is missing. A load failure that names a toolchain package says what to install or delete.
256
191
 
257
192
  Add the check to the repository's existing validation script, and run that script in CI and in any pre-push hook the repository already has, so the check runs wherever the other checks run.
258
193
 
@@ -270,7 +205,7 @@ With pnpm:
270
205
  pnpm run --silent hone:check --forfeiture this-run --base-revision origin/main
271
206
  ```
272
207
 
273
- A run that leaves forfeiture to another run ends `verdict: pass (partial assessment)` or `verdict: fail (partial assessment)`, not `verdict: pass` or `verdict: fail`. A hook or gate that matches `verdict: pass` or `verdict: fail` at the end of the line reads neither, and may report the run as unverified. Act on the exit code, or match all four verdict lines that [docs/output-contract.md](docs/output-contract.md#the-version-2-report) lists.
208
+ A run that leaves forfeiture to another run marks its verdict line as a partial assessment. Act on the exit code, or match every verdict line [docs/output-contract.md](docs/output-contract.md#the-version-2-report) lists.
274
209
 
275
210
  CI leaves forfeiture to the hook, and with `elsewhere` in effect it can run the check with no base revision:
276
211
 
@@ -278,7 +213,7 @@ CI leaves forfeiture to the hook, and with `elsewhere` in effect it can run the
278
213
  npm run --silent hone:check
279
214
  ```
280
215
 
281
- Records carried over by `hone upgrade` follow the same setting. A run given no base leaves them to the run that has one: it prints `carried standing elsewhere` with how many, and passes as a partial assessment when nothing else fails. A run given a base judges them against it, whatever `forfeiture` says. So keep at least one run that has a base, the pre-push hook above, or they are never judged. If CI should judge them too, pass the pull request's base commit; the base is then used for those records only, and no debt is forfeited. CI needs that one commit fetched, for example `git fetch --depth=1 origin <base-commit>`, not the full history:
216
+ Records carried over by `hone upgrade` follow the same setting. A run given no base leaves them to the run that has one, and says so. A run given a base judges them against it, whatever `forfeiture` says. So keep at least one run that has a base, the pre-push hook above, or they are never judged. If CI should judge them too, pass the pull request's base commit; the base is then used for those records only, and no debt is forfeited. CI needs that one commit fetched, for example `git fetch --depth=1 origin <base-commit>`, not the full history:
282
217
 
283
218
  ```bash
284
219
  npm run --silent hone:check -- --base-revision <base-commit>
@@ -345,42 +280,9 @@ A finished section reads like this, for the check `claimed-type#unlisted-cast-si
345
280
 
346
281
  ## 6. Read the report
347
282
 
348
- The report prints only the sections that have entries, each with its count, then the verdict. A finding line names the check that raised it, the engine, the place and the snippet, then what the check may indicate and, where it names one, the fix:
283
+ The report prints only the sections that have entries, each with its count, then the verdict. A finding names the check, the engine, the place and the snippet, what the check may indicate and, where it has one, the fix. Each other line says what to do about it. [docs/output-contract.md](docs/output-contract.md#the-version-2-report) lists every section in the order it prints, which sections fail the run, and every line. The `symptoms` section, printed last, explains each symptom the findings name.
349
284
 
350
- ```text
351
- <check> <engine> <file>:<line>:<column> <snippet> may indicate: <indicated>
352
- <check> <engine> <file>:<line>:<column> <snippet> may indicate: <indicated> fix: <fix> (<fix page>#<section>)
353
- loop-keyword#loop-statement walker src/basket.ts:15:0 for (const line of this.lines) { may indicate: no-hidden-effects, ports-declared-inside, doer-or-orchestrator
354
- ```
355
-
356
- A finding of a clause the symptom catalogue gives no check, such as one from a rule set of your own, prints its clause address and its mechanism, without the indication.
357
-
358
- [docs/output-contract.md](docs/output-contract.md#the-version-2-report) lists every line the report can print, exactly as printed, and which parts are stable. Lines are 1-based and columns 0-based. The run passes only when every failing section is empty. The sections, in the order they print, are:
359
-
360
- | Section | Meaning and what to do |
361
- | --- | --- |
362
- | `excluded` | the `exclude` entries from `hone.config.json` that were left out of the run; informational, check it is what you meant |
363
- | `not-adopted` | the checks `hone.config.json` lists as `"not-adopted"`; informational, they were neither run nor projected |
364
- | `not-run` | the checks `hone.config.json` lists as `"not-run"`, each as `<check> adopted, engine not run: enforced by review`; informational, they were neither run nor projected, and the rule is still owed through review |
365
- | `editions` | each check with more than one edition, with the edition that ran and the latest; informational, see `checkEditions` in [step 4](#4-write-honeconfigjson) |
366
- | `findings` | violations: fix the code, or answer them with a record (step 7) |
367
- | `answered` | findings a record answers, each with the record that answers it; informational |
368
- | `available` | a check no setting lists whose symptom a listed check sees; informational, list it in `hone.config.json` with an engine to run it |
369
- | `stale` | a record that answers no finding and holds no native exception, which says why when it is debt: nothing it holds is found, its file is gone, or its file is excluded. Debt is removed by the `hone prune-debt` command its line names; run it, then `npm run --silent hone:project`. Delete every other stale record by hand ([README.md](README.md#pruning-paid-debt)) |
370
- | `forfeited` | debt on a file this change touched, which no longer answers: fix the file; `hone prune-debt` then removes the record |
371
- | `unrecorded` | a native exception no record holds, as `<check> <engine> <kind> <detail>`: remove it, or record it where step 7 allows. An inline disable, an `eslint-disable` naming no rule, and a lint-script option each print their own line; [README.md](README.md#commands) lists them. A lint-script option weakens the script's whole run, so no record can cover it: remove it from the script |
372
- | `misnamed` | an inline disable naming a version 1 rule id, or an id no check of this run has, which suppresses nothing: name the rule the check now has |
373
- | `paid` | debt that another record answers in place of, for a finding this run raised, with the exact `hone prune-debt` command that removes it; informational next step, it never fails the run |
374
- | `refused` | a record that cannot be read or applied, with the reason: correct or delete it |
375
- | `unmeasured` | something could not be measured; each line says what, why and what Hone needs, for example `forfeiture-unmeasured no-base-revision: no --base-revision was given, so debt cannot be checked for forfeiture; pass --base-revision with the branch's base, such as origin/main, or leave forfeiture to another run with "forfeiture": "elsewhere" in hone.config.json or --forfeiture elsewhere` |
376
- | `projection-problems` | a projection or package slice that differs from what `hone project` writes now, is not written, is not in effect, or has no configuration to load it, each with what to do, for example `eslint out-of-date: hone.eslint.mjs differs from what hone project writes now; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit every file it writes` |
377
- | `assessment` | a concern this run left to another run, for example `forfeiture elsewhere: 37 debt records not checked for forfeiture in this run`; informational, and the verdict line then reads `verdict: pass (partial assessment)` or `verdict: fail (partial assessment)` |
378
- | `settings-notes` | what `hone.config.json` declares that no check reads yet; informational |
379
- | `record-notes` | a note on a record, such as a case or an `owes` the catalogue does not list, by its records file and index; informational |
380
- | `carried` | records `hone upgrade` carried from version 1, with what each lacks and whether the base held them; informational, see [MIGRATING.md](MIGRATING.md#20-moving-from-version-1-to-version-2) |
381
- | `symptoms` | printed last, one note for each symptom the findings name: what it may indicate, where the breach usually sits, the recipes that answer it, its correct uses and where to record each, and the page that explains it; guidance, it never fails the run |
382
-
383
- To print less, set `"reportOutput"` in `hone.config.json` for the repository, or pass `--report-output <output>` for one run, which wins over the file. `full` is the default and prints the report above; `actionable` leaves out the informational sections and keeps the failing, next-step and guidance ones; `counts` prints only each section's heading and count, adding `informational`, `next-step` or `guidance` after the sections that never fail the run so every other line names a section that failed it; `verdict-only` prints only the verdict line. Every output ends in the verdict line, and the exit code is the same whichever output you choose. An unknown value fails the run with exit `2`, as `arguments-invalid` for the option or `file-malformed` for the file.
285
+ To print less, set `"reportOutput"` in `hone.config.json`, or pass `--report-output` for one run. The verdict and exit code are the same whichever output you choose.
384
286
 
385
287
  ## 7. Record what a check cannot be made to accept
386
288
 
@@ -441,8 +343,8 @@ A repository with existing code usually has more findings than the change that a
441
343
  node_modules/.bin/hone record-debt --repo . --base-revision origin/main --leave src/clock.ts --leave src/adapters
442
344
  ```
443
345
 
444
- It prints one line per finding and per native exception under `unrecorded`. `recorded` lines are records it added to `hone-records`. `left` lines are files under a `--leave` path: write their records now, each with its own reason. `touched` lines are files this change created or changed: fix them, or record them yourself with a reason of your own. `already-recorded` and `unrecordable` lines say why nothing was written, and each `unrecordable` line says what to do instead; for an `ignore` it is to remove the ignore, or to list a generated or vendored file in `exclude` so that Hone's setting and the team's ignore agree; [README.md](README.md#recording-inherited-debt) has the details. When it recorded anything, a last line names the `hone project` command that puts the records into effect, which point 5 runs.
445
- 5. **Re-project and check against the same base.** With any `eslint` check, run `npm run --silent hone:project`. Then run `npm run --silent hone:check -- --forfeiture this-run --base-revision origin/main` (with pnpm, `pnpm run --silent hone:check --forfeiture this-run --base-revision origin/main`). `--forfeiture this-run` makes this run assess forfeiture whatever `forfeiture` says, as the run that assesses it for your repository does: the pre-push hook with `"forfeiture": "elsewhere"` (step 5), or CI without it. A `forfeited` line names a file this change edits: go back to point 3 for it. A check against `HEAD` hides those lines, because nothing has changed since `HEAD`, and the hook or CI then fails where this run passed. The generated records cover the findings and the inline disables and directives that hide them, so what stays under `unrecorded` is what no record can hold: an `ignore`, a `suppression-entry`, an inline rule configuration, a `config-override` or a lint-script option. Each has an `unrecordable` line from point 4 that says what to do about it. For an `ignore`, the findings in the file are already recorded, so removing it hides nothing, and a generated or vendored file can instead be listed in `exclude` so that Hone's setting and the team's ignore agree; for a `suppression-entry`, the findings in the file are already recorded, so removing it hides nothing; for a `config-override`, remove it or narrow it to the files that need it.
346
+ It prints one line per finding and per native exception, saying what it recorded and, for each it did not, why and what to do instead. Files under a `--leave` path need their records written now, each with its own reason. Files this change created or changed need fixing, or a record with a reason of your own.
347
+ 5. **Re-project and check against the same base.** With any `eslint` check, run `npm run --silent hone:project`. Then run `npm run --silent hone:check -- --forfeiture this-run --base-revision origin/main` (with pnpm, `pnpm run --silent hone:check --forfeiture this-run --base-revision origin/main`). `--forfeiture this-run` makes this run assess forfeiture whatever `forfeiture` says, as the run that assesses it for your repository does: the pre-push hook with `"forfeiture": "elsewhere"` (step 5), or CI without it. A `forfeited` line names a file this change edits: go back to point 3 for it. A check against `HEAD` hides those lines, because nothing has changed since `HEAD`, and the hook or CI then fails where this run passed. What stays under `unrecorded` is what no record can hold; point 4's line for each says what to do.
446
348
  6. **Review the diff.** Nothing takes effect until you commit it. Each generated record is debt holding only its symptom, check and file: inherited debt that nobody has reviewed, and the reviewer of the adopting change reads it as that. Note them in each check's Debt line in `disciplines.assessment.md`.
447
349
 
448
350
  The records are the same as any other debt record: each is forfeited once its file changes, which is how the debt is paid down. A file with no earlier revision gets no record, because it has no debt to inherit. The command is for adoption, but it does not refuse to run again: forfeiture already stops it turning new findings into debt, since a record written for a file just changed is forfeited by the next check that assesses forfeiture. That holds only where forfeiture is assessed. With `"forfeiture": "elsewhere"` (step 5), it is assessed only by the run that the repository leaves it to, such as the pre-push hook, so a push that bypasses that run lets such a record through until a later run assesses it.
@@ -464,7 +366,7 @@ git add src/discipline-probe.ts
464
366
  npm run --silent hone:check
465
367
  ```
466
368
 
467
- It must exit `1` with a line starting `date-used-directly#clock-sources walker src/discipline-probe.ts:1:0 const probeStartedAt = Date.now();` among its findings. Change the same file to `const probeStartedAt = 0;`, stage it, and run the check again: that finding must be gone. Then remove the probe with `git rm -f src/discipline-probe.ts`. A run that never showed the finding proves nothing: check that the file was staged and is not under an `exclude` entry. For another discipline, take a flag case from its `rules/<ID>/discipline.json`.
369
+ It must exit `1` with a `date-used-directly#clock-sources` finding at `src/discipline-probe.ts:1`. Change the same file to `const probeStartedAt = 0;`, stage it, and run the check again: that finding must be gone. Then remove the probe with `git rm -f src/discipline-probe.ts`. A run that never showed the finding proves nothing: check that the file was staged and is not under an `exclude` entry. For another check, take a flagged form from its check page.
468
370
 
469
371
  ## 9. Apply the judgement rules
470
372
 
@@ -486,76 +388,8 @@ To update, on a branch, read [the changelog](https://github.com/HailsTails/hone/
486
388
 
487
389
  To remove, run `npm uninstall @hailstails/hone`, delete the two `hone:` scripts, any vendored tarball, `hone.config.json`, `hone-records`, `disciplines.assessment.md` and, with `eslint` checks, `hone.eslint.mjs`, `hone.eslint.d.mts`, every package slice and their spread in the flat config, and take the check out of the validation script.
488
390
 
489
- ## Worked example
490
-
491
- In the Hone source repository, `tests/test-fixtures/walkthrough/` is a small repository before and after its fix, and a test runs both through the shipped `hone check` and requires the reports below, and the two files shown, to be what it prints. It lists `claimed-type#unlisted-cast-site` and `claimed-type#cast-to-any`, `loop-keyword#loop-statement`, `date-used-directly#clock-sources` and `unit-without-a-running-test#companion-test-file` on the walker, with the ESLint-only `claimed-type#non-null-assertions` listed as `"not-run"`, because the repository has no ESLint, and a `generated/` folder excluded:
492
-
493
- ```json
494
- {
495
- "version": 2,
496
- "ruleSets": {},
497
- "checks": {
498
- "claimed-type#cast-to-any": "walker",
499
- "claimed-type#unlisted-cast-site": "walker",
500
- "claimed-type#non-null-assertions": "not-run",
501
- "loop-keyword#loop-statement": "walker",
502
- "date-used-directly#clock-sources": "walker",
503
- "unit-without-a-running-test#companion-test-file": "walker"
504
- },
505
- "exclude": ["generated"]
506
- }
507
- ```
508
-
509
- Before, `npm run --silent hone:check` prints, and exits `1`:
510
-
511
- ```text
512
- excluded (1)
513
- generated
514
- not-run (1)
515
- claimed-type#non-null-assertions adopted, engine not run: enforced by review
516
- findings (5)
517
- date-used-directly#clock-sources walker src/basket.ts:7:0 private openedAt = Date.now(); may indicate: ports-declared-inside, written-out-answers, doer-or-orchestrator
518
- claimed-type#unlisted-cast-site walker src/basket.ts:10:20 entry as Line); } total(): string { let pence = 0; for (const line … may indicate: declared-not-asserted, straight-through-tests, handed-what-it-uses
519
- loop-keyword#loop-statement walker src/basket.ts:15:0 for (const line of this.lines) { may indicate: no-hidden-effects, ports-declared-inside, doer-or-orchestrator
520
- date-used-directly#clock-sources walker src/basket.ts:22:0 return Date.now() - this.openedAt; may indicate: ports-declared-inside, written-out-answers, doer-or-orchestrator
521
- unit-without-a-running-test#companion-test-file walker src/utils/format.ts:1:0 missing co-located *.test.ts(x) sibling may indicate: tested-where-its-owned
522
- symptoms (4)
523
- date-used-directly: Date used directly. May indicate: needs the current time, a random value, a new id or an outside ordering → Ports declared inside, Written-out answers; does one job → Doer or orchestrator. The breach usually sits in the unit that should be passed the time, often a doer doing two jobs. Recipe: World values through a port. Correct use: a boundary record on the clock adapter. Known debt: debt. Read node_modules/@hailstails/hone/rules/typescript/symptoms.md#date-used-directly
524
- claimed-type: Claimed type. May indicate: gives a value its type (declares it, or needs it narrower) → Declared, not asserted; checks a value that may be one of several outcomes → Straight-through tests; gives a value its type (declares it, or needs it narrower): in a test, a cast to build an input → Handed what it uses. The breach usually sits in the declaration: an input too wide, a generic not bounded, a missing parse. Recipes: Fix the declaration, not the value; Assert to narrow; One argument object. Correct use: an authorised location in the adapter whose outside contract forces it. Known debt: debt. Read node_modules/@hailstails/hone/rules/typescript/symptoms.md#claimed-type
525
- loop-keyword: Loop keyword. May indicate: makes a new value from what it has → No hidden effects; causes an effect (writes, logs, sends, exits) → Ports declared inside; coordinates other units → Doer or orchestrator. The breach usually sits in the unit. Recipe: Functional iteration. Draining a stream: an authorised location in its source's adapter. Known debt: debt. Read node_modules/@hailstails/hone/rules/typescript/symptoms.md#loop-keyword
526
- unit-without-a-running-test: Unit without a running test. May indicate: gives each unit its test → Tested where it's owned. The breach usually sits in the missing test. Recipe: Companion test file. Known debt: debt. Read node_modules/@hailstails/hone/rules/typescript/symptoms.md#unit-without-a-running-test
527
- verdict: fail
528
- ```
529
-
530
- The reports name the pages from an installed package, `node_modules/@hailstails/hone/rules/typescript/symptoms.md`; a run from the source repository names them from there.
531
-
532
- The fix replaces the `Basket` class with functions over a readonly `Basket` value, sums with `reduce`, takes the time from an injected `Clock`, types the input instead of casting it, moves `src/utils/format.ts` to `src/format.ts` with a `src/format.test.ts` sibling, and records `src/clock.ts`, the one adapter that reads `Date.now()`, as a boundary record in `hone-records/boundary-records.json`:
533
-
534
- ```json
535
- {
536
- "version": 2,
537
- "records": [
538
- { "module": "src/clock.ts", "outsideParty": "runtime:clock", "ports": ["Clock"] }
539
- ]
540
- }
541
- ```
542
-
543
- After, the same command prints, and exits `0`:
544
-
545
- ```text
546
- excluded (1)
547
- generated
548
- not-run (1)
549
- claimed-type#non-null-assertions adopted, engine not run: enforced by review
550
- answered (1)
551
- date-used-directly#clock-sources walker src/clock.ts:3:0 export const createSystemClock = (): Clock => ({ now: () => Date.now() }); answered by boundary-record runtime:clock
552
- verdict: pass
553
- ```
554
-
555
391
  ## Known gaps
556
392
 
557
- - The worked example uses only the walker engine. The ESLint consumer in `tests/test-fixtures/consumer-proof/eslint/` is the tested ESLint setup.
558
393
  - Each check flags exactly what its page says and no more. Where a rule asks for more than its check can see, the page says which part is left to review.
559
- - A snippet is the text the check reports; some checks report a fixed-width window that runs across lines, as `claimed-type#unlisted-cast-site` does above. No snippet is longer than 200 characters: a longer one is cut and ends in `…`. An ESLint finding on a line longer than that, such as a bundled or minified file, shows the line from the finding's column.
560
394
  - A broken nested `eslint.config.*` in a folder the root config ignores, such as fixtures under `ignores: ["fixtures/**"]`, does not stop the check: those files are reported as `ignore` native exceptions, as the team's own `eslint .` never loads that config. One pattern shape is taken for a folder ignore although it is not one: an ignore matching every entry directly inside the folder, such as `gen/*`, where the team's ESLint still enters `gen` and fails on its broken config.
561
395
  - The disciplines' IDs and rule text come from one team's code-discipline set. Selecting a subset is supported; editing a shipped rule is not. Write your own rule set for different rules, following [docs/extending.md](docs/extending.md).
package/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  Every release of Hone, newest first. `pnpm run release-pull-request` writes each new section from the commits merged to `main` since the previous release tag, whose subjects are the squash-merged pull request titles; README.md's Compatibility section says what each kind of release may change. The sections below were written by hand from the merged pull requests when the changelog started.
4
4
 
5
+ ## 2.0.0-pre.3
6
+
7
+ ### Fixes
8
+
9
+ - index records, measurements and declarations once instead of rescanning per hit (#365)
10
+
11
+ ## 2.0.0-pre.2
12
+
13
+ ### Fixes
14
+
15
+ - hone upgrade carries a carve-out that only held up a native suppression as debt (#352)
16
+ - hone upgrade points a 1.x projection's plugin imports at the 2.0 modules before its version 1 run (#353)
17
+
18
+ ### Other changes
19
+
20
+ - pages stop restating the code, and prose-pinning tests go (#347)
21
+
5
22
  ## 2.0.0-pre.1
6
23
 
7
24
  ### Breaking changes
package/MIGRATING.md CHANGED
@@ -403,47 +403,19 @@ Version 2 keeps its settings in `hone.config.json`, its records in the `hone-rec
403
403
  node_modules/.bin/hone upgrade --repo .
404
404
  ```
405
405
 
406
- It runs version 1 over your repository, plans the version 2 files, writes them, runs version 2 and compares the two runs. A version 1 `reportOutput` of `failures-only` is written as `actionable`, its version 2 name, and `--report-output failures-only` is refused on a version 2 repository. Only when they agree does it remove the version 1 files. If they do not, it changes nothing. A refusal prints `Nothing was changed.` except the two that [Refusals you may meet](#refusals-you-may-meet) marks, which come from version 1's own `project`, and except one that came after files were written and could not put them all back, which lists those files instead.
406
+ It runs version 1 over your repository, plans the version 2 files, writes them, runs version 2 and compares the two runs. A version 1 `reportOutput` of `failures-only` is written as `actionable`, its version 2 name, and `--report-output failures-only` is refused on a version 2 repository. Only when they agree does it remove the version 1 files. If they do not, it changes nothing. Each refusal states whether anything was changed, and lists any file it could not put back; [the output contract](docs/output-contract.md#hone-upgrade) lists every refusal.
407
407
  3. **Commit** what the upgrade wrote and removed, as its own commit after the install: the version 2 files together with the removal of the version 1 files, `git add .`, then your commit. That includes each `hone.eslint.d.mts`, which the check compares with what `hone project` writes and reports under `projection-problems` when it is missing or out of date.
408
408
 
409
- After the upgrade, `hone split-records` is not run on version 2 files: it prints `load failure: not-ready-yet split-records: this release runs split-records on version 1 files only, and this repository holds hone.config.json`, and the records stay in `hone-records`. Before it, version 1's `hone authorise` sends you here with `load failure: upgrade-needed disciplines.json: this is a version 1 file; run <upgrade command>, which rewrites every version 1 file as version 2, and commit what it writes`.
409
+ After the upgrade, `hone split-records` does not run on version 2 files, and the records stay in `hone-records`. Before it, version 1's `hone authorise` stops and sends you here.
410
410
  4. **Run the check with a base revision in at least one run, in CI at least,** for example `npm run --silent hone:check -- --base-revision origin/main`, where the script passes everything after `--` to `hone check`. The report a version 1 reader knew reads a little differently: `exempted` is now `answered`, and `carried` is a section of its own, listing the records the upgrade carried over. The records carried over follow the `forfeiture` setting, as debt does. With the default, `this-run`, every run needs `--base-revision` while a carried record or any debt exists: without one the run prints `forfeiture-unmeasured no-base-revision` when debt exists, first, and `import-unmeasured no-base-revision` when carried records exist, and fails, a bare local check or a hook that passes no base included. With `"forfeiture": "elsewhere"` a run that is given no base leaves the carried records to the run that has one, prints `carried standing elsewhere` with how many, and passes as a partial assessment when nothing else fails. A run with debt also prints `forfeiture elsewhere: <n> debt records not checked for forfeiture in this run` under `assessment`, which is the same setting at work on debt. A run that is given a base judges the carried records against it, but still does not check debt for forfeiture: it still prints that `forfeiture elsewhere` line and still ends `verdict: pass (partial assessment)`, or `verdict: fail (partial assessment)` when something else fails. Some run must assess forfeiture, and the run that does is the one with `"forfeiture": "this-run"`, the default, or `--forfeiture this-run`, given a base. A base that is given and cannot be read still prints `import-unmeasured base-git-failed` and fails under either setting. If no run is ever given a base, carried records are never judged, so keep one run that has it. A second `hone upgrade` prints `already on version 2; nothing to upgrade` and exits `0`.
411
411
 
412
412
  ### What the upgrade prints
413
413
 
414
- On success it exits `0` and prints these lines, in this order:
415
-
416
- - `upgraded to version 2`.
417
- - `wrote <file>`: `hone.config.json`, each records file under `hone-records/`, each `hone.eslint.mjs` and each `hone.eslint.d.mts`, one for each projection folder, which types the projection beside it. Commit them all.
418
- - `rewrote <file>`: each ESLint config of yours that imported a version 1 projection, now importing the version 2 one.
419
- - `removed <path>`: each version 1 file and folder, which are `disciplines.json`, the `disciplines.eslint.mjs` files, and every file and folder of `discipline-exceptions.json` or `discipline-exceptions/`.
420
-
421
- The paths are relative to `--repo`.
422
-
423
- A refusal exits `1` and prints `upgrade refused:` and one or more lines saying what to do. Every refusal but the two below ends with `Nothing was changed.`. If a refusal came after files were written and one could not be put back, it prints `These files could not be put back; put them right by hand:` and lists each in place of that line: delete a file or folder the upgrade created, and restore a file it replaced from version control.
424
-
425
- Exit `3` prints `upgrade incomplete:`. Version 2 is in place, and some version 1 files could not be removed. The output lists every version 1 file still present: delete them by hand, then commit. While `disciplines.json` is still beside `hone.config.json`, every `hone` command stops with `settings-in-both-versions`.
426
-
427
- ### Refusals you may meet
428
-
429
- Each line below is the tool's own, with `<...>` standing for what it names. Do what the line says, then run the upgrade again.
430
-
431
- - `version 1's own run could not be made (<detail>). Run hone check and fix its load failure first.` The same action follows `version 1's run failed (<detail>).` and `version 1's files could not be read (<detail>).`
432
- - `version 1 already reports <clauses> as uncovered. Select or mark each of them in disciplines.json, then run the upgrade again.`
433
- - `the file carve-out for <clause> in <file> answers no finding. Remove it, or fix the file it names, then run the upgrade again.` An `answers only a suppression` line says the same.
434
- - `<clause> in <file> is held by both a file carve-out and an authorised location. Remove one of them first, then run the upgrade again.`
435
- - `<clause> has no version 2 check to run it, and version 2 does not carry the clauses of a version 1 team rule set. Remove it from disciplines.json to upgrade without it, or stay on version 1.`
436
- - `<path> already exists. Move it aside, then run the upgrade again.` The same action, with a different cause, follows `<path> could not be read to be replaced (<detail>). Make it readable, then run the upgrade again.`, `<path> could not be created (<detail>). Fix what the detail names, then run the upgrade again.` and `<path> could not be written (<detail>). Fix what the detail names, then run the upgrade again.`
437
- - Inline directives, which most repositories with recorded inline exceptions ([section 14](#14-moving-to-recorded-inline-exceptions)) meet on the first run. The upgrade runs version 2 over your source before it removes anything, and refuses, with every written file put back, when an `eslint-disable` comment names a rule id version 2 does not have. `these inline directives name a version 1 rule id, which version 2 names differently:` lists each as ` <file>:<line> <id>: write <version 2 id>`, with `each of <ids>` where one id became several, then says `Replace each version 1 id with the version 2 id shown, then run the upgrade again.` `these inline directives name a hone rule id that version 2 has no check under:` lists each as ` <file>:<line> <id>`, then says `Fix each one to name a check of version 2, or remove it, then run the upgrade again.`
438
- - `the version 1 records are invalid; fix them first:` or `a version 1 record in <records file> is not JSON. Fix it first.`
439
- - `version 1's own project failed (<detail>). Run hone project with your version 1 release, fix what it reports, then run the upgrade again.`, then `version 1's own project may have changed files before it failed; check version control for what it changed.` The tree may have changed, and this refusal does not say `Nothing was changed.`
440
- - `version 1's own project rewrote <files>, which the upgrade had already measured. Commit what it wrote, then run the upgrade again.` Version 1's own `project` has changed those files, which stay changed: commit them, then run the upgrade again.
441
- - `version 2 does not report what version 1 reported:`, then what differs, then `This is a fault in hone, not in your repository. Report it at <issues page>, with this output.` Send the output. Nothing was changed, unless a rollback partly failed, in which case the files it could not put back are listed in its place.
442
- - A few lines are faults of the tool, and end by asking you to report them at the issues page, either `Report it at <issues page>.` or `This is a fault in hone, not in your repository. Report it at <issues page>, with this output.`, such as `version 2's run failed (<detail>).`, `a finding of <clause> in <file> names no check of version 2. Report it at <issues page>.`, `the carve-out for <clause> in <file> was given no answer.` and `the authorised location for <clause> in <file> was given no answer.`, and `<file> cannot be placed in the repository.` Send the line. The others that name a file, `<file> could not be read (<detail>). Make it readable, then run the upgrade again.`, and `the version 1 projection <projection> has no version 2 projection to take its place, since version 2 runs no lint config in <folder>. Remove it and its import in <config>, then run the upgrade again.`, say what to do.
414
+ It exits `0` on success, listing each file it wrote, rewrote or removed: commit them all. It exits `1` on a refusal, and each refusal line says what to do: do it, then run the upgrade again. A refusal says whether anything was changed, and lists any file it could not put back. A line that asks you to report a fault at the issues page is the tool's fault, not your repository's: send the output. It exits `3` when version 2 is in place but some version 1 files could not be removed: delete the files it lists by hand, then commit. [docs/output-contract.md](docs/output-contract.md) lists every line.
443
415
 
444
416
  ### Your records, and what the check judges
445
417
 
446
- A file carve-out that version 1 held with a `provenance`, as `hone record-debt` writes, or with a `whyChain`, and every authorised location move to `hone-records` word for word, under a `carried` key. These are the carried records. A location is filed at the check or checks that the findings it answers sit at, so one for a clause bound to the audit mechanism lands under the symptom those findings belong to, such as `hone-records/authorised-locations/claimed-type.json`, not under its clause. A file carve-out with neither moves as a debt record with the `reason` as its `note`.
418
+ A file carve-out that version 1 held with a `provenance`, as `hone record-debt` writes, or with a `whyChain`, and every authorised location move to `hone-records` word for word, under a `carried` key. These are the carried records. A location is filed at the check or checks that the findings it answers sit at, so one for a clause bound to the audit mechanism lands under the symptom those findings belong to, such as `hone-records/authorised-locations/claimed-type.json`, not under its clause. A file carve-out with neither moves as a debt record with the `reason` as its `note`, and so does one that held up an inline disable or a TypeScript directive and exempted no finding, once for each check the suppression reaches.
447
419
 
448
420
  The check lists the carried records under `carried`, one line each, `<records file> records[<index>] <standing>`, followed by `lacks` and the keys it lacks when the record lacks any. A carried authorised location lacks `case`, `owes` and `whyChain`, which version 1 did not hold, and its line says so. With a base revision, it judges each one: it is `established` when the base revision held that record unchanged, whether as a version 1 entry or as a version 2 record, so a base from before the upgrade works. A carried record changed since the base is refused as `carried-changed-since-base`, so leave carried records as they are. Without a base revision the standing is `unjudged`: under `"forfeiture": "this-run"`, the default, the run fails with `import-unmeasured no-base-revision`, so every run needs `--base-revision`, local runs and hooks included; under `"forfeiture": "elsewhere"` it prints `carried standing elsewhere` and leaves them to the run that has a base. Version 2 names each finding by its check, such as `authored-class-or-this#class-keyword`, where version 1 named it by its clause, such as `CD-14#class-syntax`.
449
421
 
@@ -463,14 +435,4 @@ A repository with package slices, one `disciplines.eslint.mjs` in each package f
463
435
 
464
436
  After version 1's run, the upgrade runs version 1's own `project` once, to learn which slices exist. A slice that no config root owns any more is removed by it. A refusal after that lists it under `version 1's own project removed these files, and the upgrade does not put them back; restore them from version control:`, since the upgrade did not write it.
465
437
 
466
- The refusals an ESLint repository meets:
467
-
468
- - `<config file> holds no static default import of <projection>. Change its import of it to the form import projection from "<specifier>", then run the upgrade again.` The same action follows `no file imports <projection> with a static default import.`
469
- - `<config file> imports the version 1 projection <n> times. Import it once.`
470
- - `<config file> names a version 1 projection outside the imports the upgrade rewrites, or imports one version 1 did not write. Remove the other mention or import, then run the upgrade again.`
471
- - `the version 1 projection <projection> is <state>. Run hone project with your version 1 release, commit what it writes, then run the upgrade again.` For some states it says `Run hone check with your version 1 release, fix what it reports` in place of that.
472
- - `the version 1 projection <projection> belongs to no config root and is out of date. Delete it or restore its config root, commit, then run the upgrade again.`
473
- - `version 2 cannot run this repository yet (<line>). Do what it names, or stay on version 1 until version 2 runs it, then run the upgrade again.` `<line>` is a load failure, usually `load failure: not-ready-yet eslint-config-roots: …`, which a repository holding another `hone.config.json` folder meets.
474
- - `version 2's projection could not be made (<line>). Fix what it names, then run the upgrade again.`
475
- - `version 2 would project <file>, but version 1 has no projection in <folder>. With your version 1 release, run hone project and import what it writes in the lint config of <folder>, commit, then run the upgrade again.`
476
- - `the version 1 projection <projection> has no version 2 projection to take its place, since version 2 runs no lint config in <folder>. Remove it and its import in <config file>, then run the upgrade again.`
438
+ Each refusal an ESLint repository meets names the config or projection and what to do, as every other refusal does.