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

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 (282) hide show
  1. package/ADOPTING.md +9 -20
  2. package/CHANGELOG.md +104 -0
  3. package/MIGRATING.md +18 -9
  4. package/README.md +15 -17
  5. package/chunks/chunk-3CWFUD5B.js +38 -0
  6. package/chunks/chunk-4AJQHZ7I.js +191 -0
  7. package/chunks/chunk-5AKHEW6V.js +15 -0
  8. package/chunks/{chunk-L7BGRC6D.js → chunk-6LTJRJOE.js} +1 -1
  9. package/chunks/chunk-75XWZYNN.js +64 -0
  10. package/chunks/{chunk-ASUN4AVC.js → chunk-BISP2JOL.js} +73 -9
  11. package/chunks/chunk-COQMPHWZ.js +37 -0
  12. package/chunks/chunk-D6645WPB.js +6 -0
  13. package/chunks/chunk-DJMF6JIM.js +42 -0
  14. package/chunks/chunk-EBX57Z3V.js +8 -0
  15. package/chunks/chunk-EFUWHLZK.js +426 -0
  16. package/chunks/chunk-FHVNKG5Q.js +19 -0
  17. package/chunks/{chunk-NRIQD3PI.js → chunk-FRE5IA3C.js} +3 -5
  18. package/chunks/{chunk-OKLYWD2Z.js → chunk-GMLT3MHO.js} +262 -257
  19. package/chunks/{chunk-QP5TLOBY.js → chunk-HVZVKZPW.js} +12 -9
  20. package/chunks/chunk-LEFM7OPS.js +41 -0
  21. package/chunks/chunk-LNMDMRGQ.js +51 -0
  22. package/chunks/chunk-M4VSJ27S.js +139 -0
  23. package/chunks/{chunk-RGSHTPLA.js → chunk-MBEDAFVC.js} +3 -11
  24. package/chunks/chunk-ND3EOGDK.js +2350 -0
  25. package/chunks/chunk-ONDBACCR.js +14332 -0
  26. package/chunks/chunk-OO5KV7KN.js +17 -0
  27. package/chunks/chunk-SKDQ3QJD.js +75 -0
  28. package/chunks/chunk-U6W65ZOF.js +86 -0
  29. package/chunks/chunk-W5OIAUDW.js +18 -0
  30. package/chunks/{chunk-GNOMK7CR.js → chunk-WPEOCLTP.js} +495 -52
  31. package/chunks/chunk-X73RZUPO.js +63 -0
  32. package/chunks/chunk-XE2KKWYH.js +45 -0
  33. package/chunks/chunk-XNIXPQQ5.js +179 -0
  34. package/chunks/chunk-YONPKP3C.js +15 -0
  35. package/docs/adding-a-discipline-or-mechanism.md +1 -1
  36. package/docs/extending.md +7 -388
  37. package/methods/lenses/function-first.md +2 -2
  38. package/package.json +7 -6
  39. package/rules/README.md +7 -5
  40. package/rules/SPIRIT.md +1 -1
  41. package/rules/numbers.md +4 -4
  42. package/rules/principles/no-leak-across-a-boundary.md +1 -1
  43. package/rules/principles.md +1 -1
  44. package/rules/record-kinds/authorised-location.md +1 -1
  45. package/rules/records.md +11 -19
  46. package/rules/rules.md +5 -5
  47. package/rules/sources.md +6 -7
  48. package/rules/typescript/checks.md +280 -394
  49. package/rules/typescript/recipes/adapter-per-outside-party.md +10 -5
  50. package/rules/typescript/recipes/assert-to-narrow.md +114 -4
  51. package/rules/typescript/recipes/closure-factory.md +5 -5
  52. package/rules/typescript/recipes/companion-test-file.md +5 -3
  53. package/rules/typescript/recipes/composed-orchestrator.md +6 -4
  54. package/rules/typescript/recipes/composition-root.md +5 -3
  55. package/rules/typescript/recipes/{bounded-context-generic.md → constrained-context-generic.md} +6 -4
  56. package/rules/typescript/recipes/copy-never-write-in.md +6 -4
  57. package/rules/typescript/recipes/declared-not-bundled.md +5 -3
  58. package/rules/typescript/recipes/dependency-record.md +5 -3
  59. package/rules/typescript/recipes/domain-vocabulary-list.md +5 -3
  60. package/rules/typescript/recipes/entity-module.md +8 -5
  61. package/rules/typescript/recipes/exact-pins-and-a-lock-file.md +5 -3
  62. package/rules/typescript/recipes/extension-outside-the-vendored-code.md +5 -3
  63. package/rules/typescript/recipes/failure-asserted-as-a-value.md +44 -4
  64. package/rules/typescript/recipes/failure-mapping-at-the-adapter.md +8 -5
  65. package/rules/typescript/recipes/fix-the-declaration-not-the-value.md +5 -3
  66. package/rules/typescript/recipes/functional-iteration.md +8 -3
  67. package/rules/typescript/recipes/guard-clauses.md +5 -3
  68. package/rules/typescript/recipes/integration-test-owns-its-scratch.md +5 -3
  69. package/rules/typescript/recipes/integration-test-suffix.md +5 -3
  70. package/rules/typescript/recipes/it-each-over-typed-rows.md +117 -0
  71. package/rules/typescript/recipes/map-out-at-the-adapter.md +36 -4
  72. package/rules/typescript/recipes/meaning-in-names-not-comments.md +5 -5
  73. package/rules/typescript/recipes/named-exported-type.md +5 -3
  74. package/rules/typescript/recipes/narrow-ports.md +5 -3
  75. package/rules/typescript/recipes/one-argument-object.md +8 -3
  76. package/rules/typescript/recipes/{port-in-the-domain.md → port-in-a-module-of-its-own.md} +7 -5
  77. package/rules/typescript/recipes/ports-in-the-argument.md +5 -3
  78. package/rules/typescript/recipes/repo-scripts-only.md +5 -3
  79. package/rules/typescript/recipes/result-union.md +5 -5
  80. package/rules/typescript/recipes/screaming-folders.md +5 -5
  81. package/rules/typescript/recipes/shared-strict-base-config.md +5 -5
  82. package/rules/typescript/recipes/stub-with-vi-fn.md +130 -0
  83. package/rules/typescript/recipes/tagged-union-and-exhaustive-switch.md +5 -3
  84. package/rules/typescript/recipes/whole-words.md +5 -3
  85. package/rules/typescript/recipes/whole-written-out-expectation.md +284 -4
  86. package/rules/typescript/recipes/world-values-through-a-port.md +5 -3
  87. package/rules/typescript/recipes/zod-at-the-producers-adapter.md +8 -3
  88. package/rules/typescript/recipes.md +567 -21
  89. package/rules/typescript/symptoms/ambient-randomness/random-call.md +10 -0
  90. package/rules/typescript/symptoms/ambient-randomness.md +1 -1
  91. package/rules/typescript/symptoms/answer-set-in-a-hook/hook-answer.md +10 -0
  92. package/rules/typescript/symptoms/answer-set-in-a-hook.md +1 -1
  93. package/rules/typescript/symptoms/assertion-outside-a-test-body/assertion-site.md +10 -0
  94. package/rules/typescript/symptoms/assertion-outside-a-test-body.md +25 -0
  95. package/rules/typescript/symptoms/branch-in-a-test/test-body.md +10 -184
  96. package/rules/typescript/symptoms/branch-in-a-test.md +11 -1
  97. package/rules/typescript/symptoms/built-unit-called-in-place/call-of-a-call.md +10 -0
  98. package/rules/typescript/symptoms/built-unit-called-in-place.md +25 -0
  99. package/rules/typescript/symptoms/claimed-type/non-null-assertions.md +1 -1
  100. package/rules/typescript/symptoms/code-or-prose-read-as-text-in-a-test/raw-read.md +10 -0
  101. package/rules/typescript/symptoms/code-or-prose-read-as-text-in-a-test.md +31 -0
  102. package/rules/typescript/symptoms/computed-value-in-a-test/test-body.md +26 -117
  103. package/rules/typescript/symptoms/computed-value-in-a-test.md +1 -1
  104. package/rules/typescript/symptoms/date-used-directly.md +1 -1
  105. package/rules/typescript/symptoms/default-for-a-required-value.md +1 -1
  106. package/rules/typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md +2 -19
  107. package/rules/typescript/symptoms/double-with-a-body/stub-implementation.md +2 -2
  108. package/rules/typescript/symptoms/double-with-a-body.md +1 -1
  109. package/rules/typescript/symptoms/export-from-a-test/test-file-export.md +10 -0
  110. package/rules/typescript/symptoms/export-from-a-test.md +33 -0
  111. package/rules/typescript/symptoms/failure-shaped-as-success/empty-catch.md +10 -0
  112. package/rules/typescript/symptoms/failure-shaped-as-success.md +1 -1
  113. package/rules/typescript/symptoms/floating-version/version-selector.md +10 -0
  114. package/rules/typescript/symptoms/inherited-environment-in-a-subprocess/git-spawn-environment.md +2 -2
  115. package/rules/typescript/symptoms/inner-layer-imports-outer.md +1 -1
  116. package/rules/typescript/symptoms/library-class-built-in-place.md +1 -1
  117. package/rules/typescript/symptoms/loop-keyword/loop-statement.md +1 -1
  118. package/rules/typescript/symptoms/many-spellings-of-one-concept/test-call-aliases.md +10 -0
  119. package/rules/typescript/symptoms/many-spellings-of-one-concept.md +3 -2
  120. package/rules/typescript/symptoms/module-or-global-patched/module-mock-call.md +4 -4
  121. package/rules/typescript/symptoms/no-lock-file/committed-lock-file.md +12 -0
  122. package/rules/typescript/symptoms/outside-import-past-a-boundary/import-or-require.md +1 -0
  123. package/rules/typescript/symptoms/outside-import-past-a-boundary.md +5 -4
  124. package/rules/typescript/symptoms/outside-type-in-a-signature.md +2 -2
  125. package/rules/typescript/symptoms/{port-outside-the-domain.md → port-beside-its-adapter.md} +2 -2
  126. package/rules/typescript/symptoms/port-named-for-a-mechanism.md +1 -1
  127. package/rules/typescript/symptoms/process-global-used-in-place/debugger-statement.md +10 -0
  128. package/rules/typescript/symptoms/process-global-used-in-place/direct-global-use.md +14 -0
  129. package/rules/typescript/symptoms/process-global-used-in-place.md +2 -2
  130. package/rules/typescript/symptoms/prose-in-code/comment-prose.md +12 -0
  131. package/rules/typescript/symptoms/rebinding/test-body.md +1 -18
  132. package/rules/typescript/symptoms/rebinding.md +11 -1
  133. package/rules/typescript/symptoms/schema-past-its-adapter.md +2 -2
  134. package/rules/typescript/symptoms/test-switched-off/skipped-tests.md +3 -6
  135. package/rules/typescript/symptoms/test-switched-off.md +1 -1
  136. package/rules/typescript/symptoms/text-past-its-reader/test-body.md +2 -17
  137. package/rules/typescript/symptoms/text-past-its-reader.md +1 -1
  138. package/rules/typescript/symptoms/throw-between-our-units/throw-statement.md +10 -0
  139. package/rules/typescript/symptoms/throw-or-catch-in-a-test/throw-statement.md +1 -1
  140. package/rules/typescript/symptoms/throw-or-catch-in-a-test/try-block.md +1 -25
  141. package/rules/typescript/symptoms/tool-fetched-at-run-time/fetch-command.md +10 -0
  142. package/rules/typescript/symptoms/type-declared-in-a-test/test-type-declaration.md +10 -0
  143. package/rules/typescript/symptoms/type-declared-in-a-test.md +33 -0
  144. package/rules/typescript/symptoms/unasserted-call.md +1 -1
  145. package/rules/typescript/symptoms/unit-without-a-running-test/companion-test-file.md +2 -2
  146. package/rules/typescript/symptoms/wide-input/unread-parameter.md +10 -0
  147. package/rules/typescript/symptoms/wide-input.md +3 -2
  148. package/rules/typescript/symptoms.md +210 -148
  149. package/src/application/conformance/conformance-testing-types.d.ts +13 -16
  150. package/src/domain/language-layer/authored-item-types.d.ts +66 -0
  151. package/src/domain/language-layer/catalogue-name.d.ts +5 -0
  152. package/src/domain/language-layer/check-address-text.d.ts +12 -0
  153. package/src/domain/rule-set/authored-rule-set-types.d.ts +31 -32
  154. package/src/domain/rule-set/clause-address-types.d.ts +4 -3
  155. package/src/domain/rule-set/rule-set-name-of.d.ts +10 -0
  156. package/src/domain/runner/check-binding.d.ts +18 -0
  157. package/src/domain/runner/check-observations.d.ts +39 -0
  158. package/src/domain/runner/conformance-types.d.ts +8 -2
  159. package/src/domain/runner/runner-result-types.d.ts +1 -2
  160. package/src/domain/settings/test-files.d.ts +7 -0
  161. package/src/eslint-plugin.js +45 -39
  162. package/src/hone.js +16 -13716
  163. package/src/infrastructure/disciplines-file/version-one-names.json +4 -5
  164. package/src/infrastructure/engines/eslint/authored-class-or-this/static-members-only/piece.json +0 -6
  165. package/src/infrastructure/engines/eslint/long-function/function-length/piece.json +0 -6
  166. package/src/infrastructure/engines/eslint/runner/pieces/eslint-piece-settings-types.d.ts +2 -0
  167. package/src/infrastructure/engines/eslint/runner/runner.js +1001 -1234
  168. package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/README.md +0 -3
  169. package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/eslint-plugin.js +33 -21
  170. package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/piece.json +11 -4
  171. package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/skipped-tests.examples.json +28 -0
  172. package/src/infrastructure/engines/eslint/untyped-value/implicit-any-let/piece.json +0 -2
  173. package/src/infrastructure/engines/eslint/wide-input/unread-parameter/eslint-plugin.js +94 -0
  174. package/src/infrastructure/engines/eslint/wide-input/unread-parameter/piece.json +11 -0
  175. package/src/infrastructure/engines/eslint/wide-input/unread-parameter/unread-parameter.examples.json +48 -0
  176. package/src/infrastructure/engines/walker/ambient-randomness/random-call/ambient-randomness.js +109 -0
  177. package/src/infrastructure/engines/walker/ambient-randomness/random-call/piece.json +9 -0
  178. package/src/infrastructure/engines/walker/ambient-randomness/random-call/random-call.examples.json +48 -0
  179. package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/hook-answer.examples.json +42 -0
  180. package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/hook-answers.js +72 -0
  181. package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/piece.json +9 -0
  182. package/src/infrastructure/engines/walker/assertion-outside-a-test-body/assertion-site/assertion-site.examples.json +30 -0
  183. package/src/infrastructure/engines/walker/assertion-outside-a-test-body/assertion-site/assertion-site.js +123 -0
  184. package/src/infrastructure/engines/walker/assertion-outside-a-test-body/assertion-site/piece.json +9 -0
  185. package/src/infrastructure/engines/walker/authored-class-or-this/class-keyword/class-syntax.js +3 -3
  186. package/src/infrastructure/engines/walker/boolean-in-a-signature/boolean-annotation/boolean-signatures.js +7 -5
  187. package/src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body-logic.js +192 -147
  188. package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/call-of-a-call.examples.json +24 -0
  189. package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/call-of-a-call.js +34 -0
  190. package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/piece.json +9 -0
  191. package/src/infrastructure/engines/walker/claimed-type/cast-to-any/any-cast.js +6 -4
  192. package/src/infrastructure/engines/walker/claimed-type/unlisted-cast-site/cast-expressions.js +6 -4
  193. package/src/infrastructure/engines/walker/code-or-prose-read-as-text-in-a-test/raw-read/piece.json +9 -0
  194. package/src/infrastructure/engines/walker/code-or-prose-read-as-text-in-a-test/raw-read/raw-read.examples.json +30 -0
  195. package/src/infrastructure/engines/walker/code-or-prose-read-as-text-in-a-test/raw-read/raw-read.js +166 -0
  196. package/src/infrastructure/engines/walker/computed-value-in-a-test/test-body/piece.json +0 -10
  197. package/src/infrastructure/engines/walker/date-used-directly/clock-sources/clock-sources.js +4 -4
  198. package/src/infrastructure/engines/walker/default-on-a-closed-union/default-arm/switch-defaults.js +8 -6
  199. package/src/infrastructure/engines/walker/double-with-a-body/logic-in-a-passed-function/piece.json +0 -10
  200. package/src/infrastructure/engines/walker/double-with-a-body/stub-implementation/dependency-isolation.js +9 -14
  201. package/src/infrastructure/engines/walker/drawer-path/drawer-names/categorical-paths.js +4 -4
  202. package/src/infrastructure/engines/walker/export-from-a-test/test-file-export/piece.json +9 -0
  203. package/src/infrastructure/engines/walker/export-from-a-test/test-file-export/test-file-export.examples.json +30 -0
  204. package/src/infrastructure/engines/walker/export-from-a-test/test-file-export/test-file-export.js +31 -0
  205. package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.examples.json +18 -0
  206. package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.js +32 -0
  207. package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/piece.json +9 -0
  208. package/src/infrastructure/engines/walker/floating-version/version-selector/piece.json +9 -0
  209. package/src/infrastructure/engines/walker/floating-version/version-selector/version-selector.examples.json +54 -0
  210. package/src/infrastructure/engines/walker/floating-version/version-selector/version-selector.js +75 -0
  211. package/src/infrastructure/engines/walker/inherited-environment-in-a-subprocess/git-spawn-environment/hermetic-git-spawns.js +8 -17
  212. package/src/infrastructure/engines/walker/loop-keyword/loop-statement/loops.js +8 -6
  213. package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/piece.json +9 -0
  214. package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/test-call-aliases.examples.json +36 -0
  215. package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/test-call-aliases.js +67 -0
  216. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mock-call.examples.json +34 -0
  217. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mocking.js +64 -16
  218. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/piece.json +5 -1
  219. package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/committed-lock-file.examples.json +24 -0
  220. package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/committed-lock-file.js +41 -0
  221. package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/piece.json +9 -0
  222. package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/import-boundaries.js +18 -16
  223. package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/piece.json +1 -1
  224. package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/debugger-statement.examples.json +18 -0
  225. package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/debugger-statement.js +17 -0
  226. package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/piece.json +9 -0
  227. package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/direct-global-use.examples.json +63 -0
  228. package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/piece.json +13 -0
  229. package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/process-global-used-in-place.js +126 -0
  230. package/src/infrastructure/engines/walker/prose-in-code/comment-prose/comment-prose.examples.json +42 -0
  231. package/src/infrastructure/engines/walker/prose-in-code/comment-prose/piece.json +16 -0
  232. package/src/infrastructure/engines/walker/prose-in-code/comment-prose/prose-in-code.js +90 -0
  233. package/src/infrastructure/engines/walker/rebinding/test-body/piece.json +0 -10
  234. package/src/infrastructure/engines/walker/runner/pieces/walker-piece.d.ts +7 -5
  235. package/src/infrastructure/engines/walker/runner/runner.js +268 -79
  236. package/src/infrastructure/engines/walker/runner/toolchain/typescript-parse.d.ts +3 -0
  237. package/src/infrastructure/engines/walker/shorthand-name/identifier-names/identifier-names.js +12 -7
  238. package/src/infrastructure/engines/walker/strictness-weakened/exact-optional-property-types/piece.json +0 -10
  239. package/src/infrastructure/engines/walker/strictness-weakened/no-fallthrough-cases-in-switch/piece.json +0 -10
  240. package/src/infrastructure/engines/walker/strictness-weakened/no-implicit-override/piece.json +0 -10
  241. package/src/infrastructure/engines/walker/strictness-weakened/no-property-access-from-index-signature/piece.json +0 -10
  242. package/src/infrastructure/engines/walker/strictness-weakened/no-unchecked-indexed-access/piece.json +0 -10
  243. package/src/infrastructure/engines/walker/strictness-weakened/strict/compiler-overrides.js +30 -52
  244. package/src/infrastructure/engines/walker/strictness-weakened/use-unknown-in-catch-variables/piece.json +0 -10
  245. package/src/infrastructure/engines/walker/text-past-its-reader/test-body/piece.json +0 -10
  246. package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/piece.json +9 -0
  247. package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/throw-statement.examples.json +36 -0
  248. package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/throws-in-production.js +12 -0
  249. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throw-statement.examples.json +6 -6
  250. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throws-in-tests.js +5 -44
  251. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/try-block/piece.json +0 -10
  252. package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/fetch-command.examples.json +42 -0
  253. package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/fetch-command.js +152 -0
  254. package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/piece.json +9 -0
  255. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/piece.json +9 -0
  256. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.examples.json +36 -0
  257. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.js +141 -0
  258. package/src/infrastructure/engines/walker/type-derived-from-code/factory-return-types/factory-return-types.js +8 -6
  259. package/src/infrastructure/engines/walker/unit-without-a-running-test/companion-test-file/export-test-sibling.js +16 -10
  260. package/src/infrastructure/engines/walker/untracked-escape/directive-pointers/comments-directives.js +18 -64
  261. package/src/infrastructure/engines/walker/write-into-a-parameter/parameter-mutation/parameter-mutation.js +7 -5
  262. package/src/measure-engines.process.js +80 -0
  263. package/src/rule-set.d.ts +2 -1
  264. package/src/testing.d.ts +2 -4
  265. package/src/testing.js +173 -314
  266. package/src/{audit.d.ts → walker.d.ts} +13 -8
  267. package/src/walker.js +28 -0
  268. package/chunks/chunk-5HRMJ4O2.js +0 -608
  269. package/chunks/chunk-IX2VZTBO.js +0 -887
  270. package/chunks/chunk-K2W3D3NB.js +0 -17
  271. package/chunks/chunk-M6SOGWT7.js +0 -82
  272. package/chunks/chunk-Q62Y25WS.js +0 -843
  273. package/chunks/chunk-R75QELTA.js +0 -481
  274. package/chunks/chunk-RANAKCTW.js +0 -31
  275. package/chunks/chunk-TNY2PASL.js +0 -38
  276. package/chunks/chunk-UJONWHA4.js +0 -22
  277. package/docs/output-contract.md +0 -1155
  278. package/rules/record-kinds/boundary-record.md +0 -9
  279. package/rules/typescript/recipes/iteach-over-typed-rows.md +0 -18
  280. package/rules/typescript/recipes/stub-with-vifn.md +0 -20
  281. package/src/audit.js +0 -18
  282. package/src/domain/runner/runner-module-types.d.ts +0 -15
package/docs/extending.md CHANGED
@@ -1,393 +1,12 @@
1
1
  # Extending Hone with your own rule set
2
2
 
3
- A team can add its own disciplines beside the ones Hone ships, without forking Hone. They live in the team's repository as a **rule set**: a folder of discipline files and the pieces that check them. `hone check` loads them from the repository, runs them, reports them and applies exceptions to them the same way as Hone's own; the differences are listed under [What is stable](#what-is-stable).
3
+ A team rule set holds a team's own symptoms and checks in the team's repository. `hone check` runs them beside Hone's own, and records answer them the same way. Write one when your team wants a check Hone does not ship, rather than forking Hone or editing a shipped rule.
4
4
 
5
- This guide follows one tested example. `install-proof` installs the packed package into a small repository, stored in Hone's source repository under `tests/test-fixtures/consumer-proof/team/`, type-checks its rule set and runs `hone project` and `hone check` against it. Its rule set is `acme`, with two disciplines: `ACME-1` checked by ESLint and `ACME-2` checked by the audit mechanism. Every file sample below is a file of that repository, apart from the rule pages, the per-package ESLint config, the settings samples and the exception record, which are described rather than tested there.
5
+ The `acme` rule set Hone's install proof runs is a working example: [delivery/install-proof/consumer-proof/team/tools/disciplines/acme](https://github.com/HailsTails/hone/tree/main/delivery/install-proof/consumer-proof/team/tools/disciplines/acme).
6
6
 
7
- Read [ADOPTING.md](../ADOPTING.md) first: this guide assumes Hone is installed and `disciplines.json` exists.
7
+ ## Start one
8
8
 
9
- ## Which mechanism
10
-
11
- - **ESLint** for anything about code syntax. The piece is an ordinary ESLint plugin, typed with ESLint's own types, and the team's editor and lint run report it too.
12
- - **Audit** for what ESLint cannot see: which files exist, file names, and files that are not TypeScript. An audit piece is offered every tracked file in the repository, Markdown and JSON included.
13
-
14
- ## Where the files go
15
-
16
- ```text
17
- disciplines.json
18
- eslint.config.mjs
19
- disciplines.eslint.mjs
20
- tools/disciplines/acme/
21
- package.json
22
- tsconfig.pieces.json
23
- rules/ACME-1/discipline.json
24
- rules/ACME-1/README.md
25
- rules/ACME-2/discipline.json
26
- rules/ACME-2/README.md
27
- mechanisms/eslint/ACME-1/piece.json
28
- mechanisms/eslint/ACME-1/acme.eslint-plugin.ts
29
- mechanisms/eslint/ACME-1/piece-settings.ts
30
- mechanisms/audit/ACME-2/piece.json
31
- mechanisms/audit/ACME-2/scratch-files.ts
32
- ```
33
-
34
- The rule set may sit anywhere inside the repository. Hone reads `rules/<ID>/discipline.json` and `mechanisms/<mechanism>/<ID>/piece.json` under it, and loads the modules the pieces name. Everything else in the folder is yours.
35
-
36
- ## Declare the rule set
37
-
38
- Name the folder in `disciplines.json` under `ruleSets`, then select its clauses with the rule set's name in front:
39
-
40
- ```json
41
- {
42
- "version": 1,
43
- "ruleSets": { "acme": "tools/disciplines/acme" },
44
- "clauses": {
45
- "acme/ACME-1#console-calls": "eslint",
46
- "acme/ACME-2#scratch-files": "audit"
47
- }
48
- }
49
- ```
50
-
51
- - The path is relative to the repository root and must stay inside it.
52
- - `hone` is Hone's own rule set, and its clauses can be selected beside the team's. `hone/CD-15#loops` (`loop-keyword#loop-statement`) and `CD-15#loops` are the same clause, and the report prints the short form. `loop-keyword#loop-statement` is the check's name, given for reading: today's tool neither accepts nor prints a check's name, so write and expect the clause address; check names become typeable in 2.0.
53
- - A rule set may not be called `hone` or start with `hone-`, and no declared name may be another declared name plus `-<suffix>`.
54
- - Discipline IDs only need to be unique inside one rule set: a team rule set may reuse an ID Hone's own rule set has, and `acme/<DisciplineId>` and `<DisciplineId>` stay two disciplines.
55
-
56
- The report names team clauses with their rule set:
57
-
58
- ```text
59
- findings (2)
60
- acme/ACME-1#console-calls eslint src/start-banner.ts:1:0 console.log("web started");
61
- acme/ACME-2#scratch-files audit notes.scratch.md:1:0 notes.scratch.md
62
- verdict: fail
63
- ```
64
-
65
- ## Write the discipline
66
-
67
- `rules/ACME-1/discipline.json`:
68
-
69
- ```json
70
- {
71
- "version": 1,
72
- "id": "ACME-1",
73
- "clauses": [
74
- {
75
- "kind": "mechanical",
76
- "id": "console-calls",
77
- "summary": "no direct console output in source",
78
- "mechanisms": ["eslint"],
79
- "anchor": { "kind": "keyword", "keyword": "console" },
80
- "cases": {
81
- "flag": [
82
- { "name": "console.log", "fileName": "src/a.ts", "source": "console.log(1);\n", "expectedLines": [1] }
83
- ],
84
- "allow": [
85
- { "name": "no console", "fileName": "src/b.ts", "source": "export const b = 1;\n", "expectedLines": [] }
86
- ]
87
- }
88
- }
89
- ]
90
- }
91
- ```
92
-
93
- - `id` matches the folder name. IDs are two to four capital letters, a dash and a number, with an optional lower-case letter after it.
94
- - Each clause lists the mechanisms that can check it. Selecting one clause adopts the whole discipline, so its other mechanical clauses must be selected too.
95
- - `anchor` is `{ "kind": "keyword", "keyword": "..." }` or `{ "kind": "file" }`.
96
- - `cases` say what the clause must flag and what it must leave alone. They are the clause's contract. `hone check` does not run them against a team's pieces; the team runs them in its own tests: see [Test a piece](#test-a-piece).
97
- - A clause with `"kind": "judgement"`, a `summary` and `"enforcedBy": "review"` is applied in review and cannot be selected.
98
- - `"exceptions": "refused"` on a clause stops any exception record from exempting it.
99
-
100
- `rules/ACME-1/README.md` is the rule's page: why the rule exists, one example that honours it and one that breaks it. Write it for the people and agents who apply the rule, not about how the check matches. It is optional today and will be required. Hone's own rule pages follow a fixed shape, a Rule and its Spirit on `README.md` with the mechanics in a sibling `CHECKS.md`; [adding a discipline](adding-a-discipline-or-mechanism.md#1a-the-rule-pages) describes it.
101
-
102
- ## An ESLint piece
103
-
104
- `mechanisms/eslint/ACME-1/piece.json`:
105
-
106
- ```json
107
- {
108
- "version": 1,
109
- "discipline": "ACME-1",
110
- "mechanism": "eslint",
111
- "clauses": [
112
- {
113
- "clause": "console-calls",
114
- "settings": { "pluginNamespace": "acme", "pluginModule": "acme.eslint-plugin.ts", "rule": "no-console-calls" }
115
- }
116
- ]
117
- }
118
- ```
119
-
120
- `mechanisms/eslint/ACME-1/acme.eslint-plugin.ts`:
121
-
122
- ```ts
123
- import type { ESLint, Rule } from "eslint";
124
-
125
- export const noConsoleCalls: Rule.RuleModule = {
126
- meta: {
127
- type: "problem",
128
- schema: [],
129
- messages: { console: "Write through the logger port, not console." },
130
- },
131
- create: (context) => ({
132
- "MemberExpression[object.name='console']": (node: Rule.Node) => {
133
- context.report({ node, messageId: "console" });
134
- },
135
- }),
136
- };
137
-
138
- const plugin: ESLint.Plugin = { rules: { "no-console-calls": noConsoleCalls } };
139
-
140
- export default plugin;
141
- ```
142
-
143
- - `pluginModule` is a path inside the piece folder. Its default export is the plugin, and `rule` is a key of its `rules`.
144
- - `pluginNamespace` must be the rule set's name or start with it and a dash: `acme` or `acme-console`. `hone`, `hone-*` and `hone-core` belong to Hone.
145
- - `options`, optional, is the rule's options array, passed to ESLint as written.
146
-
147
- Then run `hone project`. It writes `disciplines.eslint.mjs`, which imports the plugin by a path relative to the repository root:
148
-
149
- ```js
150
- import piece0 from "./tools/disciplines/acme/mechanisms/eslint/ACME-1/acme.eslint-plugin.ts";
151
-
152
- export default [
153
- {
154
- name: "hone-core/piece/acme",
155
- files: ["**/*.{ts,tsx,mts,cts}"],
156
- plugins: { "acme": piece0 },
157
- rules: { "acme/no-console-calls": "error" },
158
- },
159
- ];
160
- ```
161
-
162
- Every `eslint.config.*` that applies to checked files spreads the projection last. The projection sets rules only, so the config also sets the typescript-eslint parser, as [ADOPTING.md](../ADOPTING.md#4a-set-up-eslint-for-eslint-checks) step 4a explains. The example's `eslint.config.mjs`:
163
-
164
- ```js
165
- import typescriptParser from "@typescript-eslint/parser";
166
- import projection from "./disciplines.eslint.mjs";
167
-
168
- export default [
169
- { files: ["**/*.{ts,tsx,mts,cts}"], languageOptions: { parser: typescriptParser } },
170
- ...projection,
171
- ];
172
- ```
173
-
174
- In a monorepo each package's own config does the same, importing the projection by its relative path, such as `../../disciplines.eslint.mjs`. A package config that leaves the projection out fails the check, listing each of its files under `unrecorded` as `acme/ACME-1#console-calls eslint config-override <file>`. [ADOPTING.md](../ADOPTING.md#4a-set-up-eslint-for-eslint-checks) step 4a says which config ESLint applies to a file and how to state it in `disciplines.json` when detection cannot tell.
175
-
176
- ## An audit piece
177
-
178
- `mechanisms/audit/ACME-2/piece.json`:
179
-
180
- ```json
181
- {
182
- "version": 1,
183
- "discipline": "ACME-2",
184
- "mechanism": "audit",
185
- "clauses": [
186
- {
187
- "clause": "scratch-files",
188
- "settings": { "module": "scratch-files.ts" },
189
- "editions": ["1", "2"]
190
- }
191
- ]
192
- }
193
- ```
194
-
195
- `mechanisms/audit/ACME-2/scratch-files.ts`:
196
-
197
- ```ts
198
- import { editionReaches, isEdition, type PieceHit, type RunnerClause, type WalkerPiece } from "@hailstails/hone/audit";
199
-
200
- const SCRATCH_MARKER = ".scratch.";
201
- const DRAFT_MARKER = ".draft.";
202
- const DRAFT_EDITION = "2";
203
-
204
- const markersOf = (request: { readonly clause: RunnerClause }): readonly string[] =>
205
- isEdition(DRAFT_EDITION) && editionReaches({ edition: request.clause.edition, introducedIn: DRAFT_EDITION }) === "reached"
206
- ? [SCRATCH_MARKER, DRAFT_MARKER]
207
- : [SCRATCH_MARKER];
208
-
209
- const scratchHits = (request: { readonly clauses: readonly RunnerClause[]; readonly file: string }): readonly PieceHit[] =>
210
- request.clauses
211
- .filter((clause) => markersOf({ clause }).some((marker) => request.file.includes(marker)))
212
- .map((clause) => ({ clause: clause.address, anchor: { line: 1, column: 0 }, snippet: request.file }));
213
-
214
- export const check: WalkerPiece = {
215
- prepare: ({ clauses }) => ({
216
- outcome: "ok",
217
- value: {
218
- prepareFile: ({ file }) => ({ outcome: "ok", value: { kind: "complete", hits: scratchHits({ clauses, file }) } }),
219
- finish: () => ({ outcome: "ok", value: [] }),
220
- },
221
- }),
222
- };
223
- ```
224
-
225
- - `module` is a path inside the piece folder, and the module exports `check`.
226
- - `prepare` runs once with the selected clauses, the repository's file list and TypeScript's syntax API. The repository also carries a `disk`, a required field: its `root`, the kind of entry at an absolute path (`kindAt`) and a file's text (`textAt`), for a piece that must read files beyond the one it is given, untracked ones included. In a conformance case the disk holds only the case's file. A piece's own tests that build a `WalkerRepository` by hand must now give it a `disk` (the type is `WalkerDisk` from `@hailstails/hone/audit`), as the example's proof does. Such tests written before the field was added no longer type-check until they give it one. `prepareFile` runs once per tracked file and returns `skipped`, `complete` with its hits, or `syntax` with observers that walk the file's syntax tree. `finish` returns hits that need the whole repository.
227
- - `prepareFile` answers `skipped` for a file the piece does not judge. Any other answer, `complete` with no hits included, says the piece's clauses were measured on that file: the runner reports each as a `measured` pair, and `hone prune-debt` removes a stale or forfeited `file-carve-out` on that clause and file. The example answers `complete` for every file because it judges every file by its name; a piece that judges only TypeScript sources answers `skipped` for a `.md` or `.js` file.
228
- - A hit passes back the clause's `address` unchanged, a 1-based line and 0-based column, and a short snippet.
229
- - A hit may also give a `remedy` (the type is `Remedy` from `@hailstails/hone/audit`): a `fix` naming what to write instead of the form it flagged, the `page` that shows it as a path inside the rule's folder (`rules/<ID>/`), such as `CHECKS.md` or `README.md`, and the `section` of that page, as lowercase letters, digits and hyphens. Core resolves the page to the path a reader opens, as it does for the rule page under `readFirst`, and the finding then ends with ` fix: <fix> (<fix page>#<section>)`; see [the output contract](output-contract.md#report-lines).
230
- - When the piece cannot run, for example on settings it does not accept, return a failed result whose error is a `PieceFailure`: `kind` `piece-invalid`, the clause's `pieceRoot` and a `detail`. `hone check` then stops with a load failure naming the piece folder.
231
- - When the piece cannot parse a file, return a failed result whose error is `kind` `file-unparseable`, the `file` and a `detail`. `hone check` then stops with `load failure: runner-failed audit file-unparseable <file> <detail>`.
232
- - To read JSON with comments, such as a `tsconfig.json`, call TypeScript's own parser on the syntax API: `syntaxApi.parseConfigFileTextToJson(file, text)` returns the parsed value as `config` and sets `error` when it cannot parse the text. A piece does not import a JSON parser of its own; see [What is stable](#what-is-stable).
233
-
234
- ### Settings a repository can change
235
-
236
- The example's marker is fixed. To let a repository change it, a clause entry in `piece.json` declares `clauseSettings`: each key with its `default`, and optionally `choices`, a list of the values allowed. For a `marker` setting with default `".scratch."`, the clause entry would read:
237
-
238
- ```json
239
- {
240
- "clause": "scratch-files",
241
- "settings": { "module": "scratch-files.ts" },
242
- "clauseSettings": { "marker": { "default": ".scratch." } }
243
- }
244
- ```
245
-
246
- A repository that selects the clause can then override it in `disciplines.json`, keyed by the clause's address:
247
-
248
- ```json
249
- "clauseSettings": {
250
- "acme/ACME-2#scratch-files": { "marker": ".scratch.md" }
251
- }
252
- ```
253
-
254
- Hone refuses a value under an undeclared key, of another JSON kind than the default, or outside the `choices`, before any piece runs. The piece reads the value, the override or else the default, from `clause.clauseSettings` on each `RunnerClause`, in place of the fixed `SCRATCH_MARKER`. The value is typed as any JSON value, so the piece narrows it, for example with `typeof marker === "string"`, and returns a `piece-invalid` failure when it is not what it accepts. Name the settings on the discipline's page under a Settings heading. This section is described, not run by the example: Hone's unit tests cover reading, refusing and overriding settings.
255
-
256
- ### Editions of a check
257
-
258
- When a clause's check becomes stricter, ship the stricter check as a new edition instead of changing what the clause flags. A clause entry in `piece.json` lists its `editions` in ascending order: the first is the default, and the last is the latest. The example's piece lists `["1", "2"]`: edition 2 also flags files named with `.draft.`. An entry without `editions` has the single edition `"1"`. The setting key `edition` is reserved for the edition a repository pins, so a piece cannot declare it under `clauseSettings`.
259
-
260
- The piece reads the edition that runs from `clause.edition` on each `RunnerClause`. `@hailstails/hone/audit` exports two helpers. `isEdition` narrows a text such as `"2"` to an `Edition` without a cast. `editionReaches({ edition: clause.edition, introducedIn })` says whether the running edition covers something introduced in a given edition. The example piece uses both, and a piece's tests use `isEdition` the same way to build a `RunnerClause` for each edition.
261
-
262
- A case in `discipline.json` names the edition it runs under with `"edition": "2"`. A case without one runs under the piece's default edition. A case naming an edition the piece does not declare makes the rule set invalid. Conformance runs each edition's cases under that edition, and `clauseUnderTestOf` gives each case its `edition`. The example's `rules/ACME-2/discipline.json` flags `src/notes.draft.ts` under edition 2 and allows it under edition 1:
263
-
264
- ```json
265
- { "name": "draft file", "fileName": "src/notes.draft.ts", "source": "export const notes = 1;\n", "expectedLines": [1], "edition": "2" }
266
- ```
267
-
268
- A repository that selects the clause runs edition 1 until it sets `"checkEditions": "latest"` or pins the clause with `"edition": "2"` in its `clauseSettings`. Its report lists the edition that ran under `editions`, such as `acme/ACME-2#scratch-files audit edition 1 of 2`.
269
-
270
- ## TypeScript pieces under Node
271
-
272
- Hone loads piece modules with Node, which strips the types from a `.ts` file as it loads it. Node 22.18 or later does this without flags.
273
-
274
- - A piece module ends in `.ts` or `.js`. `.mts` and `.mjs` are refused.
275
- - Node decides whether a `.ts` file is an ES module from the nearest `package.json`:
276
- - `"type": "module"`: it loads, silently.
277
- - No `"type"` field: it still loads, because Node sees the `export` syntax, but every run prints a `[MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///… is not specified` block per piece module before the report.
278
- - `"type": "commonjs"`: it fails to load, with the `Failed to load the ES module` warning and load failure shown under [Common refusals](#common-refusals).
279
-
280
- The example repository says `"type": "commonjs"` at its root, the hard case, so its rule set has its own `package.json`:
281
-
282
- ```json
283
- {
284
- "private": true,
285
- "type": "module"
286
- }
287
- ```
288
-
289
- These three behaviours were checked by hand on Node 22.22.2; `install-proof` checks the first on every Node it runs.
290
- - Use only syntax Node can erase, spell the `.ts` extension in relative imports, and use `import type` for types. [ADOPTING.md](../ADOPTING.md#1-check-the-prerequisites) step 1 lists the limits.
291
- - Node does not strip types under `node_modules`. A rule set kept in an installed package is named by its repository path, for example `"acme": "node_modules/@acme/disciplines"`, and must ship `.js` piece modules; a `.ts` one fails with `Stripping types is currently unsupported for files under node_modules`.
292
-
293
- ## Type-check the rule set
294
-
295
- `@hailstails/hone/rule-set` holds types only. `@hailstails/hone/audit` holds the walker piece types and three values: `folderScope`, `isEdition` and `editionReaches`. Import types with `import type`. A `tsconfig` for the rule set that matches how Node runs it, `tools/disciplines/acme/tsconfig.pieces.json`:
296
-
297
- ```json
298
- {
299
- "compilerOptions": {
300
- "target": "es2022",
301
- "module": "nodenext",
302
- "moduleResolution": "nodenext",
303
- "strict": true,
304
- "noEmit": true,
305
- "allowImportingTsExtensions": true,
306
- "erasableSyntaxOnly": true,
307
- "verbatimModuleSyntax": true,
308
- "resolveJsonModule": true,
309
- "skipLibCheck": false,
310
- "types": []
311
- },
312
- "include": ["**/*.ts"]
313
- }
314
- ```
315
-
316
- Run it with the repository's own compiler, for example `tsc --noEmit -p tools/disciplines/acme/tsconfig.pieces.json`. `erasableSyntaxOnly` needs TypeScript 5.8 or later; leave it out on older versions.
317
-
318
- The ESLint piece's `settings` can be checked against `EslintPieceSettings` from the JSON file itself. `mechanisms/eslint/ACME-1/piece-settings.ts`:
319
-
320
- ```ts
321
- import type { EslintPieceSettings } from "@hailstails/hone/rule-set";
322
- import piece from "./piece.json" with { type: "json" };
323
-
324
- type Settled<Settings extends EslintPieceSettings> = Settings;
325
-
326
- export type PieceSettings = Settled<(typeof piece)["clauses"][number]["settings"]>;
327
- ```
328
-
329
- A wrong field then fails the type check, for example `Type 'number' is not assignable to type 'string'` for a numeric `rule`; `install-proof` checks this on TypeScript 4.8.4 and 6.0.3 with the same `Settled` type over settings typed as a JSON file types them. TypeScript reads string values in a JSON file as `string`, so this works for `settings` but not for `discipline.json` or the rest of `piece.json`, whose types name exact values such as `"mechanical"`. Hone checks those files when it reads them.
330
-
331
- ## Test a piece
332
-
333
- Test an ESLint rule with ESLint's own `RuleTester`, importing the rule the plugin exports, such as `noConsoleCalls`, and giving it the clause's `flag` cases as `invalid` and its `allow` cases as `valid`. Run on its own with `node`, `RuleTester` prints nothing when the cases hold and throws on the first that does not; under a test runner that defines `describe` and `it`, it reports each case as a test.
334
-
335
- Test an audit piece with `@hailstails/hone/testing`. `clauseConformanceOf` loads the installed audit runner, binds the clause from the rule set as `hone check` binds it, and runs every `flag` and `allow` case through the piece:
336
-
337
- ```ts
338
- import { clauseConformanceOf } from "@hailstails/hone/testing";
339
-
340
- const conformance = await clauseConformanceOf({ ruleSetRoot: "tools/disciplines/acme", clause: "acme/ACME-2#scratch-files" });
341
- ```
342
-
343
- A relative `ruleSetRoot` is read from the working directory. `{ outcome: "ok", value: [] }` means the piece met every case. Each entry in a longer list names a case, the lines it expects and the lines the piece flagged. `{ outcome: "failed", error: { kind, detail } }` means the cases could not run, for example `rule-set-unloadable` for a clause the audit mechanism may not check.
344
-
345
- Checks of your own call the piece directly. `clauseUnderTestOf` returns the same bound clause and each case's `name`, `file`, `source` and `edition`, ready for `check.prepare` and `prepareFile`; `repoPathOf` makes the `RepoPath` for any other file, such as one whose `readText` fails with `file-unreadable`. `folderScope` from `@hailstails/hone/audit` tells a piece whether a file sits in a generated folder. Hone does not run these tests; the team runs them with its own test runner.
346
-
347
- ## Exceptions
348
-
349
- Exception records in `discipline-exceptions.json` name team clauses by their full address and work exactly as for Hone's own clauses. This entry records the console calls already in `src/start-banner.ts` as debt: it moves the finding to `exempted` and, after `hone project`, turns the rule off for that file in the team's own ESLint run, until the file is next touched and the record is forfeited:
350
-
351
- ```json
352
- {
353
- "kind": "file-carve-out",
354
- "clause": "acme/ACME-1#console-calls",
355
- "file": "src/start-banner.ts"
356
- }
357
- ```
358
-
359
- A `file-carve-out` is debt and needs no `whyChain` and no `reason`. Where the clause does not apply to a file at all, record an `authorised-location` instead: it is never forfeited, so it needs a `reason` and a `whyChain` that follows the [why-chain contract](why-chain-contract.md), and without the chain it is refused as `evidence-refused`. [README.md](../README.md#hone-records) describes the record kinds and what each needs.
360
-
361
- ## What is stable
362
-
363
- Two requirements are decided and not yet built. Each will make some rule sets that pass today fail:
364
-
365
- - **A rule page is required.** A selected team discipline without `rules/<ID>/README.md` will fail to load.
366
- - **Pieces keep to import boundaries.** A team piece will be refused if it imports from anywhere but its own piece folder, its discipline's `rules/<ID>` folder, `@hailstails/hone/rule-set`, `@hailstails/hone/audit` and its mechanism's toolchain package (`eslint` or `typescript`), with values only from its own piece folder and `folderScope`, `isEdition` and `editionReaches` from `@hailstails/hone/audit`. The rule is about a piece's run-time code: a piece's own tests may also import `@hailstails/hone/testing`.
367
-
368
- To be ready now: write each discipline's `README.md`, and import nothing from Hone in a piece but types from `@hailstails/hone/rule-set` and `@hailstails/hone/audit`, and `folderScope`, `isEdition` and `editionReaches`.
369
-
370
- | Part | Status |
371
- | --- | --- |
372
- | `ruleSets`, the address `[<ruleSet>/]<ID>#<clause>`, `hone` reserved | Stable |
373
- | The folder layout `rules/<ID>/` and `mechanisms/<mechanism>/<ID>/` | Stable, with `rules/<ID>/README.md` becoming required |
374
- | `discipline.json` and `piece.json` version 1, and the ESLint piece `settings` with the namespace rule | Stable file formats |
375
- | `@hailstails/hone/rule-set` | Stable |
376
- | Exception records for team clauses | Stable |
377
- | `@hailstails/hone/audit` and the walker piece contract | Experimental: may change in a minor release |
378
- | `@hailstails/hone/testing` | Experimental: may change in a minor release |
379
- | A rule set named by a package name, such as `"acme": "@acme/disciplines"` | Not supported: name its repository path instead, as under [TypeScript pieces under Node](#typescript-pieces-under-node) |
380
- | A new mechanism from outside Hone | Not supported |
381
-
382
- ## Common refusals
383
-
384
- | Output | Cause |
385
- | --- | --- |
386
- | `load failure: reserved-rule-set-name hone` | A rule set is declared as `hone`. Pick the team's own name. |
387
- | `load failure: unknown-rule-set beta` | A clause names a rule set that `ruleSets` does not declare. |
388
- | `load failure: runner-failed eslint piece-invalid <piece folder> the plugin namespace hone belongs to Hone; the rule set acme must use acme or acme-<name>` | The ESLint piece uses one of Hone's namespaces. |
389
- | `load failure: runner-failed eslint piece-invalid <piece folder> the plugin namespace lint is not owned by the rule set acme; use acme or acme-<name>` | The namespace does not start with the rule set's name. |
390
- | `load failure: runner-failed eslint piece-invalid <piece folder> ✖ not a path inside the piece folder ending in .ts, or .js in a built install\n → at pluginModule` | The ESLint piece's `pluginModule` is outside the piece folder or ends in neither `.ts` nor `.js`. The `\n` is printed as written, not as a line break. |
391
- | `load failure: runner-failed audit piece-invalid <piece folder> [\n {\n "code": "custom",\n "path": [\n "module"\n ],\n "message": "the module is not a path inside the piece folder ending .ts, or .js in a built install"\n }\n]` | The audit piece's `module` is outside the piece folder or ends in neither `.ts` nor `.js`. The whole message is one line, each `\n` printed as written. |
392
- | `(node:<pid>) Warning: Failed to load the ES module: <piece module>. Make sure to set "type": "module" in the nearest package.json file or use the .mjs extension.` and ``(Use `node --trace-warnings ...` to show where the warning was created)``, then `load failure: runner-failed eslint piece-invalid <piece folder> Unexpected token 'export'` | The nearest `package.json` says `"type": "commonjs"`, so Node read the `.ts` piece as CommonJS. Node prints its warning for each `.ts` piece module it tried; the load failure names one mechanism whose piece failed. Give the rule set a `package.json` with `"type": "module"`. |
393
- | `<clause> eslint config-override <file>` under `unrecorded` | An `eslint.config.*` that applies to the file does not spread the projection. |
9
+ 1. Pick a folder, name it under `ruleSets` in `hone.config.json`, and select its checks as `<rule set>/<symptom>#<check>`.
10
+ 2. Write each symptom and check as an item under the folder's `rules/`, laid out as Hone's own [rules](../rules/README.md). `@hailstails/hone/rule-set` types each item's facts. A case's name must be its title in lower case with hyphens, leaving out any part in brackets. A symptom's indication may point only at a principle or rule its case owes. A recipe's `serves` lists each rule or principle it serves, and a symptom may list a recipe, and a recipe's example may answer a check's form, only where one of them is indicated by the symptom.
11
+ 3. Write each check's piece under `engines/<engine>/<symptom>/<check>/`, with its examples beside it. Use ESLint for what a lint rule can see, and the walker (`@hailstails/hone/walker`) for files and names ESLint never reads. A remedy a piece reports names its `fix` and the `form` it matched, and no page.
12
+ 4. Test each piece against its examples with `checkConformanceOf` from `@hailstails/hone/testing`, naming the rule set and its root. An empty list means the piece meets every example.
@@ -72,7 +72,7 @@ one of three buckets:
72
72
 
73
73
  - **justified.** The declaration is the single permitted authored class at its
74
74
  named site, OR it is a `new X(...)` for an external-library class in
75
- the adapter for the party it reaches, with a boundary record, AND the instance
75
+ the adapter for the party it reaches, with an authorised location, AND the instance
76
76
  is held inside the closure and never re-exported as a class. Cite the carve-out; no replacement.
77
77
  - **closure-candidate.** The class carries genuine instance state that is
78
78
  *mutated* across method calls (counters, caches, accumulating buffers,
@@ -137,7 +137,7 @@ an event `forEach` handler by shape.
137
137
 
138
138
  Every raw outside-dependency import (runtime *or* type-only) and every `new X(...)`
139
139
  for an external-library class is a candidate. For each: is the importing or
140
- instantiating file the adapter for the party it reaches, with a boundary record?
140
+ instantiating file the adapter for the party it reaches, with an authorised location?
141
141
  If yes → justified. If not, the import is in the wrong place — a function-first
142
142
  finding with a DI/port cross-reference (the raw import escaping its adapter is
143
143
  both a structural and a boundary-discipline defect; name the boundary lens as the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hailstails/hone",
3
- "version": "2.0.0-pre.3",
3
+ "version": "2.0.0-pre.5",
4
4
  "description": "Checks a repository against the disciplines it selects, applies its recorded exceptions and prints one verdict.",
5
5
  "keywords": [
6
6
  "code-quality",
@@ -28,10 +28,6 @@
28
28
  },
29
29
  "exports": {
30
30
  "./package.json": "./package.json",
31
- "./audit": {
32
- "types": "./src/audit.d.ts",
33
- "default": "./src/audit.js"
34
- },
35
31
  "./eslint-plugin": {
36
32
  "types": "./src/eslint-plugin.d.ts",
37
33
  "default": "./src/eslint-plugin.js"
@@ -44,16 +40,21 @@
44
40
  "types": "./src/testing.d.ts",
45
41
  "default": "./src/testing.js"
46
42
  },
43
+ "./walker": {
44
+ "types": "./src/walker.d.ts",
45
+ "default": "./src/walker.js"
46
+ },
47
47
  "./src/infrastructure/engines/eslint/authored-class-or-this/class-keyword/eslint-plugin.js": "./src/infrastructure/engines/eslint/authored-class-or-this/class-keyword/eslint-plugin.js",
48
48
  "./src/infrastructure/engines/eslint/claimed-type/non-null-assertions/eslint-plugin.js": "./src/infrastructure/engines/eslint/claimed-type/non-null-assertions/eslint-plugin.js",
49
- "./src/infrastructure/engines/eslint/tangled-function/cognitive-complexity/eslint-plugin.js": "./src/infrastructure/engines/eslint/tangled-function/cognitive-complexity/eslint-plugin.js",
50
49
  "./src/infrastructure/engines/eslint/name-off-its-casing/filename-case/eslint-plugin.js": "./src/infrastructure/engines/eslint/name-off-its-casing/filename-case/eslint-plugin.js",
51
50
  "./src/infrastructure/engines/eslint/name-off-its-casing/naming-convention/eslint-plugin.js": "./src/infrastructure/engines/eslint/name-off-its-casing/naming-convention/eslint-plugin.js",
52
51
  "./src/infrastructure/engines/eslint/positional-parameters/parameter-count/eslint-plugin.js": "./src/infrastructure/engines/eslint/positional-parameters/parameter-count/eslint-plugin.js",
53
52
  "./src/infrastructure/engines/eslint/rebinding/parameter-reassignment/eslint-plugin.js": "./src/infrastructure/engines/eslint/rebinding/parameter-reassignment/eslint-plugin.js",
53
+ "./src/infrastructure/engines/eslint/tangled-function/cognitive-complexity/eslint-plugin.js": "./src/infrastructure/engines/eslint/tangled-function/cognitive-complexity/eslint-plugin.js",
54
54
  "./src/infrastructure/engines/eslint/test-switched-off/focused-tests/eslint-plugin.js": "./src/infrastructure/engines/eslint/test-switched-off/focused-tests/eslint-plugin.js",
55
55
  "./src/infrastructure/engines/eslint/thrown-non-error/throw-only-error/eslint-plugin.js": "./src/infrastructure/engines/eslint/thrown-non-error/throw-only-error/eslint-plugin.js",
56
56
  "./src/infrastructure/engines/eslint/untyped-value/explicit-any/eslint-plugin.js": "./src/infrastructure/engines/eslint/untyped-value/explicit-any/eslint-plugin.js",
57
+ "./src/infrastructure/engines/eslint/wide-input/unread-parameter/eslint-plugin.js": "./src/infrastructure/engines/eslint/wide-input/unread-parameter/eslint-plugin.js",
57
58
  "./src/infrastructure/engines/eslint/work-inside-a-condition/else-after-an-exit/eslint-plugin.js": "./src/infrastructure/engines/eslint/work-inside-a-condition/else-after-an-exit/eslint-plugin.js"
58
59
  },
59
60
  "files": [
package/rules/README.md CHANGED
@@ -36,7 +36,7 @@ Two tests for a rule:
36
36
 
37
37
  ## Names, not numbers
38
38
 
39
- Rules, principles, cases, recipes and symptoms are named, not numbered. A name's id is the name, hyphenated. [Every CD](numbers.md) maps each old number to its new names. Selections, records and findings still use the numbered clause addresses; each check's mechanics are on its own page under its symptom.
39
+ Rules, principles, cases, recipes and symptoms are named, not numbered. A name's id is the name, hyphenated. [Every CD](numbers.md) maps each old number to its new names. Each check's mechanics are on its own page under its symptom.
40
40
 
41
41
  [Every CD](numbers.md#every-numbered-discipline) lists each numbered discipline with its title, clauses, files checked and review lens.
42
42
 
@@ -169,6 +169,10 @@ Where a reason is marked **proposed**, it is not yet accepted.
169
169
 
170
170
  Outside dependency: what was called a package. An internal package is our own code.
171
171
 
172
+ ## Recipes: Examples
173
+
174
+ A recipe's examples show the method. Each names the check and form it answers. The first block is a flagged form, and each block after it is the method applied. Every block after the first passes every check Hone ships at every edition, and compiles under the compiler options [strictness-weakened](typescript/symptoms/strictness-weakened.md) requires. Statements outside an `it` stand for the body of one test. `assert`, `expect`, `it` and `vi` come from `vitest`, and a `declare const` line stands for the unit under test or what it is handed.
175
+
172
176
  ## Recipes: No hidden effects
173
177
 
174
178
  The principle decides.
@@ -263,7 +267,7 @@ Until a check can name the breach, a finding names the rules the symptom points
263
267
 
264
268
  Six checks run together on `CD-27#test-body-logic`: [branch-in-a-test#test-body](typescript/symptoms/branch-in-a-test/test-body.md), [throw-or-catch-in-a-test#try-block](typescript/symptoms/throw-or-catch-in-a-test/try-block.md), [rebinding#test-body](typescript/symptoms/rebinding/test-body.md), [computed-value-in-a-test#test-body](typescript/symptoms/computed-value-in-a-test/test-body.md), [text-past-its-reader#test-body](typescript/symptoms/text-past-its-reader/test-body.md) and [double-with-a-body#logic-in-a-passed-function](typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md). Each check's page lists what it flags.
265
269
 
266
- - They read test files only: `*.test.ts` and `*.test.tsx`. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped. Helper files that tests import are not checked.
270
+ - They read test files only: `.ts` and `.tsx` files that `testFiles` in `hone.config.json` names. Generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped. Helper files that tests import are not checked.
267
271
  - None flags loops, which [loop-statement](typescript/symptoms/loop-keyword/loop-statement.md) covers, or `throw`, which [throw-statement](typescript/symptoms/throw-or-catch-in-a-test/throw-statement.md) covers.
268
272
  - None flags element access such as `calls[0]`, calls to free functions, a method called through a computed key, such as `rows["map"]`, or text built with a template literal.
269
273
 
@@ -275,8 +279,6 @@ They have two editions. Edition 1 runs by default. Edition 2 adds what each chec
275
279
  }
276
280
  ```
277
281
 
278
- Each check's "Allowed forms in a test" sections show a flagged form first, then the forms to write instead. Every form to write instead passes every audit and ESLint clause Hone ships, at each edition its check declares, and compiles under the compiler options [strictness-weakened](typescript/symptoms/strictness-weakened.md) requires. A test reads each check's page and holds every block on it to that. `assert`, `expect`, `it` and `vi` come from `vitest`, and a `declare const` line stands for the unit under test.
279
-
280
282
  ## Checks: Settings
281
283
 
282
284
  A setting fails only if it changes what a rule requires. It does not fail when it:
@@ -305,7 +307,7 @@ A default that quietly narrows a rule, which no codebase chose, still fails.
305
307
  | Edition defaults | "Edition defaults would be for backwards compatability since we went npm." An existing adopter keeps the behaviour it installed. |
306
308
  | `confinedPackages` empty by default | "packages is empty because we can't define the universe and if we just said imports at all we would catch internal packages." Seeing every outside dependency needs a way to tell it from an internal package; until then the list is the adopter's to fill. |
307
309
  | `__tests__` skipped by default | "probably because of noise level and the fact I don't adopt that folder practice deliberately at all." |
308
- | `.spec.ts` not treated as a test file by most checks | "Spec is also just not a naming practice I use." Then: "It honestly should be config for user to declare file naming structure so we can match their conventions." Hone has no such config yet; the Companion test file and Integration test suffix recipes are the convention it reads. |
310
+ | Which files are test files | "Spec is also just not a naming practice I use." Then: "It honestly should be config for user to declare file naming structure so we can match their conventions." `testFiles` in `hone.config.json` declares it. |
309
311
  | Generated folders skipped (`node_modules`, `dist` and the like) | not code of ours |
310
312
  | Reading `.test.js` and `.test.mjs` in the subprocess-environment check | it widens one check, not narrows a rule |
311
313
  | Suite-body exemption | "A test suite's body is a list of cases, not a coordinator." |
package/rules/SPIRIT.md CHANGED
@@ -43,7 +43,7 @@ Tests are not exempt. A test that needs a cast, a test double with logic, a modu
43
43
 
44
44
  ## Older than these rules
45
45
 
46
- Each rule encodes lessons programmers learned before us and wrote down under names you can look up: the SOLID principles, ports and adapters, "parse, don't validate", making illegal states unrepresentable, the test pyramid, the kinds of test double, and others. [The sources page](sources.md) names the source behind each principle, rule and recipe, and how the item relates to it. Read them to learn the pattern and the reasoning, not only the rule.
46
+ Each rule encodes lessons programmers learned before us and wrote down under names you can look up: the SOLID principles, ports and adapters, "parse, don't validate", making illegal states unrepresentable, narrow integration tests, the kinds of test double, and others. [The sources page](sources.md) names the source behind each principle, rule and recipe, and how the item relates to it. Read them to learn the pattern and the reasoning, not only the rule.
47
47
 
48
48
  ## Who does what
49
49
 
package/rules/numbers.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Every CD
2
2
 
3
- Rules, principles, cases, recipes and symptoms are named, not numbered. This is the one page that gives the old numbers: each CD, its verdict, and where it went. Selections, records and findings still use the numbered clause addresses.
3
+ Rules, principles, cases, recipes and symptoms are named, not numbered. This is the one page that gives the old numbers: each CD, its verdict, and where it went.
4
4
 
5
5
  | Verdict | Meaning |
6
6
  |---|---|
@@ -26,7 +26,7 @@ Rules, principles, cases, recipes and symptoms are named, not numbered. This is
26
26
  | CD-9 | Keeps | [Failures are values](rules/failures-are-values.md) |
27
27
  | CD-10 | Splits | [Failures are values](rules/failures-are-values.md); [Straight-through tests](rules/straight-through-tests.md); throw-only-error a [check](typescript/symptoms/thrown-non-error/throw-only-error.md) |
28
28
  | CD-11 | Recipe | [Result union](typescript/recipes/result-union.md), for [Failures are values](rules/failures-are-values.md) |
29
- | CD-12 | Recipe | [Port in the domain](typescript/recipes/port-in-the-domain.md), for [Ports declared inside](rules/ports-declared-inside.md) |
29
+ | CD-12 | Recipe | [Port in a module of its own](typescript/recipes/port-in-a-module-of-its-own.md), for [Ports declared inside](rules/ports-declared-inside.md) |
30
30
  | CD-13 | Keeps | [Ports declared inside](rules/ports-declared-inside.md) |
31
31
  | CD-14 | Splits | no-class recipe [Closure factory](typescript/recipes/closure-factory.md); [Outside dependencies stay at boundaries](rules/outside-dependencies-stay-at-boundaries.md); state a [case](cases/keeps-state-or-settings-across-calls.md) |
32
32
  | CD-15 | Cases | of [No hidden effects](principles/no-hidden-effects.md) |
@@ -36,7 +36,7 @@ Rules, principles, cases, recipes and symptoms are named, not numbered. This is
36
36
  | CD-19 | Splits | [Outside dependencies stay at boundaries](rules/outside-dependencies-stay-at-boundaries.md); [Ports declared inside](rules/ports-declared-inside.md); [construction](cases/builds-the-real-implementations.md) and [ids](cases/needs-the-current-time-a-random-value-a-new-id-or-an-outside-ordering.md) cases |
37
37
  | CD-20 | Merges | with CD-19 |
38
38
  | CD-21 | Cases | [built at the entry point](cases/builds-the-real-implementations.md) |
39
- | CD-22 | Recipe | [Bounded context generic](typescript/recipes/bounded-context-generic.md), for [Declared, not asserted](rules/declared-not-asserted.md) |
39
+ | CD-22 | Recipe | [Constrained context generic](typescript/recipes/constrained-context-generic.md), for [Declared, not asserted](rules/declared-not-asserted.md) |
40
40
  | CD-23 | Keeps | [Tested where it's owned](rules/tested-where-its-owned.md) |
41
41
  | CD-24 | Merges | with CD-23 |
42
42
  | CD-25 | Keeps | [Written-out answers](rules/written-out-answers.md) |
@@ -97,7 +97,7 @@ Each mechanical clause and the [symptom](typescript/symptoms.md) it sees.
97
97
 
98
98
  The test-logic check, CD-27#test-body-logic, also sees the `let` form of [Answer set in a hook](typescript/symptoms/answer-set-in-a-hook.md), and `try`, a form of [Throw or catch in a test](typescript/symptoms/throw-or-catch-in-a-test.md).
99
99
 
100
- Review clauses that demand a method (CD-4, CD-9, CD-11, CD-12, CD-21 and CD-22) map to their [recipes](typescript/recipes.md). The outcome each protects is seen by Schema past its adapter, Throw between our units, Failure shaped as success, Port outside the domain, Adapter built outside the root and Default for a required value.
100
+ Review clauses that demand a method (CD-4, CD-9, CD-11, CD-12, CD-21 and CD-22) map to their [recipes](typescript/recipes.md). The outcome each protects is seen by Schema past its adapter, Throw between our units, Failure shaped as success, Port beside its adapter, Adapter built outside the root and Default for a required value.
101
101
 
102
102
  Sensitive data and citation clauses (CD-32, CD-33, CD-34 and CD-39) are outside the 2.0 model, as safety (CD-32, CD-33 and CD-34) and process (CD-39): they are outside Hone's catalogue, with no item, symptom or check, and no Hone lens applies them.
103
103
 
@@ -13,7 +13,7 @@
13
13
  - **Reason to change:** The shape of the data we receive changes.
14
14
  - **Breach:** In the adapter that is missing or passes the outside form inward. Shows far inward: presence checks, re-parsing, casts.
15
15
  - **Outside data:** anything read at a boundary, our own stored rows and files included.
16
- - **Record:** an externally defined model adopted as the definitive thing. Evans's *Conformist*. It is a statement on a [boundary record](../record-kinds/boundary-record.md).
16
+ - **Record:** an externally defined model adopted as the definitive thing. Evans's *Conformist*. It is the root of an [authorised location](../record-kinds/authorised-location.md)'s why-chain.
17
17
  - **Source:** This is Evans's anticorruption layer, applied to failures as well as data, in both directions.
18
18
  - **Quoted reasons:** "we always map to our own type to decouple even if they are basically the same contents." "Throws are not about start up. They are about speaking the language of the caller at the boundary."
19
19
  - **Review:** validation runs once at the boundary and its types do not leak inward
@@ -29,7 +29,7 @@
29
29
  - **Reason to change:** The shape of the data we receive changes.
30
30
  - **Breach:** In the adapter that is missing or passes the outside form inward. Shows far inward: presence checks, re-parsing, casts.
31
31
  - **Outside data:** anything read at a boundary, our own stored rows and files included.
32
- - **Record:** an externally defined model adopted as the definitive thing. Evans's *Conformist*. It is a statement on a [boundary record](record-kinds/boundary-record.md).
32
+ - **Record:** an externally defined model adopted as the definitive thing. Evans's *Conformist*. It is the root of an [authorised location](record-kinds/authorised-location.md)'s why-chain.
33
33
  - **Source:** This is Evans's anticorruption layer, applied to failures as well as data, in both directions.
34
34
  - **Quoted reasons:** "we always map to our own type to decouple even if they are basically the same contents." "Throws are not about start up. They are about speaking the language of the caller at the boundary."
35
35
  - **Review:** validation runs once at the boundary and its types do not leak inward
@@ -6,7 +6,7 @@
6
6
  }
7
7
  ```
8
8
 
9
- - **Recorded in:** **An authorised location** is in `hone-records/authorised-locations/<symptom>.json`: `answers`, `file`, `case` and `owes`, naming the case the file is and the principle it owes, and a `whyChain`. It says the symptom is correct in that file. `hone authorise` writes one from the arguments it is given. Each file is a document `{ "version": 2, "records": [...] }`; `answers` names the symptom, or `<symptom>#<check>` to reach one check of it.
9
+ - **Recorded in:** **An authorised location** is in `hone-records/authorised-locations/<symptom>.json`: `answers`, `file`, `case` and `owes`, naming the case the file is and the principle it owes, and a `whyChain`. It says the symptom is correct in that file. `hone authorise` writes one from the arguments it is given. Each file is a document `{ "version": 2, "records": [...] }`; `answers` names `<symptom>#<check>`. Where the symptom's correct use binds an outside party, `outsideParty` names the package or `node:` module.
10
10
  An `authorised-location` follows the why-chain contract: exactly five `{ "why", "because", "evidence" }` steps chained cause to cause, then `rootCause`, `rootEvidence`, `readback` and `owner`. The contract lists what Hone refuses and what review still judges:
11
11
 
12
12
  ```json