@hailstails/hone 0.1.0-pre.5 → 0.1.0-pre.6
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 +151 -42
- package/MIGRATING.md +55 -4
- package/README.md +98 -35
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/chunks/chunk-5LCLBXP7.js +76 -0
- package/chunks/{chunk-IIMK5BCL.js → chunk-ET5EBSJX.js} +15 -13
- package/chunks/{chunk-7PVPPH4C.js → chunk-LDQUT742.js} +3 -1
- package/chunks/{chunk-VUG3DJHN.js → chunk-LOYT2AGY.js} +8 -9
- package/chunks/{chunk-HVABJ7T4.js → chunk-MVK5KFJI.js} +72 -12
- package/chunks/{chunk-SWPCKTJV.js → chunk-NCDYOPHG.js} +7340 -2124
- package/chunks/{chunk-7OVV6NEU.js → chunk-WPRR2MPJ.js} +1 -1
- package/chunks/{chunk-YBWVUDIG.js → chunk-XB4PCY3Q.js} +1 -1
- package/core/check/tool-command.js +938 -313
- package/docs/adding-a-discipline-or-mechanism.md +27 -14
- package/docs/extending.md +4 -3
- package/docs/output-contract.md +326 -0
- package/mechanisms/audit/CD-19/import-boundaries.js +3 -3
- package/mechanisms/audit/CD-2/piece.json +6 -1
- package/mechanisms/audit/CD-5/comments-directives.js +10 -26
- package/mechanisms/audit/runner/README.md +3 -2
- package/mechanisms/audit/runner/runner.js +97 -35
- package/mechanisms/eslint/CD-2/README.md +12 -0
- package/mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js +16 -0
- package/mechanisms/eslint/CD-2/piece.json +25 -0
- package/mechanisms/eslint/runner/README.md +12 -5
- package/mechanisms/eslint/runner/runner.js +900 -242
- package/methods/README.md +2 -0
- package/methods/assessment-template.md +35 -0
- package/methods/lenses/clean-architecture.md +2 -2
- package/methods/lenses/decomposition.md +2 -2
- package/methods/lenses/defended-on-intent.md +7 -7
- package/methods/lenses/di-discipline.md +38 -26
- package/methods/lenses/errors-as-data.md +2 -2
- package/methods/lenses/function-first.md +2 -2
- package/methods/lenses/naming.md +2 -2
- package/methods/lenses/test-discipline.md +15 -13
- package/methods/lenses/type-soundness.md +2 -2
- package/methods/lenses/zod-boundary.md +2 -2
- package/package.json +2 -1
- package/rules/CD-1/CHECKS.md +37 -0
- package/rules/CD-1/README.md +17 -32
- package/rules/CD-10/CHECKS.md +49 -0
- package/rules/CD-10/README.md +21 -49
- package/rules/CD-11/CHECKS.md +13 -0
- package/rules/CD-11/README.md +14 -8
- package/rules/CD-12/CHECKS.md +13 -0
- package/rules/CD-12/README.md +14 -8
- package/rules/CD-13/CHECKS.md +13 -0
- package/rules/CD-13/README.md +14 -8
- package/rules/CD-14/CHECKS.md +49 -0
- package/rules/CD-14/README.md +22 -48
- package/rules/CD-15/CHECKS.md +40 -0
- package/rules/CD-15/README.md +22 -40
- package/rules/CD-16/CHECKS.md +7 -0
- package/rules/CD-16/README.md +3 -5
- package/rules/CD-17/CHECKS.md +37 -0
- package/rules/CD-17/README.md +17 -31
- package/rules/CD-18/CHECKS.md +13 -0
- package/rules/CD-18/README.md +15 -9
- package/rules/CD-19/CHECKS.md +49 -0
- package/rules/CD-19/README.md +18 -44
- package/rules/CD-2/CHECKS.md +56 -0
- package/rules/CD-2/README.md +18 -35
- package/rules/CD-2/discipline.json +68 -0
- package/rules/CD-20/CHECKS.md +7 -0
- package/rules/CD-20/README.md +3 -5
- package/rules/CD-21/CHECKS.md +13 -0
- package/rules/CD-21/README.md +14 -9
- package/rules/CD-22/CHECKS.md +13 -0
- package/rules/CD-22/README.md +13 -8
- package/rules/CD-23/CHECKS.md +35 -0
- package/rules/CD-23/README.md +14 -29
- package/rules/CD-24/CHECKS.md +7 -0
- package/rules/CD-24/README.md +3 -5
- package/rules/CD-25/CHECKS.md +38 -0
- package/rules/CD-25/README.md +20 -32
- package/rules/CD-26/CHECKS.md +36 -0
- package/rules/CD-26/README.md +18 -31
- package/rules/CD-27/CHECKS.md +45 -0
- package/rules/CD-27/README.md +18 -40
- package/rules/CD-28/CHECKS.md +13 -0
- package/rules/CD-28/README.md +14 -8
- package/rules/CD-29/CHECKS.md +13 -0
- package/rules/CD-29/README.md +12 -8
- package/rules/CD-3/CHECKS.md +42 -0
- package/rules/CD-3/README.md +20 -42
- package/rules/CD-30/CHECKS.md +13 -0
- package/rules/CD-30/README.md +13 -8
- package/rules/CD-31/CHECKS.md +13 -0
- package/rules/CD-31/README.md +12 -8
- package/rules/CD-32/CHECKS.md +13 -0
- package/rules/CD-32/README.md +13 -8
- package/rules/CD-33/CHECKS.md +13 -0
- package/rules/CD-33/README.md +13 -8
- package/rules/CD-34/CHECKS.md +13 -0
- package/rules/CD-34/README.md +12 -8
- package/rules/CD-39/CHECKS.md +13 -0
- package/rules/CD-39/README.md +13 -8
- package/rules/CD-4/CHECKS.md +13 -0
- package/rules/CD-4/README.md +15 -8
- package/rules/CD-40/CHECKS.md +39 -0
- package/rules/CD-40/README.md +17 -33
- package/rules/CD-41/CHECKS.md +54 -0
- package/rules/CD-41/README.md +23 -54
- package/rules/CD-42/CHECKS.md +47 -0
- package/rules/CD-42/README.md +19 -47
- package/rules/CD-43/CHECKS.md +37 -0
- package/rules/CD-43/README.md +15 -31
- package/rules/CD-44/CHECKS.md +48 -0
- package/rules/CD-44/README.md +20 -48
- package/rules/CD-45/CHECKS.md +13 -0
- package/rules/CD-45/README.md +14 -8
- package/rules/CD-46/CHECKS.md +7 -0
- package/rules/CD-46/README.md +16 -4
- package/rules/CD-47/CHECKS.md +37 -0
- package/rules/CD-47/README.md +16 -32
- package/rules/CD-5/CHECKS.md +52 -0
- package/rules/CD-5/README.md +22 -52
- package/rules/CD-6/CHECKS.md +51 -0
- package/rules/CD-6/README.md +22 -51
- package/rules/CD-7/CHECKS.md +46 -0
- package/rules/CD-7/README.md +23 -46
- package/rules/CD-7a/CHECKS.md +38 -0
- package/rules/CD-7a/README.md +14 -32
- package/rules/CD-8/CHECKS.md +42 -0
- package/rules/CD-8/README.md +20 -42
- package/rules/CD-9/CHECKS.md +13 -0
- package/rules/CD-9/README.md +15 -8
- package/rules/README.md +5 -3
- package/rules/SPIRIT.md +50 -0
package/ADOPTING.md
CHANGED
|
@@ -26,7 +26,13 @@ The main route is the npm registry. Pre-releases are published under the dist-ta
|
|
|
26
26
|
npm install --save-dev @hailstails/hone@next
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
With pnpm, add it as a development dependency, using `-Dw` in place of `-D` at the root of a pnpm workspace:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm add -D @hailstails/hone@next
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The package manager records it in `package.json`, and the exact version it installed in the lockfile. Check the name before you run it: `@hailstails/hone`, never the unscoped `hone`. With Yarn, add `@hailstails/hone@next` with its own `add -D` command at the workspace root. `next` names the newest pre-release approved on npm, so it can trail the newest GitHub release for a while; [README.md](README.md#developing-hone) says how a version reaches npm.
|
|
30
36
|
|
|
31
37
|
The alternative is a tarball, copied into the repository so every teammate and CI runner installs the same bytes without the registry. This page writes its location as `<hone-tarball>`: a path such as `vendor/hailstails-hone/hailstails-hone-<version>.tgz`, or an `https://` URL your team serves it from. Download the tarball attached to the latest [GitHub release](https://github.com/HailsTails/hone/releases), or build it from a pinned commit as below.
|
|
32
38
|
|
|
@@ -46,7 +52,13 @@ Install it as a development dependency of the repository root, beside the toolch
|
|
|
46
52
|
npm install --save-dev <hone-tarball>
|
|
47
53
|
```
|
|
48
54
|
|
|
49
|
-
|
|
55
|
+
With pnpm, using `-Dw` in place of `-D` at the root of a pnpm workspace:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pnpm add -D <hone-tarball>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The package manager records it in `package.json` and the lockfile. With Yarn, add the same tarball with its own `add -D` command at the workspace root.
|
|
50
62
|
|
|
51
63
|
Add the two commands to the root `package.json` scripts:
|
|
52
64
|
|
|
@@ -57,7 +69,7 @@ Add the two commands to the root `package.json` scripts:
|
|
|
57
69
|
}
|
|
58
70
|
```
|
|
59
71
|
|
|
60
|
-
`hone` is the package's one command, with two subcommands: `hone check` runs the check and `hone project` writes the ESLint projection. `hone` with no subcommand, or with any other, exits `2` with
|
|
72
|
+
`hone` is the package's one command, with two subcommands: `hone check` runs the check and `hone project` writes the ESLint projection. `hone` with no subcommand, or with any other, exits `2` with one `load failure: arguments-invalid` line that names the commands and points at `hone --help`, which prints the usage.
|
|
61
73
|
|
|
62
74
|
Hone runs on the toolchain the repository already uses, which the package declares as peer dependencies: `typescript` is a required peer, because every `audit` clause needs it, and the ESLint packages are optional peers, needed only for `eslint` clauses. 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:
|
|
63
75
|
|
|
@@ -76,9 +88,9 @@ Commit `package.json`, the lockfile and the tarball if it is a file in the repos
|
|
|
76
88
|
|
|
77
89
|
## 3. Read what each discipline means
|
|
78
90
|
|
|
79
|
-
[rules/README.md](rules/README.md) lists every discipline. Each `rules/<ID>/README.md` quotes the rule,
|
|
91
|
+
[rules/README.md](rules/README.md) lists every discipline. Each discipline has two pages. `rules/<ID>/README.md` quotes the rule, names its review lens, and gives its spirit: what the friction is for, what a finding usually points at, the direction to go, and the principles behind it. `rules/<ID>/CHECKS.md` holds the mechanics: the Clauses table, exactly what each check flags, a violation and its fix, and how to record an exception. Read the rule page first; [the spirit of the rules](rules/SPIRIT.md) explains the approach for the whole set. A discipline's clause addresses are in its CHECKS.md Clauses table, for example `CD-14#class-syntax`, with the mechanism that checks each clause. A clause whose mechanism is `review` is a judgement clause: it is applied in review, not by a check, with the review lens the rule page names (step 9).
|
|
80
92
|
|
|
81
|
-
A check covers only what its
|
|
93
|
+
A check covers only what its CHECKS.md says it flags. Read the whole rule, not only the Clauses table: where a rule asks for more than its check can see, CHECKS.md says which part is left to review, and the rule's review lens covers that part.
|
|
82
94
|
|
|
83
95
|
Where to start: for an API, boundary validation (CD-4, CD-45), result-shaped failures (CD-9, CD-10, CD-11) and inward dependency direction (CD-12, CD-13) are useful next selections, most of them judgement rules. For React, first select the type and test disciplines that apply to component code; do not apply server ports or process-lifecycle rules to browser code.
|
|
84
96
|
|
|
@@ -98,13 +110,20 @@ Create `<repo>/disciplines.json`. Map every clause you adopt to the mechanism th
|
|
|
98
110
|
}
|
|
99
111
|
```
|
|
100
112
|
|
|
101
|
-
- `clauses` keys are clause addresses from the rules pages; the value is a mechanism the clause's
|
|
113
|
+
- `clauses` keys are clause addresses from the rules' CHECKS.md pages; the value is a mechanism the clause's CHECKS.md lists, `audit` or `eslint`, `"not-run"` or `"not-adopted"`.
|
|
102
114
|
- Selecting one clause of a discipline adopts the whole discipline: any of its other mechanical clauses you leave out are reported as `uncovered` and fail the run. CD-3 has seven clauses; select all seven or none.
|
|
103
|
-
- A discipline may span mechanisms; adopt every mechanical clause through the mechanism that has it, or the discipline reports the rest uncovered. CD-14, for example, checks `class-syntax` through `audit` or `eslint` but `static-only-class` only through `eslint`, so adopting CD-14 means adopting the ESLint mechanism for at least that clause; see [README.md](README.md#adopting-the-eslint-mechanism).
|
|
104
|
-
-
|
|
105
|
-
-
|
|
115
|
+
- A discipline may span mechanisms; adopt every mechanical clause through the mechanism that has it, or the discipline reports the rest uncovered. CD-14, for example, checks `class-syntax` through `audit` or `eslint` but `static-only-class` only through `eslint`, so adopting CD-14 means adopting the ESLint mechanism for at least that clause; see [README.md](README.md#adopting-the-eslint-mechanism). If ESLint cannot work in this repository, list such a clause as `"not-run"`, as below.
|
|
116
|
+
- A clause's value in `clauses` is one of three:
|
|
117
|
+
- a mechanism id, such as `audit`: the check runs and its findings fail the run;
|
|
118
|
+
- `"not-run"`: the clause is adopted, but its mechanism is not run; the report lists it under `notRun` as `adopted, mechanism not run: enforced by review`;
|
|
119
|
+
- `"not-adopted"`: the clause is not adopted; the report lists it under `notAdopted`.
|
|
120
|
+
- A `"not-run"` or `"not-adopted"` clause is never run and never projected, not even as `"off"`, and its mechanism is not loaded unless another clause uses it, so a repository that lists every ESLint clause this way needs no ESLint installed. Both leave the run a whole assessment. Neither takes an exception record: one on such a clause is invalid as `clause-not-run` or `clause-not-adopted`.
|
|
121
|
+
- When a clause's 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:
|
|
122
|
+
- Not adopted: the rule does not apply to this codebase; a tech lead declares that, in the open. Set the clause to `"not-adopted"`.
|
|
123
|
+
- Adopted, mechanism 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 clause to `"not-run"`. CD-6's ESLint-only `naming-convention` in a repository without ESLint is the usual case: `"CD-6#identifier-names": "audit", "CD-6#naming-convention": "not-run"`.
|
|
124
|
+
- Clause-wide carve-out: the rule binds and its check is sound, but the codebase has debt it cannot address right now. Keep the clause's mechanism, so the clause still runs, and record the debt against it as a `clause-wide-carve-out` with its why-chain and an owner who will pay it down (step 7).
|
|
106
125
|
- `exclude` lists folders or exact files, as repository paths with forward slashes; an entry containing `*` is refused, because globs are not supported. A folder entry excludes everything under it. Use it for generated or third-party code. `node_modules`, `dist`, `build`, `coverage`, `.git` and a top-level `vendor` folder are skipped already.
|
|
107
|
-
- `clauseSettings` gives a clause the settings its
|
|
126
|
+
- `clauseSettings` gives a clause the settings its CHECKS.md lists under Settings, keyed by clause address. CD-19, for example, flags only imports of the packages you list in its `confinedPackages`; CD-5's `trackerPatterns` narrows tracked references to your tracker's format. See [README.md](README.md#disciplinesjson).
|
|
108
127
|
- `ruleSets` stays `{}` unless you write disciplines of your own; see [docs/extending.md](docs/extending.md).
|
|
109
128
|
|
|
110
129
|
Every clause address Hone ships:
|
|
@@ -123,14 +142,14 @@ CD-3#no-implicit-override CD-3#no-fallthrough-cases-in-switch
|
|
|
123
142
|
CD-3#no-property-access-from-index-signature CD-3#use-unknown-in-catch-variables
|
|
124
143
|
|
|
125
144
|
eslint:
|
|
126
|
-
CD-1#explicit-any CD-1#implicit-any-let CD-
|
|
127
|
-
CD-7#filename-case
|
|
128
|
-
CD-14#static-only-class
|
|
129
|
-
CD-40#parameter-count
|
|
130
|
-
CD-42#useless-else
|
|
145
|
+
CD-1#explicit-any CD-1#implicit-any-let CD-2#non-null-assertions
|
|
146
|
+
CD-6#naming-convention CD-7#filename-case CD-10#throw-only-error
|
|
147
|
+
CD-14#class-syntax CD-14#static-only-class CD-27#focused-tests
|
|
148
|
+
CD-27#skipped-tests CD-40#parameter-count CD-41#cognitive-complexity
|
|
149
|
+
CD-41#function-length CD-42#useless-else CD-44#parameter-reassignment
|
|
131
150
|
```
|
|
132
151
|
|
|
133
|
-
CD-1, CD-6, CD-7, CD-10, CD-14, CD-27 and CD-44 have clauses under both mechanisms, and CD-40, CD-41 and CD-42 only under `eslint`, so adopting any of them needs the ESLint mechanism.
|
|
152
|
+
CD-1, CD-2, CD-6, CD-7, CD-10, CD-14, CD-27 and CD-44 have clauses under both mechanisms, and CD-40, CD-41 and CD-42 only under `eslint`, so adopting any of them needs the ESLint mechanism.
|
|
134
153
|
|
|
135
154
|
Starting with a few disciplines and adding more once the run passes is easier than fixing everything at once.
|
|
136
155
|
|
|
@@ -142,7 +161,21 @@ Skip this if every selected clause is `audit`. Otherwise, after writing `discipl
|
|
|
142
161
|
npm run --silent hone:project
|
|
143
162
|
```
|
|
144
163
|
|
|
145
|
-
It prints `disciplines.eslint.mjs written`. Spread its default export last in the repository's flat config. A repository with no ESLint config yet can start from this `eslint.config.mjs`:
|
|
164
|
+
It prints `disciplines.eslint.mjs written`. 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`:
|
|
165
|
+
|
|
166
|
+
```js
|
|
167
|
+
import typescriptParser from "@typescript-eslint/parser";
|
|
168
|
+
import projection from "./disciplines.eslint.mjs";
|
|
169
|
+
|
|
170
|
+
export default [
|
|
171
|
+
{ files: ["**/*.{ts,tsx,mts,cts}"], languageOptions: { parser: typescriptParser } },
|
|
172
|
+
...projection,
|
|
173
|
+
];
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
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`.
|
|
177
|
+
|
|
178
|
+
In a monorepo where ESLint resolves each file from its nearest config, `hone:project` also writes a `disciplines.eslint.mjs` slice beside each package's tracked `eslint.config.*`, holding only that package's exceptions 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 `disciplines.json` gets no slice: its ESLint configuration is not managed from this repository, and nested Hone configurations are not supported yet ([#72](https://github.com/HailsTails/hone/issues/72)); when that leaves a carve-out recorded there out of effect, the check names the folder on its `mechanism-not-run eslint not-included` line. The root config spreads the root projection last, and each package config spreads its own slice last, never the root one:
|
|
146
179
|
|
|
147
180
|
```js
|
|
148
181
|
import projection from "./disciplines.eslint.mjs";
|
|
@@ -153,7 +186,21 @@ export default [
|
|
|
153
186
|
];
|
|
154
187
|
```
|
|
155
188
|
|
|
156
|
-
|
|
189
|
+
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 `disciplines.json` and spread the slice in `sku.config.ts`:
|
|
190
|
+
|
|
191
|
+
```json
|
|
192
|
+
{ "eslintConfigRoots": ["packages/web"] }
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import projection from "./disciplines.eslint.mjs";
|
|
197
|
+
|
|
198
|
+
export default {
|
|
199
|
+
dangerouslySetESLintConfig: (skuEslintConfig) => [...skuEslintConfig, ...projection],
|
|
200
|
+
};
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The check names a slice that is missing, out of date, or not applied to that package's files, 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 shows its files under `unrecorded` as `config-override` while it has no file exception of its own; once a file under check there has one, the package is also reported `not-applied`. Hone sees which slice a package config spreads only through its effect: a package config that spreads the root projection by mistake is reported `not-applied` once a file under check in that package has a file exception the root projection cannot carry. Until then the check says nothing, because for a package with no file exceptions of its own the root projection and the slice switch on the same rules, and clause-wide carve-outs reach the package either way. To confirm the spread before adding an exception, 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 `disciplines.json`:
|
|
157
204
|
|
|
158
205
|
```json
|
|
159
206
|
{ "eslintConfigLookup": "nearest-to-file" }
|
|
@@ -161,7 +208,7 @@ In a monorepo, every `eslint.config.*` that applies to checked files spreads the
|
|
|
161
208
|
|
|
162
209
|
Use `"nearest-to-file"` when ESLint runs per package, with ESLint 10, or with ESLint 9 and `--flag v10_config_lookup_from_file` (on 9.28 and 9.29, `--flag unstable_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.
|
|
163
210
|
|
|
164
|
-
Commit
|
|
211
|
+
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 `disciplines.json` or `discipline-exceptions.json` changes or Hone is updated. The projection imports each piece from the package by name, for example `@hailstails/hone/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js`, 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.
|
|
165
212
|
|
|
166
213
|
## 5. Run the check
|
|
167
214
|
|
|
@@ -175,17 +222,13 @@ npm run --silent hone:check
|
|
|
175
222
|
| `1` | `verdict: fail`: the report says why |
|
|
176
223
|
| `2` | an input could not be loaded or a check crashed; the output is one line starting `load failure:` or names the failing piece |
|
|
177
224
|
|
|
178
|
-
`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: runner-failed <mechanism> toolchain-unavailable <package> ...` line names
|
|
225
|
+
`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: runner-failed <mechanism> 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. A `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.
|
|
179
226
|
|
|
180
|
-
|
|
227
|
+
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.
|
|
181
228
|
|
|
182
|
-
|
|
183
|
-
npm run --silent hone:check -- --base-revision origin/main
|
|
184
|
-
```
|
|
229
|
+
A known limit: `hone check` runs its own ESLint pass over the governed files, even when the repository's own lint has just run. A hook that runs both pays for lint twice. Reusing the repository's lint run is planned after 1.0.
|
|
185
230
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
To assess decay at push only, for example so that a hotfix in a carved file is not blocked in CI, set `"assessment": { "forfeiture": "elsewhere" }` in `disciplines.json`. CI and the pre-push hook then run different commands. The pre-push hook assesses decay for its run:
|
|
231
|
+
A first adoption assesses decay at push only, so that a hotfix in a carved file is not blocked in CI while the check is new: set `"assessment": { "forfeiture": "elsewhere" }` in `disciplines.json`. CI and the pre-push hook then run different commands. The pre-push hook assesses decay for its run:
|
|
189
232
|
|
|
190
233
|
```bash
|
|
191
234
|
npm run --silent hone:check -- --forfeiture this-run --base-revision origin/main
|
|
@@ -203,9 +246,58 @@ A repository with imported records (`provenance`) or legacy-chain records still
|
|
|
203
246
|
npm run --silent hone:check -- --base-revision <base-commit>
|
|
204
247
|
```
|
|
205
248
|
|
|
249
|
+
A team that assesses decay in CI leaves `assessment` unset and runs `npm run --silent hone:check -- --base-revision origin/main` there; the check then needs that revision and the history back to where the branch left it, for example `fetch-depth: 0` with `actions/checkout`.
|
|
250
|
+
|
|
206
251
|
The trade: a push that bypasses the hook, for example with `git push --no-verify`, leaves no later gate, so carve-out debt can stop decaying unnoticed. Every run that leaves decay to another run says so in its report (step 6). With `eslint` clauses, the repository's own `eslint` run also reports them in the editor, from the projection.
|
|
207
252
|
|
|
208
|
-
Tell any coding agent working in the repository, in its project instructions: "Read the rule pages under `node_modules/@hailstails/hone/rules/` for the disciplines in `disciplines.json` before editing. Before handing off, run the repository's validation command, report its exit code and findings, and apply the judgement rules listed in
|
|
253
|
+
Tell any coding agent working in the repository, in its project instructions: "Read the rule pages under `node_modules/@hailstails/hone/rules/` for the disciplines in `disciplines.json` before editing. When a check fails, read the section for the failing clause in `disciplines.assessment.md` and the Spirit section of the clause's rule page before changing anything; do not add an exception, exclusion or setting to make it pass. Before handing off, run the repository's validation command, report its exit code and findings, and apply the judgement rules listed in `disciplines.assessment.md` with their review lenses." Copying the rule pages does not make an agent read them; the instruction does. Step 5a writes `disciplines.assessment.md`.
|
|
254
|
+
|
|
255
|
+
### 5a. Write the assessment
|
|
256
|
+
|
|
257
|
+
The first run on an existing codebase usually fails, often with many findings. Each finding is a signal about the design: a missing boundary, an earlier choice that forces the workaround, a port wider than its use. Before fixing or recording anything, write down what the signals mean in this codebase, in `<repo>/disciplines.assessment.md`. Whoever later hits a red check then has more to go on than the assumption that the friction is unnecessary: the file says what that clause points at here and where the code is going.
|
|
258
|
+
|
|
259
|
+
Each rule page's Spirit section lists the usual causes behind its findings. The assessment does not repeat them. It says which cause applies here, where, the forward goal in this codebase's terms, and the steps toward it.
|
|
260
|
+
|
|
261
|
+
Start from the template the package ships:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
cp node_modules/@hailstails/hone/methods/assessment-template.md disciplines.assessment.md
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Fill the top sections: the rules adopted, the clauses not adopted because the rule does not apply here, the clauses adopted with their mechanism not run because the check is not a true measure here or cannot work here, and the judgement rules adopted (step 9). Step 4 says how each is declared in `disciplines.json`; the assessment says why.
|
|
268
|
+
|
|
269
|
+
Then write one section per high-count clause. Hone has no threshold for this. A clause is high-count when its findings will not all be fixed in the change that adopts it: three findings in one file you fix today need no section; three findings in three folders you will not reach this week do.
|
|
270
|
+
|
|
271
|
+
The assessment is usually drafted by a coding agent. Give it this instruction as it is:
|
|
272
|
+
|
|
273
|
+
```text
|
|
274
|
+
Draft disciplines.assessment.md from node_modules/@hailstails/hone/methods/assessment-template.md, using the latest hone:check report.
|
|
275
|
+
|
|
276
|
+
For each clause in the report's findings section whose findings will not all be fixed in this change:
|
|
277
|
+
1. Measure. Count its findings and group them by folder, by the value, library or dependency involved, and by the shape of the code.
|
|
278
|
+
2. Read the code at several sites in each group, not only the report lines.
|
|
279
|
+
3. Read the clause's rule page, node_modules/@hailstails/hone/rules/<ID>/README.md, in full, and its Spirit section closely.
|
|
280
|
+
4. Match each group against the causes listed under "What a finding points at". Name the cause exactly as the rule names it. If no listed cause fits, say so and describe what the sites show; do not pick the closest.
|
|
281
|
+
5. Write the clause's section from the template: the cause, the count and example sites as file:line, the forward goal in this codebase's terms, and the steps that change the code toward it, starting with the step that unlocks the others.
|
|
282
|
+
|
|
283
|
+
Exclusions, exceptions, settings and not adopting a clause are never a cause, a goal or a step. The Debt line says how existing debt is held while the steps are taken; write it last, after the rest of the section. A section that gives only counts, or whose steps are about recording exceptions, is not done.
|
|
284
|
+
|
|
285
|
+
Stop when every such clause has a section. Report the sections for review before changing code or recording exceptions.
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Review the draft as you would a design: the causes and the goals are the decisions in it. Commit it beside `disciplines.json`. Every failing check then ends with a `readFirst` line per failing clause that names its section before the rule page's Spirit (step 6); a clause the file does not assess is pointed at the Spirit alone. Record exceptions (step 7) only after the assessment, and note each in the clause's Debt line. Keep the file current: when steps land or a count changes, update the section; when a clause has no findings left, delete its section.
|
|
289
|
+
|
|
290
|
+
A finished section reads like this:
|
|
291
|
+
|
|
292
|
+
```markdown
|
|
293
|
+
## CD-2#cast-expressions
|
|
294
|
+
|
|
295
|
+
- **Cause here:** Parsing skipped at a boundary. Database rows are cast to domain types where they are read.
|
|
296
|
+
- **Sites:** 118 at 3f1c2ab, in src/orders/ and src/billing/. For example src/orders/order-reader.ts:41, src/billing/invoice-reader.ts:17.
|
|
297
|
+
- **Forward goal:** rows are parsed once in the storage port, and services receive typed orders and invoices.
|
|
298
|
+
- **Steps:** 1. A schema per table read, in the storage port. 2. The port returns parsed types. 3. Delete the casts, one folder at a time.
|
|
299
|
+
- **Debt:** held by the orders team; file carve-outs in discipline-exceptions.json, paid off as each file is touched.
|
|
300
|
+
```
|
|
209
301
|
|
|
210
302
|
## 6. Read the report
|
|
211
303
|
|
|
@@ -216,31 +308,35 @@ The report prints only the sections that have entries, each with its count, then
|
|
|
216
308
|
CD-15#loops audit src/basket.ts:15:0 for (const line of this.lines) {
|
|
217
309
|
```
|
|
218
310
|
|
|
219
|
-
Lines are 1-based and columns 0-based. The run passes only when every section except `excluded`, `notAdopted`, `exempted` and `
|
|
311
|
+
[docs/output-contract.md](docs/output-contract.md) 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 section except `excluded`, `notAdopted`, `notRun`, `exempted`, `assessment` and `readFirst` is empty. The sections are:
|
|
220
312
|
|
|
221
313
|
| Section | Meaning and what to do |
|
|
222
314
|
| --- | --- |
|
|
223
315
|
| `excluded` | the `exclude` entries from `disciplines.json` that were left out of the run; informational, check it is what you meant |
|
|
224
316
|
| `notAdopted` | the clauses `disciplines.json` lists as `"not-adopted"`; informational, they were neither run nor projected |
|
|
317
|
+
| `notRun` | the clauses `disciplines.json` lists as `"not-run"`, each as `<clause> adopted, mechanism not run: enforced by review`; informational, they were neither run nor projected, and the rule is still owed through review |
|
|
225
318
|
| `findings` | violations: fix the code, or record an exception (step 7) |
|
|
226
319
|
| `exempted` | findings an exception covers; informational |
|
|
227
|
-
| `
|
|
320
|
+
| `unrecorded` | a native exception no record holds, as `<clause> <mechanism> <kind> <detail>`: remove it, or record it where step 7 allows. An inline disable, `<clause> eslint inline-disable <file>:<line> <comment>`, and a TypeScript directive, `CD-2#cast-expressions audit inline-disable <file>:<line> <comment>`, are held only by an `authorised-location` or `file-carve-out` on that clause and file. An `eslint-disable` naming no rule escapes every selected clause, needs a record for each, and its lines end ` names no rule and escapes every selected clause: naming the rule is the cheap fix`. A lint-script option, `<clause> eslint command-line-option <package.json> <script> <option> weakens the script's whole run, so no record can cover it: remove it from the script`, cannot be recorded. Where another command comes before `eslint` in its script, as in `tsc && eslint -c eslint.config.mjs .`, the line instead reads `<clause> eslint command-line-option <package.json> <script> <option>: <command> is not the first command of its script, so Hone cannot tell what the option does to the files under check; give <command> a script of its own, such as "<invocation>"`: move that command to a script of its own. Where something before `eslint` in its own command is neither a package runner nor a `NAME=value` setting, as `env` in `env --chdir=src eslint --ignore-pattern dist .` or `-y` in `npx -y eslint --ignore-pattern dist .`, it reads `<clause> eslint command-line-option <package.json> <script> <option>: "<wrapper>" comes before <command> and is neither a package runner nor a NAME=value setting, so Hone cannot tell what the option does to the files under check; put only package runners and NAME=value settings before <command>`. `cross-env` followed only by `NAME=value` settings counts as a setting |
|
|
321
|
+
| `uncovered` | a mechanical clause of an adopted discipline is not listed: add it to `disciplines.json` with a mechanism, `"not-run"` or `"not-adopted"` |
|
|
228
322
|
| `stale` | an exception that no longer exempts anything: delete it |
|
|
229
323
|
| `forfeited` | a file carve-out whose file changed since `--base-revision`: fix the file and delete the carve-out |
|
|
230
|
-
| `invalidRecords` | an exception entry that cannot be accepted, with the reason, for example `clause-not-adopted` for an entry on a clause listed as `"not-adopted"`: correct or delete it |
|
|
324
|
+
| `invalidRecords` | an exception entry that cannot be accepted, with the reason, for example `clause-not-run` or `clause-not-adopted` for an entry on a clause listed as `"not-run"` or `"not-adopted"`: correct or delete it |
|
|
231
325
|
| `doublyHeld` | a file both authorised and carved out for one clause: keep one |
|
|
232
|
-
| `unmeasured` | something could not be measured, for example `forfeiture-unmeasured
|
|
233
|
-
| `
|
|
326
|
+
| `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 file carve-outs cannot be checked for decay; pass --base-revision with the branch's base, such as origin/main, or leave decay to another run with "assessment": { "forfeiture": "elsewhere" } in disciplines.json or --forfeiture elsewhere` |
|
|
327
|
+
| `projectionProblems` | a projection or package slice that differs from what `hone project` writes now, is not written, is not applied, or has no configuration to load it, each with what to do, for example `eslint out-of-date: disciplines.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 disciplines.eslint.mjs it writes` |
|
|
328
|
+
| `assessment` | a concern this run left to another run, for example `forfeiture elsewhere: 37 file carve-outs not checked for decay in this run`; informational, and the verdict line then reads `verdict: pass (partial assessment)` or `verdict: fail (partial assessment)` |
|
|
329
|
+
| `readFirst` | printed last, one line per clause with findings: where to read before changing code, the clause's section in `disciplines.assessment.md` (step 5a) and then the Spirit section of its rule page, for example `CD-15#loops: read the "## CD-15#loops" section of disciplines.assessment.md, then node_modules/@hailstails/hone/rules/CD-15/README.md#spirit`; before the file is written, one note line comes first, counted in the section, and each clause line names its rule page only, as in the walkthrough below; guidance, it never fails the run |
|
|
234
330
|
|
|
235
|
-
To print less, set `"reportOutput"` in `disciplines.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; `failures-only` leaves out `excluded`, `notAdopted`, `exempted` and `assessment`; `counts` prints only each section's heading and count, adding `informational` after `excluded`, `notAdopted`, `exempted` and `assessment` so every other line names a section that failed the run; `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.
|
|
331
|
+
To print less, set `"reportOutput"` in `disciplines.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; `failures-only` leaves out `excluded`, `notAdopted`, `notRun`, `exempted` and `assessment`, and keeps `readFirst`; `counts` prints only each section's heading and count, adding `informational` after `excluded`, `notAdopted`, `notRun`, `exempted` and `assessment` and `guidance` after `readFirst` so every other line names a section that failed the run; `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.
|
|
236
332
|
|
|
237
333
|
## 7. Record exceptions
|
|
238
334
|
|
|
239
|
-
Fix
|
|
335
|
+
Before recording anything, take the chain in [the spirit of the rules](rules/SPIRIT.md#when-the-check-is-red): measure the sites for each failing clause, ask what each group points at using the rule page's Spirit section and the clause's section in `disciplines.assessment.md` (step 5a), then decide. Fix the cause where you can; exceptions are not the first move. Where a file legitimately needs what a clause forbids, record it in `<repo>/discipline-exceptions.json`:
|
|
240
336
|
|
|
241
337
|
- `authorised-location`: the clause does not apply to this one file, for example the single adapter that reads the real clock.
|
|
242
|
-
- `file-carve-out`: known debt in one file. It is forfeited, and fails the run, as soon as that file changes since `--base-revision`.
|
|
243
|
-
- `clause-wide-carve-out`:
|
|
338
|
+
- `file-carve-out`: known debt in one file. It is forfeited, and fails the run, as soon as that file changes since `--base-revision`. An `eslint-disable` comment or a `@ts-expect-error`, `@ts-ignore` or `@ts-nocheck` directive already in a file is debt of this kind on the clause it escapes; a new one in a file with no record is `unrecorded`.
|
|
339
|
+
- `clause-wide-carve-out`: debt across the whole clause. The rule binds and its check is sound, and the codebase cannot address the debt right now. Its why-chain records why, and the debt has an owner who will pay it down. The check still runs, and a clause-wide carve-out that exempts no finding is `stale`, so record one only while the clause still has findings. Leaving the clause out of `clauses` is not an alternative: it leaves the clause `uncovered`. If the check is not a true measure of the rule here, or cannot work here, list the clause as `"not-run"` instead; if the rule does not apply, list it as `"not-adopted"` (step 4).
|
|
244
340
|
|
|
245
341
|
Every entry needs a `reason`. By default every entry also needs a `whyChain` shaped like this, with exactly five steps in `whys`:
|
|
246
342
|
|
|
@@ -285,7 +381,7 @@ It must exit `1` with the line `CD-17#clock-sources audit src/discipline-probe.t
|
|
|
285
381
|
|
|
286
382
|
## 9. Apply the judgement rules
|
|
287
383
|
|
|
288
|
-
A judgement clause cannot be selected in `disciplines.json`, and no check reports it.
|
|
384
|
+
A judgement clause cannot be selected in `disciplines.json`, and no check reports it. List the judgement rules the repository adopts in the Judgement rules section of `disciplines.assessment.md` (step 5a), so reviewers and agents know to apply them.
|
|
289
385
|
|
|
290
386
|
Each rule page names its review lens, a method under [methods/lenses/](methods/README.md) for reading code against that kind of rule. To review a change, by a human reviewer or a coding agent:
|
|
291
387
|
|
|
@@ -301,31 +397,43 @@ To use an agent, give it the lens file, the rule pages it names, the change and
|
|
|
301
397
|
|
|
302
398
|
To update, repeat step 2 on a branch with a tarball built from a newer pinned SHA, compare the installed rule pages under `node_modules/@hailstails/hone/rules/` with the old ones, re-run `hone:project` if any clause is `eslint`, run the check, and commit with a message naming the new SHA. Rule text can change between pins, so read the changed pages. Before updating to a pin that has the causal why-chain contract, follow [MIGRATING.md section 8](MIGRATING.md#8-moving-to-causal-why-chains): pass `--base-revision` first, or the update's check reports `legacy-chain-unmeasured`.
|
|
303
399
|
|
|
304
|
-
To remove, run `npm uninstall @hailstails/hone`, delete the two `hone:` scripts, any vendored tarball, `disciplines.json`, `discipline-exceptions.json` and, with `eslint` clauses, `disciplines.eslint.mjs` and its spread in the flat config, and take the check out of the validation script.
|
|
400
|
+
To remove, run `npm uninstall @hailstails/hone`, delete the two `hone:` scripts, any vendored tarball, `disciplines.json`, `discipline-exceptions.json`, `disciplines.assessment.md` and, with `eslint` clauses, `disciplines.eslint.mjs` and its spread in the flat config, and take the check out of the validation script.
|
|
305
401
|
|
|
306
402
|
## Worked example
|
|
307
403
|
|
|
308
|
-
In the Hone source repository, `tests/test-fixtures/walkthrough/` is a small repository before and after its fix, selecting CD-2, CD-15, CD-17 and CD-23 through the audit, with a `generated/` folder excluded. `tests/walkthrough.integration.test.ts` pins both reports exactly.
|
|
404
|
+
In the Hone source repository, `tests/test-fixtures/walkthrough/` is a small repository before and after its fix, selecting CD-2, CD-15, CD-17 and CD-23 through the audit, with CD-2's ESLint-only `non-null-assertions` clause listed as `"not-run"`, because the repository has no ESLint, and a `generated/` folder excluded. `tests/walkthrough.integration.test.ts` pins both reports exactly, apart from where the rule pages are (see below).
|
|
309
405
|
|
|
310
406
|
Before, `npm run --silent hone:check` prints, and exits `1`:
|
|
311
407
|
|
|
312
408
|
```text
|
|
313
409
|
excluded (1)
|
|
314
410
|
generated
|
|
411
|
+
notRun (1)
|
|
412
|
+
CD-2#non-null-assertions adopted, mechanism not run: enforced by review
|
|
315
413
|
findings (5)
|
|
316
414
|
CD-17#clock-sources audit src/basket.ts:7:0 private openedAt = Date.now();
|
|
317
415
|
CD-2#cast-expressions audit src/basket.ts:10:20 entry as Line); } total(): string { let pence = 0; for (const line …
|
|
318
416
|
CD-15#loops audit src/basket.ts:15:0 for (const line of this.lines) {
|
|
319
417
|
CD-17#clock-sources audit src/basket.ts:22:0 return Date.now() - this.openedAt;
|
|
320
418
|
CD-23#export-test-sibling audit src/utils/format.ts:1:0 missing co-located *.test.ts(x) sibling
|
|
419
|
+
readFirst (5)
|
|
420
|
+
Start from each rule's Spirit below. disciplines.assessment.md, where this repository records its own causes, forward goal and steps for a clause, is not written yet; node_modules/@hailstails/hone/ADOPTING.md#5a-write-the-assessment says how to write it.
|
|
421
|
+
CD-17#clock-sources: read node_modules/@hailstails/hone/rules/CD-17/README.md#spirit
|
|
422
|
+
CD-2#cast-expressions: read node_modules/@hailstails/hone/rules/CD-2/README.md#spirit
|
|
423
|
+
CD-15#loops: read node_modules/@hailstails/hone/rules/CD-15/README.md#spirit
|
|
424
|
+
CD-23#export-test-sibling: read node_modules/@hailstails/hone/rules/CD-23/README.md#spirit
|
|
321
425
|
verdict: fail
|
|
322
426
|
```
|
|
323
427
|
|
|
428
|
+
The test runs against the source repository rather than an install, so the report it pins names the rule pages and the adoption guide from there: `../../../../rules/CD-17/README.md` and `../../../../ADOPTING.md` where an installed package prints `node_modules/@hailstails/hone/rules/CD-17/README.md` and `node_modules/@hailstails/hone/ADOPTING.md`.
|
|
429
|
+
|
|
324
430
|
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 an authorised location. After, the same command prints, and exits `0`:
|
|
325
431
|
|
|
326
432
|
```text
|
|
327
433
|
excluded (1)
|
|
328
434
|
generated
|
|
435
|
+
notRun (1)
|
|
436
|
+
CD-2#non-null-assertions adopted, mechanism not run: enforced by review
|
|
329
437
|
exempted (1)
|
|
330
438
|
CD-17#clock-sources audit src/clock.ts:3:0 export const createSystemClock = (): Clock => ({ now: () => Date.now() }); exempted by authorised-location
|
|
331
439
|
verdict: pass
|
|
@@ -334,6 +442,7 @@ verdict: pass
|
|
|
334
442
|
## Known gaps
|
|
335
443
|
|
|
336
444
|
- The worked example uses only the audit mechanism. The ESLint consumer in `tests/test-fixtures/consumer-proof/eslint/` is the tested ESLint setup.
|
|
337
|
-
- Each check flags exactly what its
|
|
338
|
-
- A snippet is the text the check reports; some checks report a fixed-width window that runs across lines, as CD-2 does above.
|
|
445
|
+
- Each check flags exactly what its CHECKS.md says and no more. Where a rule asks for more than its check can see, the page says which part is left to review.
|
|
446
|
+
- A snippet is the text the check reports; some checks report a fixed-width window that runs across lines, as CD-2 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.
|
|
447
|
+
- 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.
|
|
339
448
|
- 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/MIGRATING.md
CHANGED
|
@@ -31,7 +31,7 @@ Old code often holds CD-1 `any` the old route never checked. Hone flags it in st
|
|
|
31
31
|
|
|
32
32
|
Do [ADOPTING.md](ADOPTING.md) steps 1, 2 and 4 (and 4a for any `eslint` clause). A repository that used only Biome has no `eslint.config.*`: create `eslint.config.mjs` as step 4a shows before the first check, or the check stops with `runner-failed eslint team-config-unloadable`. Leave the old files in place until step 6.
|
|
33
33
|
|
|
34
|
-
Map each chosen discipline to its clauses with this table. A discipline is adopted whole: select every mechanical clause it lists, or the check reports the rest as `uncovered`.
|
|
34
|
+
Map each chosen discipline to its clauses with this table. A discipline is adopted whole: select every mechanical clause it lists, or the check reports the rest as `uncovered`. Where the rule binds but a clause's mechanism cannot work in this repository, such as an ESLint-only clause with no ESLint installed, list that clause as `"not-run"`; where the rule does not apply at all, list it as `"not-adopted"`. [ADOPTING.md](ADOPTING.md#4-write-disciplinesjson) step 4 sets out the clause values and the three declared states.
|
|
35
35
|
|
|
36
36
|
| Old CD | Clauses to select in `disciplines.json` |
|
|
37
37
|
| --- | --- |
|
|
@@ -40,7 +40,7 @@ Map each chosen discipline to its clauses with this table. A discipline is adopt
|
|
|
40
40
|
| CD-46 | nothing to select: it applies to every file carve-out once the check runs with `--base-revision` |
|
|
41
41
|
| CD-16, CD-20, CD-24 | select their owners, CD-15, CD-19 and CD-23 |
|
|
42
42
|
| CD-35, CD-36, CD-37, CD-38 | not in Hone; keep their current handling |
|
|
43
|
-
| any other CD | every mechanical clause in `node_modules/@hailstails/hone/rules/<ID>/
|
|
43
|
+
| any other CD | every mechanical clause in `node_modules/@hailstails/hone/rules/<ID>/CHECKS.md`'s Clauses table, with a mechanism that table lists |
|
|
44
44
|
|
|
45
45
|
Clauses whose mechanism is `review` are judgement clauses: do not put them in `disciplines.json`; list them in the agent instructions instead (step 6).
|
|
46
46
|
|
|
@@ -166,7 +166,7 @@ Stop and ask the human if anything outside the old trial uses the copied tools o
|
|
|
166
166
|
| CD-3 flags | merged into the shared `compilerOptions`, wherever they were | set only in a base file not named `tsconfig.json`; any of the seven in a `tsconfig.json` is a finding |
|
|
167
167
|
| Running with debt | the decay check needed a base ref | every run with a file carve-out needs `--base-revision`, unless it sets forfeiture `elsewhere`; every run with imported or legacy-chain records needs it either way |
|
|
168
168
|
| Debt decay (CD-46) | optional `rin-harness-carve-out-decay.ts` run | built into every check run with `--base-revision` |
|
|
169
|
-
| Stale and unrecorded exceptions | not checked | fail the run, including linter ignores
|
|
169
|
+
| Stale and unrecorded exceptions | not checked | fail the run, including linter ignores, `eslint-disable` comments and `@ts-expect-error`, `@ts-ignore` and `@ts-nocheck` directives with no record; an inline disable or directive is held by a file record on its clause and file, never by a clause-wide carve-out, and a lint-script option that weakens the run cannot be recorded at all |
|
|
170
170
|
| Path matching | old tools matched records by path suffix | exact repository paths |
|
|
171
171
|
| Linter | Biome, ESLint or oxlint for explicit `any` only | ESLint through the generated projection; Biome and oxlint are not Hone mechanisms |
|
|
172
172
|
| CD-8 exhaustive switch | typed ESLint `switch-exhaustiveness-check` suggested | the audit's `switch-defaults` clause only; type-aware linting is not supported |
|
|
@@ -232,7 +232,58 @@ Version `0.1.0-pre.1` was published as the GitHub release tarball `honed-0.1.0-p
|
|
|
232
232
|
| rule pages under `node_modules/honed/rules/` | `node_modules/@hailstails/hone/rules/` |
|
|
233
233
|
|
|
234
234
|
1. **Swap the package.** Run `npm uninstall honed`, then install `@hailstails/hone` as [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 says: `npm install --save-dev @hailstails/hone@next`, or the tarball attached to the latest [GitHub release](https://github.com/HailsTails/hone/releases). Remove the vendored `honed-0.1.0-pre.1.tgz` if the repository keeps one, or replace it with the new tarball. `typescript` is now a required peer, where `honed` declared it optional: if the repository root does not already declare it, npm 7 and later install the newest supported release on their own, so add it to `devDependencies` at the version the repository uses.
|
|
235
|
-
2. **Re-project straight away** if any clause is `eslint`, before the check, the linter or anything else runs: `npm run --silent hone:project`, then commit `disciplines.eslint.mjs`. Until then the committed projection still imports `honed/...`, which is no longer installed, so the repository's own ESLint cannot load its configuration and the check stops with `load failure: runner-failed eslint team-config-unloadable Cannot find package 'honed' imported from ...disciplines.eslint.mjs
|
|
235
|
+
2. **Re-project straight away** if any clause is `eslint`, before the check, the linter or anything else runs: `npm run --silent hone:project`, then commit `disciplines.eslint.mjs`. Until then the committed projection still imports `honed/...`, which is no longer installed, so the repository's own ESLint cannot load its configuration and the check stops with `load failure: runner-failed eslint team-config-unloadable eslint.config.mjs, the ESLint config for <file>, failed to load: Cannot find package 'honed' imported from ...disciplines.eslint.mjs ...` and exit 2. `hone project` does not load the old projection, so it runs and repairs it. Its import specifiers change from `honed/...` to `@hailstails/hone/...`, and its block names from `honed/...` to `hone-core/...`, in that same re-projection. The disciplines' rule ids `hone/...` and `hone-cd<N>/...` stay, so an `eslint-disable` comment, team config entry or suppression needs renaming only if it names `honed/inline-config`, which is now `hone-core/inline-config`.
|
|
236
236
|
3. **Keep the scripts.** `"hone:check": "hone check --repo ."` and `"hone:project": "hone project --repo ."` work unchanged, because the command is still `hone`.
|
|
237
237
|
4. **Repoint agent instructions** from `node_modules/honed/rules/` to `node_modules/@hailstails/hone/rules/`.
|
|
238
238
|
5. **Run the check.** It must give the same report as the last run under `honed`.
|
|
239
|
+
|
|
240
|
+
## 12. Moving off `waivedClauses`
|
|
241
|
+
|
|
242
|
+
Earlier releases let a repository record a `clause-wide-carve-out` and set `"assessment": { "waivedClauses": "not-run" }` in `disciplines.json`, or pass `--waived-clauses not-run`, so the carved-out clause was not run. That setting and that flag are gone. A clause now states this itself, in `clauses`. With either one still in place, `disciplines.json` is `file-malformed`, naming `waivedClauses` and the clause states to use, or the flag is `arguments-invalid`.
|
|
243
|
+
|
|
244
|
+
For each clause the setting skipped:
|
|
245
|
+
|
|
246
|
+
1. **Say what is true of it.** Set the clause to `"not-run"` when the rule binds but its check is not a true measure of the rule here, or cannot work here, such as CD-6's ESLint-only `naming-convention` with no ESLint installed: the report lists it under `notRun`, and the rule is owed through review. Set it to `"not-adopted"` when the rule does not apply to this codebase. If neither is true, and the clause is debt the codebase cannot pay right now, keep its mechanism and its carve-out, and let the check run; see [ADOPTING.md](ADOPTING.md#4-write-disciplinesjson) step 4.
|
|
247
|
+
2. **Delete its carve-out** from `discipline-exceptions.json` when the clause is now `"not-run"` or `"not-adopted"`: an entry on such a clause is invalid, as `clause-not-run` or `clause-not-adopted`, and fails the run.
|
|
248
|
+
3. **Remove the setting and the flag.** Delete `waivedClauses` from `assessment` in `disciplines.json`, and `--waived-clauses` from scripts, CI and the pre-push hook.
|
|
249
|
+
4. **Re-project** if any clause was `eslint`: run `npm run --silent hone:project`. The projection no longer carries the clause's rule or its `"off"` block; commit it.
|
|
250
|
+
5. **Run the check.** The `assessment` section's `waived-clauses` line is gone, and the verdict line is no longer marked `(partial assessment)` unless forfeiture is assessed elsewhere.
|
|
251
|
+
|
|
252
|
+
## 13. Moving to package projection slices
|
|
253
|
+
|
|
254
|
+
Earlier releases wrote one `disciplines.eslint.mjs` at the repository root, and every package config spread it. A package linted from its own folder resolves `files` against that folder, so the root projection's carve-outs never matched there. Hone now writes a slice per config root; see [README.md](README.md#package-slices).
|
|
255
|
+
|
|
256
|
+
1. **Refresh Hone** as [ADOPTING.md](ADOPTING.md#10-update-and-remove) step 10 says, and run the check. Under the nearest-to-file lookup, each folder with a tracked `eslint.config.*` is a config root, and the check fails with `eslint missing <package>/disciplines.eslint.mjs` for each until its slice is written.
|
|
257
|
+
2. **Project and commit.** Run `npm run --silent hone:project` and commit every `disciplines.eslint.mjs` it writes, the root one and each package's.
|
|
258
|
+
3. **Spread each package's own slice.** In each package config, import `./disciplines.eslint.mjs` from that package's folder and spread it last, in place of the root projection. A package still spreading the root projection is reported `eslint not-applied <package>/disciplines.eslint.mjs` once a recorded file there is under check.
|
|
259
|
+
4. **List generated configs.** A package whose `eslint.config.*` a tool generates and git ignores gets no slice until its folder is listed under `eslintConfigRoots` in `disciplines.json`. Each listed folder must be one git tracks files under, outside every `exclude` path, or the check stops with `config-root-untracked`.
|
|
260
|
+
5. **Repositories that move to the repository-root lookup after adopting slices.** A repository that was on the repository-root lookup from the start never had package slices, and can skip this step. One ESLint 9 run applies the root config to every file, so no package folder is a config root. `hone project` removes each package slice it wrote whose bytes it would still write, and reports any other as `left-in-place`. If anyone lints from a package folder, a package config that imports its slice then fails with `Cannot find module`: list that package under `eslintConfigRoots` to keep its slice, or stop importing it there.
|
|
261
|
+
6. **Folders holding their own `disciplines.json`** get no slice: their ESLint configuration is not managed from this repository, as nested Hone configurations are not supported yet ([#72](https://github.com/HailsTails/hone/issues/72)). When such a folder's own config leaves a carve-out recorded there out of effect, the `mechanism-not-run eslint not-included` line adds it. Governing the folder from this repository works today: remove its `disciplines.json`, keep its records here, and `hone project` writes its slice.
|
|
262
|
+
|
|
263
|
+
## 14. Moving to recorded inline exceptions
|
|
264
|
+
|
|
265
|
+
Earlier releases reported an `eslint-disable` comment naming a selected rule as an `inline-disable` no record could cover, and did not report TypeScript directives at all. Inline exceptions are now debt on the clause they escape, in their file, held by the file records you already write.
|
|
266
|
+
|
|
267
|
+
1. **Refresh Hone** as [ADOPTING.md](ADOPTING.md#10-update-and-remove) step 10 says, and run the check. Each `@ts-expect-error`, `@ts-ignore` and `@ts-nocheck` in a `.ts` or `.tsx` file is listed under `unrecorded` as `CD-2#cast-expressions audit inline-disable <file>:<line> <comment>`, test files included, and each `eslint-disable` as before.
|
|
268
|
+
2. **Remove what you can.** A directive or disable that hides nothing is cheaper to delete than to record.
|
|
269
|
+
3. **Record the rest per clause and file.** Add a `file-carve-out` for debt, or an `authorised-location` where the clause truly does not apply to that file, on the clause the line names and that file. One record holds every inline exception of that clause in the file. A `clause-wide-carve-out` does not hold them, and a tracked reference on the comment (CD-5) does not stand in for the record. Editing a carved file forfeits the carve-out, and each inline exception it held is listed again.
|
|
270
|
+
4. **Name the rule in a bare disable.** An `eslint-disable` naming no rule escapes every selected ESLint clause and needs a record for each. Its lines end `names no rule and escapes every selected clause: naming the rule is the cheap fix`.
|
|
271
|
+
5. **Fix lint-script options.** A `command-line-option` line that ends `weakens the script's whole run, so no record can cover it: remove it from the script` names an option to remove. One that ends `is not the first command of its script, so Hone cannot tell what the option does to the files under check; give <command> a script of its own, such as "<invocation>"` names a script such as `tsc && eslint -c eslint.config.mjs .`: move the quoted command to a script of its own, then run the check again. One that ends `comes before <command> and is neither a package runner nor a NAME=value setting, so Hone cannot tell what the option does to the files under check; put only package runners and NAME=value settings before <command>` quotes the first token Hone does not read, such as `env` or a runner flag like `-y`: rewrite the command so only package runners and `NAME=value` settings, including `cross-env NAME=value`, come before `eslint`. `-c` naming the config ESLint already finds, and `--ignore-pattern` that ignores no checked file, are not reported once `eslint` runs plainly.
|
|
272
|
+
6. **Stale records may clear.** A record that holds a native exception it can cover now counts as used. An `authorised-location` or `file-carve-out` that held only a `config-override`, and was listed `stale` while dropping it left the override unrecorded, is no longer stale.
|
|
273
|
+
7. **Standalone runners** written outside Hone return `{ hits, nativeExceptions }` from `run`, where `nativeExceptions` holds only `inline-disable` entries with `reach`, in place of a bare list of hits. A runner still returning the list fails with `runner-invalid-output` naming that shape.
|
|
274
|
+
|
|
275
|
+
## 15. Adopting `CD-2#non-null-assertions`
|
|
276
|
+
|
|
277
|
+
CD-2 gained a clause, `CD-2#non-null-assertions`, checked through `eslint` only. It flags non-null assertions, `x!`, and definite assignment assertions, `let x!: T` and `field!: T`; see [rules/CD-2/CHECKS.md](rules/CD-2/CHECKS.md). A repository that selects any CD-2 clause has adopted CD-2, so after refreshing Hone its check fails with this line under `uncovered` until `disciplines.json` lists the new clause:
|
|
278
|
+
|
|
279
|
+
```text
|
|
280
|
+
CD-2#non-null-assertions
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Choose one state for it, as [ADOPTING.md](ADOPTING.md#4-write-disciplinesjson) step 4 sets out:
|
|
284
|
+
|
|
285
|
+
1. **The repository runs the ESLint mechanism.** Add `"CD-2#non-null-assertions": "eslint"` to `clauses`, then run `npm run --silent hone:project` and commit `disciplines.eslint.mjs`, and each package slice it writes. Run the check. Each existing `!` is a finding; fix it, or hold it as debt with a `file-carve-out` per file, or a `clause-wide-carve-out` with an owner, after the human approves, and re-run `hone:project` so the projection carries the records. An `eslint-disable` naming no rule now escapes this clause too, and is listed under `unrecorded` for it until a file record on this clause holds it, as section 14 says; naming the rule it means is the cheap fix.
|
|
286
|
+
2. **The repository has no ESLint, or the rule binds but its check is not a true measure here.** Add `"CD-2#non-null-assertions": "not-run"`. The report lists it under `notRun`, and review owes the rule. Nothing is projected and ESLint is not loaded for it.
|
|
287
|
+
3. **The rule does not apply to this codebase.** A tech lead says so in the open, and the clause is listed as `"not-adopted"`. The report lists it under `notAdopted`.
|
|
288
|
+
|
|
289
|
+
Neither `"not-run"` nor `"not-adopted"` takes an exception record. Stop and ask the human before choosing `"not-adopted"`, or before recording carve-outs for existing `!` sites.
|