@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
@@ -2,126 +2,128 @@ import {
2
2
  editionOf
3
3
  } from "../../../../../../chunks/chunk-RFR3ITBS.js";
4
4
  import {
5
- folderScope
6
- } from "../../../../../../chunks/chunk-K2W3D3NB.js";
5
+ PACKAGE_MANIFEST
6
+ } from "../../../../../../chunks/chunk-SKDQ3QJD.js";
7
+ import {
8
+ createDefaultJsoncParsePort
9
+ } from "../../../../../../chunks/chunk-DJMF6JIM.js";
10
+ import {
11
+ sourceSnippetAt
12
+ } from "../../../../../../chunks/chunk-5AKHEW6V.js";
13
+ import {
14
+ folderScope,
15
+ testFileEligibility
16
+ } from "../../../../../../chunks/chunk-COQMPHWZ.js";
7
17
  import {
8
18
  editionReaches
9
19
  } from "../../../../../../chunks/chunk-RANIXNWY.js";
10
20
  import "../../../../../../chunks/chunk-DGOLOS5A.js";
11
21
 
12
- // src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body-logic.ts
13
- var testFileEligibility = (request) => {
14
- if (folderScope({ file: request.file }) === "generated") return "skipped";
15
- return request.file.endsWith(".test.ts") || request.file.endsWith(".test.tsx") ? "eligible" : "skipped";
22
+ // src/infrastructure/engines/walker/branch-in-a-test/test-body/own-modules.ts
23
+ var jsonc = createDefaultJsoncParsePort({ trailingCommas: "refused" });
24
+ var packageNameOf = (request) => {
25
+ const { disk } = request.repository;
26
+ const text = disk.textAt({ path: `${disk.root}/${request.file}` });
27
+ if (text.outcome !== "ok") return void 0;
28
+ const parsed = jsonc.parse({ source: text.value });
29
+ if (parsed.outcome !== "ok") return void 0;
30
+ const manifest = parsed.value;
31
+ return typeof manifest === "object" && manifest !== null && "name" in manifest && typeof manifest.name === "string" ? manifest.name : void 0;
16
32
  };
33
+ var ownPackageNamesOf = (request) => request.repository.files.flatMap((file) => {
34
+ if (!PACKAGE_MANIFEST.test(file) || folderScope({ file }) === "generated") return [];
35
+ const name = packageNameOf({ repository: request.repository, file });
36
+ return name === void 0 ? [] : [name];
37
+ });
38
+ var moduleOriginOf = (request) => {
39
+ const { specifier, ownPackageNames } = request;
40
+ if (specifier.startsWith(".") || specifier.startsWith("#")) return "own";
41
+ return ownPackageNames.some((name) => specifier === name || specifier.startsWith(`${name}/`)) ? "own" : "outside";
42
+ };
43
+
44
+ // src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body-logic.ts
17
45
  var SECOND_EDITION = editionOf("2");
18
- var BRANCH_IN_A_TEST = "branch-in-a-test/test-body.md";
19
- var COMPUTED_VALUE_IN_A_TEST = "computed-value-in-a-test/test-body.md";
20
- var REBINDING = "rebinding/test-body.md";
21
- var TEXT_PAST_ITS_READER = "text-past-its-reader/test-body.md";
22
- var THROW_OR_CATCH_IN_A_TEST = "throw-or-catch-in-a-test/try-block.md";
23
- var DOUBLE_WITH_A_BODY = "double-with-a-body/logic-in-a-passed-function.md";
24
46
  var firstEdition = (remedy) => ({ introducedIn: editionOf("1"), remedy });
25
47
  var secondEdition = (remedy) => ({ introducedIn: SECOND_EDITION, remedy });
26
48
  var BRANCHING = firstEdition({
27
- fix: "write one test per case, or one it.each table; to narrow a value that may be missing, assert.isDefined it",
28
- page: BRANCH_IN_A_TEST,
29
- section: "branching-with-if"
49
+ fix: "The test branches because the unit can return more than one shape. Give each outcome its own test or make the return type express the one outcome callers can rely on.",
50
+ form: "branching-with-if"
30
51
  });
31
52
  var TRY_BLOCK = firstEdition({
32
- fix: "assert the throw with expect(() => act()).toThrow or await expect(act()).rejects, or assert the failure the unit returns",
33
- page: THROW_OR_CATCH_IN_A_TEST,
34
- section: "a-try-block"
53
+ fix: "Catching inside the test can let it pass when no error occurs. Assert the failure the unit returns. Where an adapter's caller relies on a throw, assert the throw.",
54
+ form: "a-try-block"
35
55
  });
36
56
  var TERNARY = firstEdition({
37
- fix: "write the value out, or give each case its own it.each row",
38
- page: BRANCH_IN_A_TEST,
39
- section: "a-ternary"
57
+ fix: "The test chooses between values at runtime. State the expected value for each case so the assertion cannot adapt to the result.",
58
+ form: "a-ternary"
40
59
  });
41
60
  var LET = firstEdition({
42
- fix: "use const; record calls with vi.fn and assert them with toHaveBeenCalledWith",
43
- page: REBINDING,
44
- section: "a-let"
61
+ fix: "A reassigned local makes the test depend on hidden state. Keep the expected values fixed and assert the interaction you need to observe.",
62
+ form: "a-let"
45
63
  });
46
64
  var PICKING_METHOD = firstEdition({
47
- fix: "assert on the whole array with toEqual, toContain, toContainEqual or expect.arrayContaining",
48
- page: COMPUTED_VALUE_IN_A_TEST,
49
- section: "a-method-that-picks-or-tests-an-element"
65
+ fix: "Selecting an element can discard data the caller should see. Assert the whole returned collection.",
66
+ form: "a-method-that-picks-or-tests-an-element"
50
67
  });
51
68
  var COMPUTING_METHOD = firstEdition({
52
- fix: "write the expected value out, or match part of it with toMatchObject, toHaveLength or expect.stringContaining",
53
- page: COMPUTED_VALUE_IN_A_TEST,
54
- section: "a-method-that-computes-a-value"
69
+ fix: "Computing the expectation can repeat the mistake in the implementation. Write the expected value out.",
70
+ form: "a-method-that-computes-a-value"
55
71
  });
56
72
  var MUTATING_METHOD = firstEdition({
57
- fix: "write the finished array out as a literal",
58
- page: COMPUTED_VALUE_IN_A_TEST,
59
- section: "a-method-that-mutates"
73
+ fix: "Mutating the expected collection obscures its final state. State the finished collection so the reader can see what should be returned.",
74
+ form: "a-method-that-mutates"
60
75
  });
61
76
  var SHORT_CIRCUIT = secondEdition({
62
- fix: "write the value it gives; to narrow a value that may be missing, assert.isDefined it",
63
- page: BRANCH_IN_A_TEST,
64
- section: "a-short-circuit"
77
+ fix: "Short-circuiting lets the test skip a case when the unit returns an optional or falsy value. Make required output explicit in the unit's type or test each outcome separately.",
78
+ form: "a-short-circuit"
65
79
  });
66
80
  var INDEXED_OPTIONAL_CHAIN = secondEdition({
67
- fix: "compare the whole element with toMatchObject, or destructure it and assert.isDefined it before reading it",
68
- page: BRANCH_IN_A_TEST,
69
- section: "an-optional-chain-after-an-index"
81
+ fix: "Optional access hides whether the expected element exists. Assert the whole collection, or assert that the element is defined and then read it.",
82
+ form: "an-optional-chain-after-an-index"
70
83
  });
71
84
  var MOCK_CALL_OPTIONAL_CHAIN = secondEdition({
72
- fix: "assert the call with toHaveBeenNthCalledWith or toHaveBeenLastCalledWith",
73
- page: BRANCH_IN_A_TEST,
74
- section: "an-optional-chain-on-a-mock-call"
85
+ fix: "Optional access hides whether the dependency was called. Assert the expected call and its arguments.",
86
+ form: "an-optional-chain-on-a-mock-call"
75
87
  });
76
88
  var MOCK_RESULT_OPTIONAL_CHAIN = secondEdition({
77
- fix: "assert what it returned with toHaveNthReturnedWith or toHaveLastReturnedWith",
78
- page: BRANCH_IN_A_TEST,
79
- section: "an-optional-chain-on-a-mock-result"
89
+ fix: "Optional access hides whether the dependency returned a value. Write out what the collaborator gives back, then check what the unit returns and the call it makes.",
90
+ form: "an-optional-chain-on-a-mock-result"
80
91
  });
81
92
  var PROPERTY_OPTIONAL_CHAIN = secondEdition({
82
- fix: "compare the whole value with toMatchObject, or destructure it and assert.isDefined it before reading it",
83
- page: BRANCH_IN_A_TEST,
84
- section: "an-optional-chain-on-a-property"
93
+ fix: "The returned object can omit a property the caller needs. Make that property required in the unit's return type or test its absence as a separate outcome.",
94
+ form: "an-optional-chain-on-a-property"
85
95
  });
86
96
  var OPTIONAL_CALL = secondEdition({
87
- fix: "assert.isDefined the function, then call it",
88
- page: BRANCH_IN_A_TEST,
89
- section: "an-optional-call"
97
+ fix: "The unit's output makes the function optional, so callers cannot count on being able to call it. Make the function required in the return type or test the absent case separately.",
98
+ form: "an-optional-call"
90
99
  });
91
100
  var SWITCH = secondEdition({
92
- fix: "write one test per case, or one it.each table",
93
- page: BRANCH_IN_A_TEST,
94
- section: "a-switch"
101
+ fix: "The test branches on a value and can omit assertions for unexpected cases. State the expected outcome for each case separately.",
102
+ form: "a-switch"
95
103
  });
96
104
  var JSON_CALL = secondEdition({
97
- fix: "assert the object the unit gives back, written out; a unit that gives back only text should hand over an object, leaving the text to the adapter at its edge",
98
- page: TEXT_PAST_ITS_READER,
99
- section: "serialising-or-parsing-json"
105
+ fix: "Serializing or parsing inside the test can obscure the returned structure. Assert the object the caller needs and leave its wire format to the boundary adapter.",
106
+ form: "serialising-or-parsing-json"
100
107
  });
101
108
  var OBJECT_ASSIGN = secondEdition({
102
- fix: "write the object out, spreading what it copies; to give an Error a property, assign it",
103
- page: COMPUTED_VALUE_IN_A_TEST,
104
- section: "merging-objects"
109
+ fix: "Building the expected object by mutation obscures its final shape. State the fields the caller should see and make any copied fields explicit.",
110
+ form: "merging-objects"
105
111
  });
106
112
  var OBJECT_FROM_ENTRIES = secondEdition({
107
- fix: "write the object out as a literal",
108
- page: COMPUTED_VALUE_IN_A_TEST,
109
- section: "building-an-object-from-entries"
113
+ fix: "Building the expected object from entries hides the shape the assertion promises. Write the whole object out.",
114
+ form: "building-an-object-from-entries"
110
115
  });
111
116
  var ARRAY_FROM = secondEdition({
112
- fix: "write a short array out as a literal; the page shows no form for a long one",
113
- page: COMPUTED_VALUE_IN_A_TEST,
114
- section: "building-an-array-from-a-length"
117
+ fix: "Generating the expected array hides the sequence being asserted. Write the array out.",
118
+ form: "building-an-array-from-a-length"
115
119
  });
116
120
  var MATH_CALL = secondEdition({
117
- fix: "write the number out",
118
- page: COMPUTED_VALUE_IN_A_TEST,
119
- section: "a-math-call"
121
+ fix: "Calculating the expected number can reproduce the implementation's error. State the expected number directly.",
122
+ form: "a-math-call"
120
123
  });
121
124
  var PASSED_ON_FUNCTION = {
122
- fix: "make it a vi.fn spy with a written-out mockReturnValue, and assert what it was asked with toHaveBeenCalledExactlyOnceWith; the recipe is Stub with vi.fn",
123
- page: DOUBLE_WITH_A_BODY,
124
- section: "logic-inside-a-function-the-test-passes-on"
125
+ fix: "A callback with its own logic makes the test depend on a second implementation. Give the collaborator a fixed answer and assert how it was used.",
126
+ form: "logic-inside-a-function-the-test-passes-on"
125
127
  };
126
128
  var FORMS_IN_PAGE_ORDER = [
127
129
  BRANCHING,
@@ -148,8 +150,8 @@ var TEST_BODY_REMEDIES = [
148
150
  ...FORMS_IN_PAGE_ORDER.map((form) => form.remedy),
149
151
  PASSED_ON_FUNCTION
150
152
  ];
151
- var TEST_BODY_SECTIONS = TEST_BODY_REMEDIES.map(
152
- (remedy) => remedy.section
153
+ var TEST_BODY_FORMS = TEST_BODY_REMEDIES.map(
154
+ (remedy) => remedy.form
153
155
  );
154
156
  var PICKING_METHODS = [
155
157
  "at",
@@ -393,7 +395,7 @@ var objectFitsBuiltIn = (request) => {
393
395
  const fits = "from" in positions ? request.position >= positions.from : positions.at.includes(request.position);
394
396
  return fits ? "fits" : "never-fits";
395
397
  };
396
- var moduleTarget = (request) => request.specifier.startsWith(".") ? "own-api" : "built-in-or-library";
398
+ var moduleTarget = (request) => moduleOriginOf(request) === "own" ? "own-api" : "built-in-or-library";
397
399
  var loadedModuleOf = (request) => {
398
400
  const { syntaxApi, node } = request;
399
401
  if (!syntaxApi.isCallExpression(node)) return void 0;
@@ -433,23 +435,30 @@ var declarationsOf = (request) => {
433
435
  };
434
436
  var declarationsNamed = (request) => request.declarations.get(request.name) ?? [];
435
437
  var declarationTarget = (request) => {
436
- const { syntaxApi, declarations, node, visited } = request;
438
+ const { syntaxApi, declarations, ownPackageNames, node, visited } = request;
437
439
  if (syntaxApi.isImportEqualsDeclaration(node)) {
438
440
  const reference = node.moduleReference;
439
- return syntaxApi.isExternalModuleReference(reference) && syntaxApi.isStringLiteralLike(reference.expression) ? moduleTarget({ specifier: reference.expression.text }) : "own-api";
441
+ return syntaxApi.isExternalModuleReference(reference) && syntaxApi.isStringLiteralLike(reference.expression) ? moduleTarget({ specifier: reference.expression.text, ownPackageNames }) : "own-api";
440
442
  }
441
443
  if (!syntaxApi.isVariableDeclaration(node) || node.initializer === void 0) return "own-api";
442
- return originTarget({ syntaxApi, declarations, node: node.initializer, visited });
444
+ return originTarget({
445
+ syntaxApi,
446
+ declarations,
447
+ ownPackageNames,
448
+ node: node.initializer,
449
+ visited
450
+ });
443
451
  };
444
452
  var nameTarget = (request) => {
445
- const { syntaxApi, declarations, node, name, visited } = request;
453
+ const { syntaxApi, declarations, ownPackageNames, node, name, visited } = request;
446
454
  if (visited.includes(name)) return "own-api";
447
- if (BUILT_IN_NAMESPACES.includes(name) || packageBindingsOf({ syntaxApi, node }).includes(name))
455
+ if (BUILT_IN_NAMESPACES.includes(name) || packageBindingsOf({ syntaxApi, ownPackageNames, node }).includes(name))
448
456
  return "built-in-or-library";
449
457
  const fromLibrary = declarationsNamed({ declarations, name }).some(
450
458
  (declaration) => declarationTarget({
451
459
  syntaxApi,
452
460
  declarations,
461
+ ownPackageNames,
453
462
  node: declaration,
454
463
  visited: [...visited, name]
455
464
  }) === "built-in-or-library"
@@ -457,11 +466,18 @@ var nameTarget = (request) => {
457
466
  return fromLibrary ? "built-in-or-library" : "own-api";
458
467
  };
459
468
  var memberTarget = (request) => {
460
- const { syntaxApi, declarations, member, visited } = request;
469
+ const { syntaxApi, declarations, ownPackageNames, member, visited } = request;
461
470
  if (syntaxApi.isShorthandPropertyAssignment(member)) {
462
- return nameTarget({ syntaxApi, declarations, node: member, name: member.name.text, visited });
471
+ return nameTarget({
472
+ syntaxApi,
473
+ declarations,
474
+ ownPackageNames,
475
+ node: member,
476
+ name: member.name.text,
477
+ visited
478
+ });
463
479
  }
464
- return syntaxApi.isPropertyAssignment(member) ? originTarget({ syntaxApi, declarations, node: member.initializer, visited }) : "own-api";
480
+ return syntaxApi.isPropertyAssignment(member) ? originTarget({ syntaxApi, declarations, ownPackageNames, node: member.initializer, visited }) : "own-api";
465
481
  };
466
482
  var heldMembersNamed = (request) => {
467
483
  const { syntaxApi, declarations, holder, member } = request;
@@ -476,7 +492,7 @@ var heldMembersNamed = (request) => {
476
492
  });
477
493
  };
478
494
  var heldValueTarget = (request) => {
479
- const { syntaxApi, declarations, node, visited } = request;
495
+ const { syntaxApi, declarations, ownPackageNames, node, visited } = request;
480
496
  if (!syntaxApi.isPropertyAccessExpression(node) || !syntaxApi.isIdentifier(node.expression))
481
497
  return void 0;
482
498
  const members = heldMembersNamed({
@@ -488,29 +504,32 @@ var heldValueTarget = (request) => {
488
504
  });
489
505
  if (members.length === 0) return void 0;
490
506
  const fromLibrary = members.some(
491
- (member) => memberTarget({ syntaxApi, declarations, node, member, visited }) === "built-in-or-library"
507
+ (member) => memberTarget({ syntaxApi, declarations, ownPackageNames, node, member, visited }) === "built-in-or-library"
492
508
  );
493
509
  return fromLibrary ? "built-in-or-library" : "own-api";
494
510
  };
495
511
  var originTarget = (request) => {
496
- const { syntaxApi, declarations, node, visited } = request;
512
+ const { syntaxApi, declarations, ownPackageNames, node, visited } = request;
497
513
  const loadedModule = loadedModuleOf({ syntaxApi, node });
498
- if (loadedModule !== void 0) return moduleTarget({ specifier: loadedModule });
514
+ if (loadedModule !== void 0) return moduleTarget({ specifier: loadedModule, ownPackageNames });
499
515
  const held = heldValueTarget(request);
500
516
  if (held !== void 0) return held;
501
517
  if (syntaxApi.isIdentifier(node))
502
- return nameTarget({ syntaxApi, declarations, node, name: node.text, visited });
518
+ return nameTarget({ syntaxApi, declarations, ownPackageNames, node, name: node.text, visited });
503
519
  if (syntaxApi.isStringLiteralLike(node) || syntaxApi.isArrayLiteralExpression(node) || syntaxApi.isTemplateExpression(node)) {
504
520
  return "built-in-or-library";
505
521
  }
506
522
  const isChain = syntaxApi.isPropertyAccessExpression(node) || syntaxApi.isElementAccessExpression(node) || syntaxApi.isCallExpression(node) || syntaxApi.isParenthesizedExpression(node) || syntaxApi.isNonNullExpression(node) || syntaxApi.isAwaitExpression(node) || syntaxApi.isAsExpression(node) || syntaxApi.isSatisfiesExpression(node);
507
- return isChain ? originTarget({ syntaxApi, declarations, node: node.expression, visited }) : "own-api";
523
+ return isChain ? originTarget({ syntaxApi, declarations, ownPackageNames, node: node.expression, visited }) : "own-api";
508
524
  };
509
525
  var packageBindingsOf = (request) => request.node.getSourceFile().statements.flatMap((statement) => {
510
526
  const { syntaxApi } = request;
511
527
  if (!syntaxApi.isImportDeclaration(statement) || !syntaxApi.isStringLiteral(statement.moduleSpecifier))
512
528
  return [];
513
- if (statement.moduleSpecifier.text.startsWith(".") || statement.importClause === void 0)
529
+ if (moduleTarget({
530
+ specifier: statement.moduleSpecifier.text,
531
+ ownPackageNames: request.ownPackageNames
532
+ }) === "own-api" || statement.importClause === void 0)
514
533
  return [];
515
534
  const { name, namedBindings } = statement.importClause;
516
535
  const named = namedBindings === void 0 ? [] : syntaxApi.isNamespaceImport(namedBindings) ? [namedBindings.name.text] : namedBindings.elements.map((element) => element.name.text);
@@ -528,8 +547,14 @@ var argumentsTarget = (request) => {
528
547
  return objectNoBuiltInTakes ? "own-api" : "built-in-or-library";
529
548
  };
530
549
  var callTargetOf = (request) => {
531
- const { syntaxApi, declarations, call, method } = request;
532
- const target = originTarget({ syntaxApi, declarations, node: method.expression, visited: [] });
550
+ const { syntaxApi, declarations, ownPackageNames, call, method } = request;
551
+ const target = originTarget({
552
+ syntaxApi,
553
+ declarations,
554
+ ownPackageNames,
555
+ node: method.expression,
556
+ visited: []
557
+ });
533
558
  if (target === "built-in-or-library") return "built-in-or-library";
534
559
  return argumentsTarget({ syntaxApi, call, name: method.name.text });
535
560
  };
@@ -539,9 +564,15 @@ var listedMethodForm = (request) => {
539
564
  return callTargetOf(request) === "own-api" ? void 0 : form;
540
565
  };
541
566
  var callForm = (request) => {
542
- const { syntaxApi, declarations, node } = request;
567
+ const { syntaxApi, declarations, ownPackageNames, node } = request;
543
568
  if (!syntaxApi.isCallExpression(node)) return void 0;
544
- const calledForm = syntaxApi.isPropertyAccessExpression(node.expression) ? listedMethodForm({ syntaxApi, declarations, call: node, method: node.expression }) ?? namespaceForm({
569
+ const calledForm = syntaxApi.isPropertyAccessExpression(node.expression) ? listedMethodForm({
570
+ syntaxApi,
571
+ declarations,
572
+ ownPackageNames,
573
+ call: node,
574
+ method: node.expression
575
+ }) ?? namespaceForm({
545
576
  syntaxApi,
546
577
  node: node.expression.expression,
547
578
  name: node.expression.name.text
@@ -566,11 +597,21 @@ var expressionForm = (request) => {
566
597
  return callForm(request) ?? optionalChainForm(request);
567
598
  };
568
599
  var IMPLEMENTATION_TAKERS = ["mockImplementation", "mockImplementationOnce"];
600
+ var TEST_REGISTRATION = /* @__PURE__ */ new Set([
601
+ "it",
602
+ "test",
603
+ "describe",
604
+ "suite",
605
+ "beforeAll",
606
+ "beforeEach",
607
+ "afterEach",
608
+ "afterAll"
609
+ ]);
569
610
  var takesImplementation = (request) => {
570
611
  const { syntaxApi, node } = request;
571
- if (!syntaxApi.isCallExpression(node) || !syntaxApi.isPropertyAccessExpression(node.expression))
572
- return "other";
612
+ if (!syntaxApi.isCallExpression(node)) return "other";
573
613
  const callee = node.expression;
614
+ if (!syntaxApi.isPropertyAccessExpression(callee)) return "other";
574
615
  const isViFn = callee.name.text === "fn" && syntaxApi.isIdentifier(callee.expression) && callee.expression.text === "vi";
575
616
  return isViFn || IMPLEMENTATION_TAKERS.includes(callee.name.text) ? "takes" : "other";
576
617
  };
@@ -579,12 +620,22 @@ var enclosingFunctionOf = (request) => {
579
620
  if (request.syntaxApi.isFunctionLike(request.node)) return request.node;
580
621
  return enclosingFunctionOf({ syntaxApi: request.syntaxApi, node: request.node.parent });
581
622
  };
623
+ var findDirectCallbackEnclosure = (request) => {
624
+ const { syntaxApi, node } = request;
625
+ if (!syntaxApi.isCallExpression(node) || !syntaxApi.isIdentifier(node.expression) || TEST_REGISTRATION.has(node.expression.text)) {
626
+ return "elsewhere";
627
+ }
628
+ const enclosing = enclosingFunctionOf({ syntaxApi, node: node.parent });
629
+ if (enclosing === void 0) return "passed-on-function";
630
+ const registration = enclosing.parent;
631
+ return syntaxApi.isCallExpression(registration) && syntaxApi.isIdentifier(registration.expression) && TEST_REGISTRATION.has(registration.expression.text) ? "passed-on-function" : "elsewhere";
632
+ };
582
633
  var enclosureOf = (request) => {
583
634
  const { syntaxApi } = request;
584
635
  const enclosing = enclosingFunctionOf({ syntaxApi, node: request.node.parent });
585
636
  if (enclosing === void 0) return "elsewhere";
586
637
  const holder = syntaxApi.isPropertyAssignment(enclosing.parent) ? enclosing.parent.parent : enclosing.parent;
587
- const passedOn = syntaxApi.isObjectLiteralExpression(holder) || takesImplementation({ syntaxApi, node: holder }) === "takes";
638
+ const passedOn = syntaxApi.isObjectLiteralExpression(holder) || takesImplementation({ syntaxApi, node: holder }) === "takes" || findDirectCallbackEnclosure({ syntaxApi, node: holder }) === "passed-on-function";
588
639
  return passedOn ? "passed-on-function" : "elsewhere";
589
640
  };
590
641
  var testBodyFormOf = (request) => {
@@ -592,61 +643,55 @@ var testBodyFormOf = (request) => {
592
643
  if (form === void 0) return void 0;
593
644
  return enclosureOf(request) === "passed-on-function" ? { introducedIn: form.introducedIn, remedy: PASSED_ON_FUNCTION } : form;
594
645
  };
595
- var snippetAt = (request) => {
596
- const snippet = request.source.slice(request.position, request.position + 80).replace(/\n/g, " ");
597
- return snippet.length === 80 ? `${snippet}\u2026` : snippet;
598
- };
599
646
  var check = {
600
- prepare: ({ clauses, syntaxApi }) => ({
601
- outcome: "ok",
602
- value: {
603
- prepareFile: ({ file }) => {
604
- if (testFileEligibility({ file }) === "skipped") {
605
- return { outcome: "ok", value: { kind: "skipped" } };
606
- }
607
- return {
608
- outcome: "ok",
609
- value: {
610
- kind: "syntax",
611
- begin: ({ sourceFile, anchorAt }) => {
612
- const hits = [];
613
- const declarations = declarationsOf({ syntaxApi, sourceFile });
614
- return {
615
- enter: ({ node }) => {
616
- const form = testBodyFormOf({ syntaxApi, declarations, node });
617
- if (form === void 0) return;
618
- const reaching = clauses.filter(
619
- (clause) => editionReaches({
620
- edition: clause.edition,
621
- introducedIn: form.introducedIn
622
- }) === "reached"
623
- );
624
- if (reaching.length === 0) return;
625
- const position = node.getStart(sourceFile);
626
- const anchor = anchorAt({ position });
627
- const snippet = snippetAt({ source: sourceFile.text, position });
628
- hits.push(
629
- ...reaching.map((clause) => ({
630
- clause: clause.address,
631
- anchor,
632
- snippet,
633
- remedy: form.remedy
634
- }))
635
- );
636
- },
637
- finish: () => hits
638
- };
639
- }
647
+ prepare: ({ bindings, repository, syntaxApi }) => {
648
+ const ownPackageNames = ownPackageNamesOf({ repository });
649
+ return {
650
+ outcome: "ok",
651
+ value: {
652
+ prepareFile: ({ file }) => {
653
+ if (testFileEligibility({ file, testFiles: repository.testFiles }) === "skipped") {
654
+ return { outcome: "ok", value: { kind: "skipped" } };
640
655
  }
641
- };
642
- },
643
- finish: () => ({ outcome: "ok", value: [] })
644
- }
645
- })
656
+ return {
657
+ outcome: "ok",
658
+ value: {
659
+ kind: "syntax",
660
+ begin: ({ sourceFile, anchorAt }) => {
661
+ const hits = [];
662
+ const declarations = declarationsOf({ syntaxApi, sourceFile });
663
+ return {
664
+ enter: ({ node }) => {
665
+ const form = testBodyFormOf({
666
+ syntaxApi,
667
+ declarations,
668
+ ownPackageNames,
669
+ node
670
+ });
671
+ if (form === void 0) return;
672
+ const binding = bindings.find(
673
+ ({ address, forms, edition }) => forms?.[form.remedy.form] === address && editionReaches({ edition, introducedIn: form.introducedIn }) === "reached"
674
+ );
675
+ if (binding === void 0) return;
676
+ const position = node.getStart(sourceFile);
677
+ const anchor = anchorAt({ position });
678
+ const snippet = sourceSnippetAt({ source: sourceFile.text, position });
679
+ hits.push({ check: binding.address, anchor, snippet, remedy: form.remedy });
680
+ },
681
+ finish: () => hits
682
+ };
683
+ }
684
+ }
685
+ };
686
+ },
687
+ finish: () => ({ outcome: "ok", value: [] })
688
+ }
689
+ };
690
+ }
646
691
  };
647
692
  export {
693
+ TEST_BODY_FORMS,
648
694
  TEST_BODY_REMEDIES,
649
- TEST_BODY_SECTIONS,
650
695
  check,
651
696
  declarationsOf,
652
697
  testBodyFormOf
@@ -0,0 +1,24 @@
1
+ {
2
+ "flag": [
3
+ {
4
+ "name": "configured unit called without a name",
5
+ "fileName": "src/checkout.ts",
6
+ "source": "checkoutOf({ clock })({ order });",
7
+ "expectedLines": [1]
8
+ }
9
+ ],
10
+ "allow": [
11
+ {
12
+ "name": "configured unit named before its call",
13
+ "fileName": "src/checkout.ts",
14
+ "source": "const checkout = checkoutOf({ clock });\ncheckout({ order });",
15
+ "expectedLines": []
16
+ },
17
+ {
18
+ "name": "table argument is an array",
19
+ "fileName": "src/checkout.test.ts",
20
+ "source": "it.each([1])(\"order\", () => {});",
21
+ "expectedLines": []
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,34 @@
1
+ import {
2
+ syntaxNodeCheck
3
+ } from "../../../../../../chunks/chunk-LEFM7OPS.js";
4
+ import {
5
+ withoutParentheses
6
+ } from "../../../../../../chunks/chunk-EBX57Z3V.js";
7
+ import "../../../../../../chunks/chunk-5AKHEW6V.js";
8
+ import {
9
+ typeScriptSourceEligibility
10
+ } from "../../../../../../chunks/chunk-COQMPHWZ.js";
11
+ import "../../../../../../chunks/chunk-DGOLOS5A.js";
12
+
13
+ // src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/call-of-a-call.ts
14
+ var immediateBuilderOf = ({ syntaxApi, node }) => {
15
+ if (!syntaxApi.isCallExpression(node)) return void 0;
16
+ const callee = withoutParentheses({ syntaxApi, node: node.expression });
17
+ if (!syntaxApi.isCallExpression(callee)) return void 0;
18
+ return callee.arguments.some(
19
+ (argument) => syntaxApi.isObjectLiteralExpression(withoutParentheses({ syntaxApi, node: argument }))
20
+ ) ? callee : void 0;
21
+ };
22
+ var check = syntaxNodeCheck({
23
+ eligibility: typeScriptSourceEligibility,
24
+ found: (visit) => {
25
+ const builder = immediateBuilderOf(visit);
26
+ if (builder === void 0) return void 0;
27
+ if (immediateBuilderOf({ syntaxApi: visit.syntaxApi, node: builder }) !== void 0)
28
+ return void 0;
29
+ return { at: builder, snippet: builder.expression.getText(visit.sourceFile) };
30
+ }
31
+ });
32
+ export {
33
+ check
34
+ };
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": 2,
3
+ "anchor": {
4
+ "kind": "file"
5
+ },
6
+ "settings": {
7
+ "module": "call-of-a-call.js"
8
+ }
9
+ }
@@ -2,10 +2,12 @@ import {
2
2
  anyBearingOf,
3
3
  assertionOf,
4
4
  castSnippetAt
5
- } from "../../../../../../chunks/chunk-QP5TLOBY.js";
5
+ } from "../../../../../../chunks/chunk-HVZVKZPW.js";
6
+ import "../../../../../../chunks/chunk-EBX57Z3V.js";
7
+ import "../../../../../../chunks/chunk-5AKHEW6V.js";
6
8
  import {
7
9
  folderScope
8
- } from "../../../../../../chunks/chunk-K2W3D3NB.js";
10
+ } from "../../../../../../chunks/chunk-COQMPHWZ.js";
9
11
  import "../../../../../../chunks/chunk-DGOLOS5A.js";
10
12
 
11
13
  // src/infrastructure/engines/walker/claimed-type/cast-to-any/any-cast.ts
@@ -15,7 +17,7 @@ var sourceEligibility = (request) => {
15
17
  return "eligible";
16
18
  };
17
19
  var check = {
18
- prepare: ({ clauses, syntaxApi }) => ({
20
+ prepare: ({ bindings, syntaxApi }) => ({
19
21
  outcome: "ok",
20
22
  value: {
21
23
  prepareFile: ({ file }) => {
@@ -37,7 +39,7 @@ var check = {
37
39
  const snippet = castSnippetAt({ sourceFile, position });
38
40
  const anchor = anchorAt({ position });
39
41
  hits.push(
40
- ...clauses.map((clause) => ({ clause: clause.address, anchor, snippet }))
42
+ ...bindings.map((binding) => ({ check: binding.address, anchor, snippet }))
41
43
  );
42
44
  },
43
45
  finish: () => hits