@hailstails/hone 0.1.0-pre.4 → 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.
Files changed (150) hide show
  1. package/ADOPTING.md +172 -38
  2. package/MIGRATING.md +58 -7
  3. package/README.md +117 -35
  4. package/THIRD-PARTY-NOTICES.md +1 -1
  5. package/api/audit.d.ts +3 -2
  6. package/api/rule-set.d.ts +2 -4
  7. package/chunks/chunk-3HFJHJDO.js +53 -0
  8. package/chunks/chunk-5LCLBXP7.js +76 -0
  9. package/chunks/{chunk-BX6QHLSZ.js → chunk-ET5EBSJX.js} +61 -6
  10. package/chunks/chunk-LDQUT742.js +15 -0
  11. package/chunks/{chunk-RZA3OVOO.js → chunk-LOYT2AGY.js} +10 -9
  12. package/chunks/chunk-MVK5KFJI.js +421 -0
  13. package/chunks/{chunk-FOAGAYXM.js → chunk-NCDYOPHG.js} +7224 -2361
  14. package/chunks/chunk-WPRR2MPJ.js +22 -0
  15. package/chunks/{chunk-EYCRDEXX.js → chunk-XB4PCY3Q.js} +2 -13
  16. package/core/check/tool-command.js +1130 -230
  17. package/core/mechanism-port/piece-failure-types.d.ts +14 -0
  18. package/core/mechanism-port/runner-module-types.d.ts +5 -0
  19. package/core/rule-set-reader/authored-rule-set-types.d.ts +48 -0
  20. package/core/values/json-value.d.ts +3 -0
  21. package/docs/adding-a-discipline-or-mechanism.md +29 -13
  22. package/docs/extending.md +358 -0
  23. package/docs/output-contract.md +326 -0
  24. package/mechanisms/audit/CD-1/any-cast.js +9 -37
  25. package/mechanisms/audit/CD-19/import-boundaries.js +79 -68
  26. package/mechanisms/audit/CD-19/piece.json +5 -0
  27. package/mechanisms/audit/CD-2/cast-expressions.js +14 -37
  28. package/mechanisms/audit/CD-2/piece.json +6 -1
  29. package/mechanisms/audit/CD-5/comments-directives.js +121 -55
  30. package/mechanisms/audit/CD-5/piece.json +7 -0
  31. package/mechanisms/audit/runner/README.md +4 -2
  32. package/mechanisms/audit/runner/runner.js +102 -36
  33. package/mechanisms/audit/runner/typescript-parse.d.ts +6 -0
  34. package/mechanisms/audit/runner/walker-piece.d.ts +5 -5
  35. package/mechanisms/eslint/CD-2/README.md +12 -0
  36. package/mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js +16 -0
  37. package/mechanisms/eslint/CD-2/piece.json +25 -0
  38. package/mechanisms/eslint/runner/README.md +12 -5
  39. package/mechanisms/eslint/runner/runner.js +940 -232
  40. package/methods/README.md +2 -0
  41. package/methods/assessment-template.md +35 -0
  42. package/methods/lenses/clean-architecture.md +2 -2
  43. package/methods/lenses/decomposition.md +2 -2
  44. package/methods/lenses/defended-on-intent.md +7 -7
  45. package/methods/lenses/di-discipline.md +38 -26
  46. package/methods/lenses/errors-as-data.md +2 -2
  47. package/methods/lenses/function-first.md +2 -2
  48. package/methods/lenses/naming.md +2 -2
  49. package/methods/lenses/test-discipline.md +15 -13
  50. package/methods/lenses/type-soundness.md +2 -2
  51. package/methods/lenses/zod-boundary.md +2 -2
  52. package/package.json +5 -4
  53. package/rules/CD-1/CHECKS.md +37 -0
  54. package/rules/CD-1/README.md +17 -32
  55. package/rules/CD-1/discipline.json +16 -6
  56. package/rules/CD-10/CHECKS.md +49 -0
  57. package/rules/CD-10/README.md +21 -49
  58. package/rules/CD-11/CHECKS.md +13 -0
  59. package/rules/CD-11/README.md +14 -8
  60. package/rules/CD-12/CHECKS.md +13 -0
  61. package/rules/CD-12/README.md +14 -8
  62. package/rules/CD-13/CHECKS.md +13 -0
  63. package/rules/CD-13/README.md +14 -8
  64. package/rules/CD-14/CHECKS.md +49 -0
  65. package/rules/CD-14/README.md +22 -48
  66. package/rules/CD-15/CHECKS.md +40 -0
  67. package/rules/CD-15/README.md +22 -40
  68. package/rules/CD-16/CHECKS.md +7 -0
  69. package/rules/CD-16/README.md +3 -5
  70. package/rules/CD-17/CHECKS.md +37 -0
  71. package/rules/CD-17/README.md +17 -31
  72. package/rules/CD-18/CHECKS.md +13 -0
  73. package/rules/CD-18/README.md +15 -9
  74. package/rules/CD-19/CHECKS.md +49 -0
  75. package/rules/CD-19/README.md +18 -34
  76. package/rules/CD-19/discipline.json +6 -8
  77. package/rules/CD-2/CHECKS.md +56 -0
  78. package/rules/CD-2/README.md +19 -32
  79. package/rules/CD-2/discipline.json +93 -7
  80. package/rules/CD-20/CHECKS.md +7 -0
  81. package/rules/CD-20/README.md +3 -5
  82. package/rules/CD-21/CHECKS.md +13 -0
  83. package/rules/CD-21/README.md +14 -9
  84. package/rules/CD-22/CHECKS.md +13 -0
  85. package/rules/CD-22/README.md +13 -8
  86. package/rules/CD-23/CHECKS.md +35 -0
  87. package/rules/CD-23/README.md +14 -29
  88. package/rules/CD-24/CHECKS.md +7 -0
  89. package/rules/CD-24/README.md +3 -5
  90. package/rules/CD-25/CHECKS.md +38 -0
  91. package/rules/CD-25/README.md +20 -32
  92. package/rules/CD-26/CHECKS.md +36 -0
  93. package/rules/CD-26/README.md +18 -31
  94. package/rules/CD-27/CHECKS.md +45 -0
  95. package/rules/CD-27/README.md +18 -40
  96. package/rules/CD-28/CHECKS.md +13 -0
  97. package/rules/CD-28/README.md +14 -8
  98. package/rules/CD-29/CHECKS.md +13 -0
  99. package/rules/CD-29/README.md +12 -8
  100. package/rules/CD-3/CHECKS.md +42 -0
  101. package/rules/CD-3/README.md +20 -42
  102. package/rules/CD-30/CHECKS.md +13 -0
  103. package/rules/CD-30/README.md +13 -8
  104. package/rules/CD-31/CHECKS.md +13 -0
  105. package/rules/CD-31/README.md +12 -8
  106. package/rules/CD-32/CHECKS.md +13 -0
  107. package/rules/CD-32/README.md +13 -8
  108. package/rules/CD-33/CHECKS.md +13 -0
  109. package/rules/CD-33/README.md +13 -8
  110. package/rules/CD-34/CHECKS.md +13 -0
  111. package/rules/CD-34/README.md +12 -8
  112. package/rules/CD-39/CHECKS.md +13 -0
  113. package/rules/CD-39/README.md +13 -8
  114. package/rules/CD-4/CHECKS.md +13 -0
  115. package/rules/CD-4/README.md +15 -8
  116. package/rules/CD-40/CHECKS.md +39 -0
  117. package/rules/CD-40/README.md +17 -33
  118. package/rules/CD-41/CHECKS.md +54 -0
  119. package/rules/CD-41/README.md +23 -54
  120. package/rules/CD-42/CHECKS.md +47 -0
  121. package/rules/CD-42/README.md +19 -47
  122. package/rules/CD-43/CHECKS.md +37 -0
  123. package/rules/CD-43/README.md +15 -31
  124. package/rules/CD-44/CHECKS.md +48 -0
  125. package/rules/CD-44/README.md +20 -48
  126. package/rules/CD-45/CHECKS.md +13 -0
  127. package/rules/CD-45/README.md +14 -8
  128. package/rules/CD-46/CHECKS.md +7 -0
  129. package/rules/CD-46/README.md +16 -4
  130. package/rules/CD-47/CHECKS.md +37 -0
  131. package/rules/CD-47/README.md +16 -32
  132. package/rules/CD-5/CHECKS.md +52 -0
  133. package/rules/CD-5/README.md +22 -40
  134. package/rules/CD-5/discipline.json +66 -0
  135. package/rules/CD-6/CHECKS.md +51 -0
  136. package/rules/CD-6/README.md +22 -51
  137. package/rules/CD-7/CHECKS.md +46 -0
  138. package/rules/CD-7/README.md +23 -46
  139. package/rules/CD-7a/CHECKS.md +38 -0
  140. package/rules/CD-7a/README.md +14 -32
  141. package/rules/CD-8/CHECKS.md +42 -0
  142. package/rules/CD-8/README.md +20 -42
  143. package/rules/CD-9/CHECKS.md +13 -0
  144. package/rules/CD-9/README.md +15 -8
  145. package/rules/README.md +5 -3
  146. package/rules/SPIRIT.md +50 -0
  147. package/core/mechanism-port/runner-failure-types.d.ts +0 -38
  148. package/core/rule-set-reader/rule-set-types.d.ts +0 -41
  149. /package/api/{audit.js → audit.mjs} +0 -0
  150. /package/api/{rule-set.js → rule-set.mjs} +0 -0
@@ -0,0 +1,16 @@
1
+ import {
2
+ defaultNativeRuleSources,
3
+ eslintCoreRules
4
+ } from "../../../../chunks/chunk-HJA4CX7C.js";
5
+ import "../../../../chunks/chunk-NZLE2WMY.js";
6
+
7
+ // mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.ts
8
+ var createPlugin = (sources) => ({
9
+ meta: { name: "hone-cd2", version: "0.0.0-local" },
10
+ rules: eslintCoreRules({ names: ["no-restricted-syntax"], sources })
11
+ });
12
+ var cd2_eslint_plugin_default = createPlugin(defaultNativeRuleSources);
13
+ export {
14
+ createPlugin,
15
+ cd2_eslint_plugin_default as default
16
+ };
@@ -0,0 +1,25 @@
1
+ {
2
+ "version": 1,
3
+ "discipline": "CD-2",
4
+ "mechanism": "eslint",
5
+ "clauses": [
6
+ {
7
+ "clause": "non-null-assertions",
8
+ "settings": {
9
+ "pluginNamespace": "hone-cd2",
10
+ "pluginModule": "cd2/cd2.eslint-plugin.js",
11
+ "rule": "no-restricted-syntax",
12
+ "options": [
13
+ {
14
+ "selector": "TSNonNullExpression",
15
+ "message": "CD-2: a non-null assertion claims a value the compiler cannot see; narrow it with a check instead."
16
+ },
17
+ {
18
+ "selector": "[definite=true]",
19
+ "message": "CD-2: a definite assignment assertion claims an assignment the compiler cannot see; initialise the binding instead."
20
+ }
21
+ ]
22
+ }
23
+ }
24
+ ]
25
+ }
@@ -1,27 +1,34 @@
1
1
  # ESLint runner
2
2
 
3
- The ESLint runner is Hone's embedded mechanism: each selected clause runs as an ESLint rule inside the team's own ESLint setup. Its `exceptionPath` is `embedded`. Core hands it the selected clauses, the files to check, the repository's tracked paths and the exception records for this mechanism. The runner lints the files with its own configuration to find hits, reports every native channel in the team's setup that weakens a selected rule, and writes and checks the projection `disciplines.eslint.mjs` that carries the records into the team's own run. Its `projectedKinds` is `["config-override"]`, so a record can cover only that kind.
3
+ The ESLint runner is Hone's embedded mechanism: each selected clause runs as an ESLint rule inside the team's own ESLint setup. Its `exceptionPath` is `embedded`. Core hands it the selected clauses, the files to check, the repository's tracked paths and the exception records for this mechanism. The runner lints the files with its own configuration to find hits, reports every native channel in the team's setup that weakens a selected rule, and writes and checks the projection `disciplines.eslint.mjs`, one slice per config root, that carries the records into the team's own run. Its `projectedKinds` is `["config-override", "inline-disable"]`, so a record can cover only those kinds, and an `inline-disable` only by a file record on its clause and file.
4
4
 
5
5
  The native channels, the exception kind each maps to, and how the projection is adopted and checked are in [the guide](../../../docs/adding-a-discipline-or-mechanism.md#embedded-mechanisms).
6
6
 
7
- The check compares the committed projection byte for byte with what the runner would write now. Built core is the installed package: the runner reads the package's `package.json` for its name, and the projection imports each piece inside it by package name, `<name>/mechanisms/eslint/...`, which resolves wherever the package is installed. A `package.json` that cannot be read or names no package is a `tool-failed` failure. Core run from source, as in its own tests, imports each piece by its path relative to the repository root. A piece outside the install, in the repository's own rule set, is always imported by relative path.
7
+ The check compares the committed projection byte for byte with what the runner would write now. Built core is the installed package: the runner reads the package's `package.json` for its name, and the projection imports each piece inside it by package name, `<name>/mechanisms/eslint/...`, which resolves wherever the package is installed. A `package.json` that cannot be read or names no package is a `tool-failed` failure. Core run from source, as in its own tests, imports each piece by its path relative to the folder the slice is written in. A piece outside the install, in the repository's own rule set, is always imported by relative path, and a piece on another drive from a slice's folder fails as `piece-invalid`.
8
+
9
+ The config roots are the repository root, every folder holding a tracked `eslint.config.*` when the team's lookup is nearest-to-file, and every folder core passes as a declared config root, less any folder at or under a folder with a tracked `disciplines.json`, because nested Hone configurations are not supported yet ([#72](https://github.com/HailsTails/hone/issues/72)). Under the nearest-to-file lookup, when the projection is not in effect, `run` names each outermost such folder holding files under check whose own config leaves a record of this repository out of effect, or the selected rule off, as a `nested-configuration` slice; core names the folder on the `mechanism-not-run` entry it explains, not as a projection problem. Core reads and validates `eslintConfigRoots` from `disciplines.json` and passes the folders in the request as `declaredConfigRoots`; the runner never reads them itself. Each root's slice is `disciplines.eslint.mjs` in that folder. The root slice holds every record; a package slice holds the records for files under its folder, re-pathed relative to it and glob-escaped as in the root, and every clause-wide carve-out. A file belongs to the deepest root containing it. `project` writes every slice, then, for each tracked `disciplines.eslint.mjs` in a folder that is no longer a root, regenerates the slice that folder would get and removes the file only when its bytes match that text, so it never deletes a file it did not write; otherwise it reports `left-in-place`. `project` renders and reads every slice and orphan before it writes or removes anything, so a failure part-way changes nothing. `run` reports each package slice that is `missing` or `out-of-date`, each declared root with no `eslint.config.*` on disk as `unconfigured`, and, under the nearest-to-file lookup when the projection is not in effect, each package root whose own recorded files under check are not excepted as `not-applied`, grouping the checked files by their governing root once. Every config root gets and keeps its slice whatever a config above it ignores: a lint run from that folder loads its own config and never reads the ignores of the configs above it, so `project` writes the same slices from the same inputs every time. `not-applied` judges each recorded file through the same per-file query as every other judgement, which resolves the file from its nearest config, the one a lint run from its package loads. A root-only repository's projection is unchanged.
8
10
 
9
11
  ## Runtime
10
12
 
11
13
  - From source, Node 22.18.0 or later, which runs the `.ts` modules directly by stripping types. The built package is plain JavaScript.
12
14
  - `zod`, for the piece settings, the loaded plugin, ESLint's resolved configuration and the files the runner reads. A dependency of core.
13
15
  - `@eslint/plugin-kit`, for parsing inline configuration comments. A dependency of core, pinned at 0.7.3, because a transitive copy does not resolve under strict package managers.
14
- - The repository's own toolchain, as optional peers: `eslint` `^9.12.0 || ^10.0.0`, and `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin` `^8.56.0`, the first typescript-eslint release whose peer range accepts both ESLint majors. TypeScript is the parser's own peer, so the runner does not check it. The runner loads them once, when it is loaded, and answers every call with `toolchain-unavailable` naming the first that is missing, cannot load or is out of range, or with `toolchain-shadowed` when one resolves from inside the installed core package, before it loads any piece. The suite runs on four lines: ESLint 9.12.0 and 10.0.0 with typescript-eslint 8.56.0, and ESLint 9.39.5 and 10.11.0 with 8.71.2.
16
+ - The repository's own toolchain, as optional peers: `eslint` `^9.28.0 || ^10.0.0`, and `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin` `^8.56.0`, the first typescript-eslint release whose peer range accepts both ESLint majors. TypeScript is the parser's own peer, so the runner does not check it. The runner loads all three once, when it is loaded, and answers every call with `toolchain-unavailable` naming each that is missing, cannot load or is out of range, or with `toolchain-shadowed` when one resolves from inside the installed core package, before it loads any piece. The suite runs on four lines: ESLint 9.28.0 and 10.0.0 with typescript-eslint 8.56.0, and ESLint 9.39.5 and 10.11.0 with 8.71.2.
15
17
 
16
18
  ## Files
17
19
 
18
- - `create-eslint-runner.ts` builds the runner from its ports: file text, module loading, paths and ESLint. It implements `run`, `conform` and `project`.
20
+ - `create-eslint-runner.ts` builds the runner from its ports: file text, file removal, module loading, paths and ESLint. It implements `run`, `conform` and `project`.
19
21
  - `eslint-toolchain.ts` loads the toolchain for core's own ESLint run by dynamic imports of `eslint`, `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin`, so a missing one becomes a named failure. It first asks where each resolves and fails as `toolchain-shadowed` for a copy inside the installed core package, then checks each version against its range, and hands the loaded `ESLint` class to `eslint-instance.ts`, which builds `createEslint` for that version. Core passes only options every supported release accepts: on ESLint 9 it asks for the nearest-to-file configuration lookup with the flag that release names, `unstable_config_lookup_from_file` before 9.30.0 and `v10_config_lookup_from_file` from 9.30.0, and ESLint 10 looks up that way by default. It never passes `applySuppressions`, which ESLint 9 and 10.0.0 refuse and which 10.11.0 accepts with a default of off.
20
22
  - `eslint-instance.ts` is the port over a loaded toolchain, and takes only types from `eslint` and `@typescript-eslint/parser`. It builds `createEslint` on the loaded `ESLint` class and maps ESLint's results into the runner's own types. It builds a query instance on the team's own configuration, a governance instance on the runner's configuration only, and `lintSourceCases` for conformance. It also defines the reserved rule `<reservedNamespace>/inline-config`. `reservedNamespace` is the `reservedEslintNamespace` field of `core/values/tool-identity.ts`, currently `hone-core`, Hone's own namespace, distinct from every piece's `hone` and `hone-cd<N>` and independent of the package name; the reserved rule, the governance configuration and the projection's block names all take it from there.
23
+ - `governing-config.ts` decides, when a nested `eslint.config.*` fails to load, whether the team's own ESLint would ever enter its folder. It asks the config governing that folder, then each config above it up to the repository root, whether it ignores that folder and then the file. `governingConfigIgnores` answers one such question, for a file or a folder, telling a real ignore from a path no `files` block matches; `cachedGoverningIgnores` asks each config about each path once, only when first needed.
21
24
  - `inline-config-parser.ts` is the wrapping factory for `@eslint/plugin-kit`, the only file that imports it.
22
25
  - `native-rules.ts` re-exports the ESLint core rules (`eslintCoreRules`) and the typescript-eslint rules (`typescriptEslintRules`) that pieces reuse. It is the only file that imports them, and it imports `eslint/use-at-your-own-risk` and `@typescript-eslint/eslint-plugin` statically, resolved upward from the install like the toolchain.
23
- - `projection.ts` writes `disciplines.eslint.mjs` and compares it with the file on disk.
26
+ - `projection.ts` renders a projection's text, and writes and compares one projection file.
27
+ - `projection-slices.ts` finds the config roots for a lookup, names each root's slice, picks and re-paths each slice's records, finds the package root governing a file, and finds tracked slices outside every root.
28
+ - `sliced-projection.ts` renders each root's slice, reports stale package slices, and plans then writes, removes or leaves slices for `project`.
29
+ - `config-lookup.ts` reads `eslintConfigLookup` from `disciplines.json`, and decides which config the team's ESLint run applies.
24
30
  - `package-script-scanner.ts` finds ESLint invocations in tracked `package.json` scripts, and the options and `--suppressions-location` values they carry.
31
+ - `script-option-effect.ts` judges whether a `-c`, `--config` or `--ignore-pattern` option changes what ESLint does to the checked files under its script's folder. Only one that the folder settles as changing nothing is not reported. An invocation settles only when it is plain: the first command of its script, with nothing before `eslint` but a package runner, `NAME=value` assignments, or `cross-env` followed only by `NAME=value` assignments, and no token after it that the shell expands or that reaches outside the folder. Anything else is reported.
25
32
  - `suppressions-scanner.ts` reads suppression entries from `eslint-suppressions.json` files and from files named by `--suppressions-location`.
26
33
  - `eslint-piece-settings-schema.ts`, `eslint-plugin-schema.ts`, `eslint-config-schema.ts` and `eslint-file-schemas.ts` hold the schemas for a piece's settings, a loaded plugin module, ESLint's resolved configuration, and `package.json` and suppressions files.
27
34
  - `runner.ts` is the runner core loads: the default ports, bound to the toolchain loaded from the install's own resolution.