@hailstails/hone 2.0.0-pre.2 → 2.0.0-pre.4

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 (201) hide show
  1. package/ADOPTING.md +7 -7
  2. package/CHANGELOG.md +76 -0
  3. package/MIGRATING.md +15 -6
  4. package/README.md +12 -13
  5. package/chunks/chunk-3CWFUD5B.js +38 -0
  6. package/chunks/chunk-5AKHEW6V.js +15 -0
  7. package/chunks/chunk-75XWZYNN.js +64 -0
  8. package/chunks/chunk-7FVSZ2VL.js +1304 -0
  9. package/chunks/chunk-A3RL4O5V.js +146 -0
  10. package/chunks/chunk-BIDD2YWP.js +398 -0
  11. package/chunks/{chunk-GNOMK7CR.js → chunk-BKQ3K766.js} +489 -52
  12. package/chunks/{chunk-NRIQD3PI.js → chunk-BRANVR7K.js} +3 -5
  13. package/chunks/chunk-COQMPHWZ.js +37 -0
  14. package/chunks/{chunk-L7BGRC6D.js → chunk-CXM5KBZX.js} +1 -1
  15. package/chunks/chunk-D6645WPB.js +6 -0
  16. package/chunks/chunk-DJMF6JIM.js +42 -0
  17. package/chunks/{chunk-OKLYWD2Z.js → chunk-E4D5WDRX.js} +27 -20
  18. package/chunks/chunk-EBX57Z3V.js +8 -0
  19. package/chunks/chunk-FHVNKG5Q.js +19 -0
  20. package/chunks/chunk-FPIP7JEC.js +191 -0
  21. package/chunks/{chunk-QP5TLOBY.js → chunk-HVZVKZPW.js} +12 -9
  22. package/chunks/chunk-LD766VWU.js +57 -0
  23. package/chunks/chunk-LEFM7OPS.js +41 -0
  24. package/chunks/chunk-LNMDMRGQ.js +51 -0
  25. package/chunks/{chunk-RGSHTPLA.js → chunk-MBEDAFVC.js} +3 -11
  26. package/chunks/chunk-OO5KV7KN.js +17 -0
  27. package/chunks/{chunk-ASUN4AVC.js → chunk-PVSC4SE3.js} +71 -5
  28. package/chunks/chunk-SKDQ3QJD.js +75 -0
  29. package/chunks/chunk-W5OIAUDW.js +18 -0
  30. package/chunks/chunk-X73RZUPO.js +63 -0
  31. package/chunks/chunk-XE2KKWYH.js +45 -0
  32. package/chunks/chunk-YGMO5Z6U.js +432 -0
  33. package/chunks/chunk-YONPKP3C.js +15 -0
  34. package/docs/adding-a-discipline-or-mechanism.md +1 -1
  35. package/docs/extending.md +7 -388
  36. package/package.json +7 -6
  37. package/rules/README.md +2 -2
  38. package/rules/typescript/checks.md +236 -18
  39. package/rules/typescript/symptoms/ambient-randomness/random-call.md +10 -0
  40. package/rules/typescript/symptoms/answer-set-in-a-hook/hook-answer.md +10 -0
  41. package/rules/typescript/symptoms/assertion-outside-a-test/assertion-site.md +10 -0
  42. package/rules/typescript/symptoms/assertion-outside-a-test.md +25 -0
  43. package/rules/typescript/symptoms/built-unit-called-in-place/call-of-a-call.md +10 -0
  44. package/rules/typescript/symptoms/built-unit-called-in-place.md +25 -0
  45. package/rules/typescript/symptoms/code-or-prose-read-as-text/raw-read.md +10 -0
  46. package/rules/typescript/symptoms/code-or-prose-read-as-text.md +31 -0
  47. package/rules/typescript/symptoms/computed-value-in-a-test/test-body.md +1 -1
  48. package/rules/typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md +1 -1
  49. package/rules/typescript/symptoms/double-with-a-body/stub-implementation.md +2 -2
  50. package/rules/typescript/symptoms/export-from-a-test-file/test-file-export.md +10 -0
  51. package/rules/typescript/symptoms/export-from-a-test-file.md +33 -0
  52. package/rules/typescript/symptoms/failure-shaped-as-success/empty-catch.md +10 -0
  53. package/rules/typescript/symptoms/floating-version/version-selector.md +10 -0
  54. package/rules/typescript/symptoms/inherited-environment-in-a-subprocess/git-spawn-environment.md +1 -1
  55. package/rules/typescript/symptoms/many-spellings-of-one-concept/test-call-aliases.md +10 -0
  56. package/rules/typescript/symptoms/many-spellings-of-one-concept.md +3 -2
  57. package/rules/typescript/symptoms/module-or-global-patched/module-mock-call.md +4 -4
  58. package/rules/typescript/symptoms/no-lock-file/committed-lock-file.md +12 -0
  59. package/rules/typescript/symptoms/process-global-used-in-place/debugger-statement.md +10 -0
  60. package/rules/typescript/symptoms/process-global-used-in-place/direct-global-use.md +14 -0
  61. package/rules/typescript/symptoms/process-global-used-in-place.md +1 -1
  62. package/rules/typescript/symptoms/prose-in-code/comment-prose.md +12 -0
  63. package/rules/typescript/symptoms/test-switched-off/skipped-tests.md +3 -6
  64. package/rules/typescript/symptoms/test-switched-off.md +1 -1
  65. package/rules/typescript/symptoms/throw-between-our-units/throw-statement.md +10 -0
  66. package/rules/typescript/symptoms/throw-or-catch-in-a-test/throw-statement.md +1 -1
  67. package/rules/typescript/symptoms/tool-fetched-at-run-time/fetch-command.md +10 -0
  68. package/rules/typescript/symptoms/type-declared-in-a-test/test-type-declaration.md +10 -0
  69. package/rules/typescript/symptoms/type-declared-in-a-test.md +33 -0
  70. package/rules/typescript/symptoms/unit-without-a-running-test/companion-test-file.md +2 -2
  71. package/rules/typescript/symptoms/wide-input/unread-parameter.md +10 -0
  72. package/rules/typescript/symptoms/wide-input.md +3 -2
  73. package/rules/typescript/symptoms.md +183 -121
  74. package/src/application/conformance/conformance-testing-types.d.ts +13 -16
  75. package/src/domain/language-layer/authored-item-types.d.ts +50 -0
  76. package/src/domain/language-layer/catalogue-name.d.ts +5 -0
  77. package/src/domain/language-layer/check-address-text.d.ts +12 -0
  78. package/src/domain/rule-set/authored-rule-set-types.d.ts +31 -32
  79. package/src/domain/rule-set/clause-address-types.d.ts +4 -3
  80. package/src/domain/rule-set/rule-set-name-of.d.ts +10 -0
  81. package/src/domain/runner/check-binding.d.ts +18 -0
  82. package/src/domain/runner/check-observations.d.ts +39 -0
  83. package/src/domain/runner/conformance-types.d.ts +8 -2
  84. package/src/domain/settings/test-files.d.ts +7 -0
  85. package/src/eslint-plugin.js +16 -12
  86. package/src/hone.js +10493 -10410
  87. package/src/infrastructure/engines/eslint/authored-class-or-this/static-members-only/piece.json +0 -6
  88. package/src/infrastructure/engines/eslint/long-function/function-length/piece.json +0 -6
  89. package/src/infrastructure/engines/eslint/runner/pieces/eslint-piece-settings-types.d.ts +2 -0
  90. package/src/infrastructure/engines/eslint/runner/runner.js +953 -1189
  91. package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/README.md +0 -3
  92. package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/eslint-plugin.js +33 -21
  93. package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/piece.json +11 -4
  94. package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/skipped-tests.examples.json +28 -0
  95. package/src/infrastructure/engines/eslint/untyped-value/implicit-any-let/piece.json +0 -2
  96. package/src/infrastructure/engines/eslint/wide-input/unread-parameter/eslint-plugin.js +94 -0
  97. package/src/infrastructure/engines/eslint/wide-input/unread-parameter/piece.json +11 -0
  98. package/src/infrastructure/engines/eslint/wide-input/unread-parameter/unread-parameter.examples.json +48 -0
  99. package/src/infrastructure/engines/walker/ambient-randomness/random-call/ambient-randomness.js +109 -0
  100. package/src/infrastructure/engines/walker/ambient-randomness/random-call/piece.json +9 -0
  101. package/src/infrastructure/engines/walker/ambient-randomness/random-call/random-call.examples.json +48 -0
  102. package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/hook-answer.examples.json +42 -0
  103. package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/hook-answers.js +72 -0
  104. package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/piece.json +9 -0
  105. package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/assertion-site.examples.json +30 -0
  106. package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/assertion-site.js +123 -0
  107. package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/piece.json +9 -0
  108. package/src/infrastructure/engines/walker/authored-class-or-this/class-keyword/class-syntax.js +3 -3
  109. package/src/infrastructure/engines/walker/boolean-in-a-signature/boolean-annotation/boolean-signatures.js +7 -5
  110. package/src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body-logic.js +213 -126
  111. package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/call-of-a-call.examples.json +24 -0
  112. package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/call-of-a-call.js +34 -0
  113. package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/piece.json +9 -0
  114. package/src/infrastructure/engines/walker/claimed-type/cast-to-any/any-cast.js +6 -4
  115. package/src/infrastructure/engines/walker/claimed-type/unlisted-cast-site/cast-expressions.js +6 -4
  116. package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/piece.json +9 -0
  117. package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/raw-read.examples.json +30 -0
  118. package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/raw-read.js +166 -0
  119. package/src/infrastructure/engines/walker/computed-value-in-a-test/test-body/piece.json +0 -10
  120. package/src/infrastructure/engines/walker/date-used-directly/clock-sources/clock-sources.js +4 -4
  121. package/src/infrastructure/engines/walker/default-on-a-closed-union/default-arm/switch-defaults.js +8 -6
  122. package/src/infrastructure/engines/walker/double-with-a-body/logic-in-a-passed-function/piece.json +0 -10
  123. package/src/infrastructure/engines/walker/double-with-a-body/stub-implementation/dependency-isolation.js +9 -14
  124. package/src/infrastructure/engines/walker/drawer-path/drawer-names/categorical-paths.js +4 -4
  125. package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/piece.json +9 -0
  126. package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/test-file-export.examples.json +30 -0
  127. package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/test-file-export.js +31 -0
  128. package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.examples.json +18 -0
  129. package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.js +32 -0
  130. package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/piece.json +9 -0
  131. package/src/infrastructure/engines/walker/floating-version/version-selector/piece.json +9 -0
  132. package/src/infrastructure/engines/walker/floating-version/version-selector/version-selector.examples.json +54 -0
  133. package/src/infrastructure/engines/walker/floating-version/version-selector/version-selector.js +75 -0
  134. package/src/infrastructure/engines/walker/inherited-environment-in-a-subprocess/git-spawn-environment/hermetic-git-spawns.js +8 -17
  135. package/src/infrastructure/engines/walker/loop-keyword/loop-statement/loops.js +8 -6
  136. package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/piece.json +9 -0
  137. package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/test-call-aliases.examples.json +36 -0
  138. package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/test-call-aliases.js +67 -0
  139. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mock-call.examples.json +34 -0
  140. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mocking.js +64 -16
  141. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/piece.json +5 -1
  142. package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/committed-lock-file.examples.json +24 -0
  143. package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/committed-lock-file.js +41 -0
  144. package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/piece.json +9 -0
  145. package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/import-boundaries.js +18 -16
  146. package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/piece.json +1 -1
  147. package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/debugger-statement.examples.json +18 -0
  148. package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/debugger-statement.js +17 -0
  149. package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/piece.json +9 -0
  150. package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/direct-global-use.examples.json +63 -0
  151. package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/piece.json +13 -0
  152. package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/process-global-used-in-place.js +126 -0
  153. package/src/infrastructure/engines/walker/prose-in-code/comment-prose/comment-prose.examples.json +42 -0
  154. package/src/infrastructure/engines/walker/prose-in-code/comment-prose/piece.json +16 -0
  155. package/src/infrastructure/engines/walker/prose-in-code/comment-prose/prose-in-code.js +90 -0
  156. package/src/infrastructure/engines/walker/rebinding/test-body/piece.json +0 -10
  157. package/src/infrastructure/engines/walker/runner/pieces/walker-piece.d.ts +7 -5
  158. package/src/infrastructure/engines/walker/runner/runner.js +266 -77
  159. package/src/infrastructure/engines/walker/runner/toolchain/typescript-parse.d.ts +3 -0
  160. package/src/infrastructure/engines/walker/shorthand-name/identifier-names/identifier-names.js +12 -7
  161. package/src/infrastructure/engines/walker/strictness-weakened/exact-optional-property-types/piece.json +0 -10
  162. package/src/infrastructure/engines/walker/strictness-weakened/no-fallthrough-cases-in-switch/piece.json +0 -10
  163. package/src/infrastructure/engines/walker/strictness-weakened/no-implicit-override/piece.json +0 -10
  164. package/src/infrastructure/engines/walker/strictness-weakened/no-property-access-from-index-signature/piece.json +0 -10
  165. package/src/infrastructure/engines/walker/strictness-weakened/no-unchecked-indexed-access/piece.json +0 -10
  166. package/src/infrastructure/engines/walker/strictness-weakened/strict/compiler-overrides.js +30 -52
  167. package/src/infrastructure/engines/walker/strictness-weakened/use-unknown-in-catch-variables/piece.json +0 -10
  168. package/src/infrastructure/engines/walker/text-past-its-reader/test-body/piece.json +0 -10
  169. package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/piece.json +9 -0
  170. package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/throw-statement.examples.json +36 -0
  171. package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/throws-in-production.js +12 -0
  172. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throw-statement.examples.json +6 -6
  173. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throws-in-tests.js +5 -44
  174. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/try-block/piece.json +0 -10
  175. package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/fetch-command.examples.json +42 -0
  176. package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/fetch-command.js +152 -0
  177. package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/piece.json +9 -0
  178. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/piece.json +9 -0
  179. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.examples.json +24 -0
  180. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.js +27 -0
  181. package/src/infrastructure/engines/walker/type-derived-from-code/factory-return-types/factory-return-types.js +8 -6
  182. package/src/infrastructure/engines/walker/unit-without-a-running-test/companion-test-file/export-test-sibling.js +16 -10
  183. package/src/infrastructure/engines/walker/untracked-escape/directive-pointers/comments-directives.js +18 -64
  184. package/src/infrastructure/engines/walker/write-into-a-parameter/parameter-mutation/parameter-mutation.js +7 -5
  185. package/src/rule-set.d.ts +2 -1
  186. package/src/testing.d.ts +2 -4
  187. package/src/testing.js +104 -317
  188. package/src/{audit.d.ts → walker.d.ts} +13 -8
  189. package/src/walker.js +28 -0
  190. package/chunks/chunk-5HRMJ4O2.js +0 -608
  191. package/chunks/chunk-IX2VZTBO.js +0 -887
  192. package/chunks/chunk-K2W3D3NB.js +0 -17
  193. package/chunks/chunk-M6SOGWT7.js +0 -82
  194. package/chunks/chunk-MWLBA4B3.js +0 -849
  195. package/chunks/chunk-R75QELTA.js +0 -481
  196. package/chunks/chunk-RANAKCTW.js +0 -31
  197. package/chunks/chunk-TNY2PASL.js +0 -38
  198. package/chunks/chunk-UJONWHA4.js +0 -22
  199. package/docs/output-contract.md +0 -1155
  200. package/src/audit.js +0 -18
  201. package/src/domain/runner/runner-module-types.d.ts +0 -15
@@ -1,19 +1,47 @@
1
+ import {
2
+ PACKAGE_MANIFEST
3
+ } from "../../../../../../chunks/chunk-SKDQ3QJD.js";
4
+ import {
5
+ createDefaultJsoncParsePort
6
+ } from "../../../../../../chunks/chunk-DJMF6JIM.js";
1
7
  import {
2
8
  editionOf
3
9
  } from "../../../../../../chunks/chunk-RFR3ITBS.js";
4
10
  import {
5
- folderScope
6
- } from "../../../../../../chunks/chunk-K2W3D3NB.js";
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
46
  var BRANCH_IN_A_TEST = "branch-in-a-test/test-body.md";
19
47
  var COMPUTED_VALUE_IN_A_TEST = "computed-value-in-a-test/test-body.md";
@@ -24,102 +52,102 @@ var DOUBLE_WITH_A_BODY = "double-with-a-body/logic-in-a-passed-function.md";
24
52
  var firstEdition = (remedy) => ({ introducedIn: editionOf("1"), remedy });
25
53
  var secondEdition = (remedy) => ({ introducedIn: SECOND_EDITION, remedy });
26
54
  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",
55
+ 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.",
28
56
  page: BRANCH_IN_A_TEST,
29
57
  section: "branching-with-if"
30
58
  });
31
59
  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",
60
+ fix: "Catching inside the test can let it pass when no error occurs. Assert the failure the caller should observe, whether it is returned or thrown.",
33
61
  page: THROW_OR_CATCH_IN_A_TEST,
34
62
  section: "a-try-block"
35
63
  });
36
64
  var TERNARY = firstEdition({
37
- fix: "write the value out, or give each case its own it.each row",
65
+ fix: "The test chooses between values at runtime. State the expected value for each case so the assertion cannot adapt to the result.",
38
66
  page: BRANCH_IN_A_TEST,
39
67
  section: "a-ternary"
40
68
  });
41
69
  var LET = firstEdition({
42
- fix: "use const; record calls with vi.fn and assert them with toHaveBeenCalledWith",
70
+ fix: "A reassigned local makes the test depend on hidden state. Keep the expected values fixed and assert the interaction you need to observe.",
43
71
  page: REBINDING,
44
72
  section: "a-let"
45
73
  });
46
74
  var PICKING_METHOD = firstEdition({
47
- fix: "assert on the whole array with toEqual, toContain, toContainEqual or expect.arrayContaining",
75
+ fix: "Selecting an element can discard data the caller should see. Assert the relevant membership or structure of the returned collection directly.",
48
76
  page: COMPUTED_VALUE_IN_A_TEST,
49
77
  section: "a-method-that-picks-or-tests-an-element"
50
78
  });
51
79
  var COMPUTING_METHOD = firstEdition({
52
- fix: "write the expected value out, or match part of it with toMatchObject, toHaveLength or expect.stringContaining",
80
+ fix: "Computing the expectation can repeat the mistake in the implementation. Write the expected value or the relevant properties explicitly.",
53
81
  page: COMPUTED_VALUE_IN_A_TEST,
54
82
  section: "a-method-that-computes-a-value"
55
83
  });
56
84
  var MUTATING_METHOD = firstEdition({
57
- fix: "write the finished array out as a literal",
85
+ fix: "Mutating the expected collection obscures its final state. State the finished collection so the reader can see what should be returned.",
58
86
  page: COMPUTED_VALUE_IN_A_TEST,
59
87
  section: "a-method-that-mutates"
60
88
  });
61
89
  var SHORT_CIRCUIT = secondEdition({
62
- fix: "write the value it gives; to narrow a value that may be missing, assert.isDefined it",
90
+ 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.",
63
91
  page: BRANCH_IN_A_TEST,
64
92
  section: "a-short-circuit"
65
93
  });
66
94
  var INDEXED_OPTIONAL_CHAIN = secondEdition({
67
- fix: "compare the whole element with toMatchObject, or destructure it and assert.isDefined it before reading it",
95
+ fix: "Optional access hides whether the expected element exists. Assert that the collection contains the required element and its relevant contents.",
68
96
  page: BRANCH_IN_A_TEST,
69
97
  section: "an-optional-chain-after-an-index"
70
98
  });
71
99
  var MOCK_CALL_OPTIONAL_CHAIN = secondEdition({
72
- fix: "assert the call with toHaveBeenNthCalledWith or toHaveBeenLastCalledWith",
100
+ fix: "Optional access hides whether the dependency was called. Assert the expected call and its arguments.",
73
101
  page: BRANCH_IN_A_TEST,
74
102
  section: "an-optional-chain-on-a-mock-call"
75
103
  });
76
104
  var MOCK_RESULT_OPTIONAL_CHAIN = secondEdition({
77
- fix: "assert what it returned with toHaveNthReturnedWith or toHaveLastReturnedWith",
105
+ fix: "Optional access hides whether the dependency returned a value. Assert the return from the expected call.",
78
106
  page: BRANCH_IN_A_TEST,
79
107
  section: "an-optional-chain-on-a-mock-result"
80
108
  });
81
109
  var PROPERTY_OPTIONAL_CHAIN = secondEdition({
82
- fix: "compare the whole value with toMatchObject, or destructure it and assert.isDefined it before reading it",
110
+ 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.",
83
111
  page: BRANCH_IN_A_TEST,
84
112
  section: "an-optional-chain-on-a-property"
85
113
  });
86
114
  var OPTIONAL_CALL = secondEdition({
87
- fix: "assert.isDefined the function, then call it",
115
+ 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.",
88
116
  page: BRANCH_IN_A_TEST,
89
117
  section: "an-optional-call"
90
118
  });
91
119
  var SWITCH = secondEdition({
92
- fix: "write one test per case, or one it.each table",
120
+ fix: "The test branches on a value and can omit assertions for unexpected cases. State the expected outcome for each case separately.",
93
121
  page: BRANCH_IN_A_TEST,
94
122
  section: "a-switch"
95
123
  });
96
124
  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",
125
+ 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.",
98
126
  page: TEXT_PAST_ITS_READER,
99
127
  section: "serialising-or-parsing-json"
100
128
  });
101
129
  var OBJECT_ASSIGN = secondEdition({
102
- fix: "write the object out, spreading what it copies; to give an Error a property, assign it",
130
+ fix: "Building the expected object by mutation obscures its final shape. State the fields the caller should see and make any copied fields explicit.",
103
131
  page: COMPUTED_VALUE_IN_A_TEST,
104
132
  section: "merging-objects"
105
133
  });
106
134
  var OBJECT_FROM_ENTRIES = secondEdition({
107
- fix: "write the object out as a literal",
135
+ fix: "Building the expected object from entries hides the shape the assertion promises. Write out the relevant fields and values.",
108
136
  page: COMPUTED_VALUE_IN_A_TEST,
109
137
  section: "building-an-object-from-entries"
110
138
  });
111
139
  var ARRAY_FROM = secondEdition({
112
- fix: "write a short array out as a literal; the page shows no form for a long one",
140
+ fix: "Generating the expected array hides the sequence being asserted. State the relevant elements, length, or ordering directly.",
113
141
  page: COMPUTED_VALUE_IN_A_TEST,
114
142
  section: "building-an-array-from-a-length"
115
143
  });
116
144
  var MATH_CALL = secondEdition({
117
- fix: "write the number out",
145
+ fix: "Calculating the expected number can reproduce the implementation's error. State the expected number directly.",
118
146
  page: COMPUTED_VALUE_IN_A_TEST,
119
147
  section: "a-math-call"
120
148
  });
121
149
  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",
150
+ 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.",
123
151
  page: DOUBLE_WITH_A_BODY,
124
152
  section: "logic-inside-a-function-the-test-passes-on"
125
153
  };
@@ -393,7 +421,7 @@ var objectFitsBuiltIn = (request) => {
393
421
  const fits = "from" in positions ? request.position >= positions.from : positions.at.includes(request.position);
394
422
  return fits ? "fits" : "never-fits";
395
423
  };
396
- var moduleTarget = (request) => request.specifier.startsWith(".") ? "own-api" : "built-in-or-library";
424
+ var moduleTarget = (request) => moduleOriginOf(request) === "own" ? "own-api" : "built-in-or-library";
397
425
  var loadedModuleOf = (request) => {
398
426
  const { syntaxApi, node } = request;
399
427
  if (!syntaxApi.isCallExpression(node)) return void 0;
@@ -401,102 +429,133 @@ var loadedModuleOf = (request) => {
401
429
  const [specifier] = node.arguments;
402
430
  return loads && specifier !== void 0 && syntaxApi.isStringLiteralLike(specifier) ? specifier.text : void 0;
403
431
  };
404
- var bindsName = (request) => {
405
- const { syntaxApi, binding, name } = request;
406
- if (syntaxApi.isIdentifier(binding)) return binding.text === name ? "binds" : "other";
432
+ var boundNames = (request) => {
433
+ const { syntaxApi, binding } = request;
434
+ if (syntaxApi.isIdentifier(binding)) return [binding.text];
407
435
  if (!syntaxApi.isObjectBindingPattern(binding) && !syntaxApi.isArrayBindingPattern(binding))
408
- return "other";
409
- const binds = binding.elements.some(
410
- (element) => syntaxApi.isBindingElement(element) && bindsName({ syntaxApi, binding: element.name, name }) === "binds"
436
+ return [];
437
+ return binding.elements.flatMap(
438
+ (element) => syntaxApi.isBindingElement(element) ? boundNames({ syntaxApi, binding: element.name }) : []
411
439
  );
412
- return binds ? "binds" : "other";
413
440
  };
414
- var declarationsNamed = (request) => {
415
- const { syntaxApi, name } = request;
416
- const declarations = [];
441
+ var declaredNames = (request) => {
442
+ const { syntaxApi, node } = request;
443
+ if (syntaxApi.isVariableDeclaration(node))
444
+ return [...new Set(boundNames({ syntaxApi, binding: node.name }))];
445
+ return syntaxApi.isImportEqualsDeclaration(node) ? [node.name.text] : [];
446
+ };
447
+ var declarationsOf = (request) => {
448
+ const { syntaxApi } = request;
449
+ const declared = [];
417
450
  const visit = (node) => {
418
- const declares = syntaxApi.isVariableDeclaration(node) && bindsName({ syntaxApi, binding: node.name, name }) === "binds" || syntaxApi.isImportEqualsDeclaration(node) && node.name.text === name;
419
- if (declares) declarations.push(node);
451
+ declared.push(...declaredNames({ syntaxApi, node }).map((name) => ({ name, node })));
420
452
  syntaxApi.forEachChild(node, visit);
421
453
  };
422
- visit(request.node.getSourceFile());
423
- return declarations;
454
+ visit(request.sourceFile);
455
+ return new Map(
456
+ [...Map.groupBy(declared, ({ name }) => name)].map(([name, entries]) => [
457
+ name,
458
+ entries.map(({ node }) => node)
459
+ ])
460
+ );
424
461
  };
462
+ var declarationsNamed = (request) => request.declarations.get(request.name) ?? [];
425
463
  var declarationTarget = (request) => {
426
- const { syntaxApi, node, visited } = request;
464
+ const { syntaxApi, declarations, ownPackageNames, node, visited } = request;
427
465
  if (syntaxApi.isImportEqualsDeclaration(node)) {
428
466
  const reference = node.moduleReference;
429
- return syntaxApi.isExternalModuleReference(reference) && syntaxApi.isStringLiteralLike(reference.expression) ? moduleTarget({ specifier: reference.expression.text }) : "own-api";
467
+ return syntaxApi.isExternalModuleReference(reference) && syntaxApi.isStringLiteralLike(reference.expression) ? moduleTarget({ specifier: reference.expression.text, ownPackageNames }) : "own-api";
430
468
  }
431
469
  if (!syntaxApi.isVariableDeclaration(node) || node.initializer === void 0) return "own-api";
432
- return originTarget({ syntaxApi, node: node.initializer, visited });
470
+ return originTarget({
471
+ syntaxApi,
472
+ declarations,
473
+ ownPackageNames,
474
+ node: node.initializer,
475
+ visited
476
+ });
433
477
  };
434
478
  var nameTarget = (request) => {
435
- const { syntaxApi, node, name, visited } = request;
479
+ const { syntaxApi, declarations, ownPackageNames, node, name, visited } = request;
436
480
  if (visited.includes(name)) return "own-api";
437
- if (BUILT_IN_NAMESPACES.includes(name) || packageBindingsOf({ syntaxApi, node }).includes(name))
481
+ if (BUILT_IN_NAMESPACES.includes(name) || packageBindingsOf({ syntaxApi, ownPackageNames, node }).includes(name))
438
482
  return "built-in-or-library";
439
- const fromLibrary = declarationsNamed({ syntaxApi, node, name }).some(
440
- (declaration) => declarationTarget({ syntaxApi, node: declaration, visited: [...visited, name] }) === "built-in-or-library"
483
+ const fromLibrary = declarationsNamed({ declarations, name }).some(
484
+ (declaration) => declarationTarget({
485
+ syntaxApi,
486
+ declarations,
487
+ ownPackageNames,
488
+ node: declaration,
489
+ visited: [...visited, name]
490
+ }) === "built-in-or-library"
441
491
  );
442
492
  return fromLibrary ? "built-in-or-library" : "own-api";
443
493
  };
444
494
  var memberTarget = (request) => {
445
- const { syntaxApi, member, visited } = request;
495
+ const { syntaxApi, declarations, ownPackageNames, member, visited } = request;
446
496
  if (syntaxApi.isShorthandPropertyAssignment(member)) {
447
- return nameTarget({ syntaxApi, node: member, name: member.name.text, visited });
497
+ return nameTarget({
498
+ syntaxApi,
499
+ declarations,
500
+ ownPackageNames,
501
+ node: member,
502
+ name: member.name.text,
503
+ visited
504
+ });
448
505
  }
449
- return syntaxApi.isPropertyAssignment(member) ? originTarget({ syntaxApi, node: member.initializer, visited }) : "own-api";
506
+ return syntaxApi.isPropertyAssignment(member) ? originTarget({ syntaxApi, declarations, ownPackageNames, node: member.initializer, visited }) : "own-api";
450
507
  };
451
508
  var heldMembersNamed = (request) => {
452
- const { syntaxApi, holder, member } = request;
453
- return declarationsNamed({ syntaxApi, node: request.node, name: holder }).flatMap(
454
- (declaration) => {
455
- if (!syntaxApi.isVariableDeclaration(declaration) || !syntaxApi.isIdentifier(declaration.name))
456
- return [];
457
- const { initializer } = declaration;
458
- if (initializer === void 0 || !syntaxApi.isObjectLiteralExpression(initializer)) return [];
459
- return initializer.properties.filter(
460
- (property) => property.name !== void 0 && syntaxApi.isIdentifier(property.name) && property.name.text === member
461
- );
462
- }
463
- );
509
+ const { syntaxApi, declarations, holder, member } = request;
510
+ return declarationsNamed({ declarations, name: holder }).flatMap((declaration) => {
511
+ if (!syntaxApi.isVariableDeclaration(declaration) || !syntaxApi.isIdentifier(declaration.name))
512
+ return [];
513
+ const { initializer } = declaration;
514
+ if (initializer === void 0 || !syntaxApi.isObjectLiteralExpression(initializer)) return [];
515
+ return initializer.properties.filter(
516
+ (property) => property.name !== void 0 && syntaxApi.isIdentifier(property.name) && property.name.text === member
517
+ );
518
+ });
464
519
  };
465
520
  var heldValueTarget = (request) => {
466
- const { syntaxApi, node, visited } = request;
521
+ const { syntaxApi, declarations, ownPackageNames, node, visited } = request;
467
522
  if (!syntaxApi.isPropertyAccessExpression(node) || !syntaxApi.isIdentifier(node.expression))
468
523
  return void 0;
469
524
  const members = heldMembersNamed({
470
525
  syntaxApi,
526
+ declarations,
471
527
  node,
472
528
  holder: node.expression.text,
473
529
  member: node.name.text
474
530
  });
475
531
  if (members.length === 0) return void 0;
476
532
  const fromLibrary = members.some(
477
- (member) => memberTarget({ syntaxApi, node, member, visited }) === "built-in-or-library"
533
+ (member) => memberTarget({ syntaxApi, declarations, ownPackageNames, node, member, visited }) === "built-in-or-library"
478
534
  );
479
535
  return fromLibrary ? "built-in-or-library" : "own-api";
480
536
  };
481
537
  var originTarget = (request) => {
482
- const { syntaxApi, node, visited } = request;
538
+ const { syntaxApi, declarations, ownPackageNames, node, visited } = request;
483
539
  const loadedModule = loadedModuleOf({ syntaxApi, node });
484
- if (loadedModule !== void 0) return moduleTarget({ specifier: loadedModule });
540
+ if (loadedModule !== void 0) return moduleTarget({ specifier: loadedModule, ownPackageNames });
485
541
  const held = heldValueTarget(request);
486
542
  if (held !== void 0) return held;
487
543
  if (syntaxApi.isIdentifier(node))
488
- return nameTarget({ syntaxApi, node, name: node.text, visited });
544
+ return nameTarget({ syntaxApi, declarations, ownPackageNames, node, name: node.text, visited });
489
545
  if (syntaxApi.isStringLiteralLike(node) || syntaxApi.isArrayLiteralExpression(node) || syntaxApi.isTemplateExpression(node)) {
490
546
  return "built-in-or-library";
491
547
  }
492
548
  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);
493
- return isChain ? originTarget({ syntaxApi, node: node.expression, visited }) : "own-api";
549
+ return isChain ? originTarget({ syntaxApi, declarations, ownPackageNames, node: node.expression, visited }) : "own-api";
494
550
  };
495
551
  var packageBindingsOf = (request) => request.node.getSourceFile().statements.flatMap((statement) => {
496
552
  const { syntaxApi } = request;
497
553
  if (!syntaxApi.isImportDeclaration(statement) || !syntaxApi.isStringLiteral(statement.moduleSpecifier))
498
554
  return [];
499
- if (statement.moduleSpecifier.text.startsWith(".") || statement.importClause === void 0)
555
+ if (moduleTarget({
556
+ specifier: statement.moduleSpecifier.text,
557
+ ownPackageNames: request.ownPackageNames
558
+ }) === "own-api" || statement.importClause === void 0)
500
559
  return [];
501
560
  const { name, namedBindings } = statement.importClause;
502
561
  const named = namedBindings === void 0 ? [] : syntaxApi.isNamespaceImport(namedBindings) ? [namedBindings.name.text] : namedBindings.elements.map((element) => element.name.text);
@@ -514,9 +573,15 @@ var argumentsTarget = (request) => {
514
573
  return objectNoBuiltInTakes ? "own-api" : "built-in-or-library";
515
574
  };
516
575
  var callTargetOf = (request) => {
517
- const { syntaxApi, call, method } = request;
518
- if (originTarget({ syntaxApi, node: method.expression, visited: [] }) === "built-in-or-library")
519
- return "built-in-or-library";
576
+ const { syntaxApi, declarations, ownPackageNames, call, method } = request;
577
+ const target = originTarget({
578
+ syntaxApi,
579
+ declarations,
580
+ ownPackageNames,
581
+ node: method.expression,
582
+ visited: []
583
+ });
584
+ if (target === "built-in-or-library") return "built-in-or-library";
520
585
  return argumentsTarget({ syntaxApi, call, name: method.name.text });
521
586
  };
522
587
  var listedMethodForm = (request) => {
@@ -525,9 +590,15 @@ var listedMethodForm = (request) => {
525
590
  return callTargetOf(request) === "own-api" ? void 0 : form;
526
591
  };
527
592
  var callForm = (request) => {
528
- const { syntaxApi, node } = request;
593
+ const { syntaxApi, declarations, ownPackageNames, node } = request;
529
594
  if (!syntaxApi.isCallExpression(node)) return void 0;
530
- const calledForm = syntaxApi.isPropertyAccessExpression(node.expression) ? listedMethodForm({ syntaxApi, call: node, method: node.expression }) ?? namespaceForm({
595
+ const calledForm = syntaxApi.isPropertyAccessExpression(node.expression) ? listedMethodForm({
596
+ syntaxApi,
597
+ declarations,
598
+ ownPackageNames,
599
+ call: node,
600
+ method: node.expression
601
+ }) ?? namespaceForm({
531
602
  syntaxApi,
532
603
  node: node.expression.expression,
533
604
  name: node.expression.name.text
@@ -552,11 +623,21 @@ var expressionForm = (request) => {
552
623
  return callForm(request) ?? optionalChainForm(request);
553
624
  };
554
625
  var IMPLEMENTATION_TAKERS = ["mockImplementation", "mockImplementationOnce"];
626
+ var TEST_REGISTRATION = /* @__PURE__ */ new Set([
627
+ "it",
628
+ "test",
629
+ "describe",
630
+ "suite",
631
+ "beforeAll",
632
+ "beforeEach",
633
+ "afterEach",
634
+ "afterAll"
635
+ ]);
555
636
  var takesImplementation = (request) => {
556
637
  const { syntaxApi, node } = request;
557
- if (!syntaxApi.isCallExpression(node) || !syntaxApi.isPropertyAccessExpression(node.expression))
558
- return "other";
638
+ if (!syntaxApi.isCallExpression(node)) return "other";
559
639
  const callee = node.expression;
640
+ if (!syntaxApi.isPropertyAccessExpression(callee)) return "other";
560
641
  const isViFn = callee.name.text === "fn" && syntaxApi.isIdentifier(callee.expression) && callee.expression.text === "vi";
561
642
  return isViFn || IMPLEMENTATION_TAKERS.includes(callee.name.text) ? "takes" : "other";
562
643
  };
@@ -565,12 +646,22 @@ var enclosingFunctionOf = (request) => {
565
646
  if (request.syntaxApi.isFunctionLike(request.node)) return request.node;
566
647
  return enclosingFunctionOf({ syntaxApi: request.syntaxApi, node: request.node.parent });
567
648
  };
649
+ var directCallbackIsPassedOn = (request) => {
650
+ const { syntaxApi, node } = request;
651
+ if (!syntaxApi.isCallExpression(node) || !syntaxApi.isIdentifier(node.expression) || TEST_REGISTRATION.has(node.expression.text)) {
652
+ return false;
653
+ }
654
+ const enclosing = enclosingFunctionOf({ syntaxApi, node: node.parent });
655
+ if (enclosing === void 0) return true;
656
+ const registration = enclosing.parent;
657
+ return syntaxApi.isCallExpression(registration) && syntaxApi.isIdentifier(registration.expression) && TEST_REGISTRATION.has(registration.expression.text);
658
+ };
568
659
  var enclosureOf = (request) => {
569
660
  const { syntaxApi } = request;
570
661
  const enclosing = enclosingFunctionOf({ syntaxApi, node: request.node.parent });
571
662
  if (enclosing === void 0) return "elsewhere";
572
663
  const holder = syntaxApi.isPropertyAssignment(enclosing.parent) ? enclosing.parent.parent : enclosing.parent;
573
- const passedOn = syntaxApi.isObjectLiteralExpression(holder) || takesImplementation({ syntaxApi, node: holder }) === "takes";
664
+ const passedOn = syntaxApi.isObjectLiteralExpression(holder) || takesImplementation({ syntaxApi, node: holder }) === "takes" || directCallbackIsPassedOn({ syntaxApi, node: holder });
574
665
  return passedOn ? "passed-on-function" : "elsewhere";
575
666
  };
576
667
  var testBodyFormOf = (request) => {
@@ -578,60 +669,56 @@ var testBodyFormOf = (request) => {
578
669
  if (form === void 0) return void 0;
579
670
  return enclosureOf(request) === "passed-on-function" ? { introducedIn: form.introducedIn, remedy: PASSED_ON_FUNCTION } : form;
580
671
  };
581
- var snippetAt = (request) => {
582
- const snippet = request.source.slice(request.position, request.position + 80).replace(/\n/g, " ");
583
- return snippet.length === 80 ? `${snippet}\u2026` : snippet;
584
- };
585
672
  var check = {
586
- prepare: ({ clauses, syntaxApi }) => ({
587
- outcome: "ok",
588
- value: {
589
- prepareFile: ({ file }) => {
590
- if (testFileEligibility({ file }) === "skipped") {
591
- return { outcome: "ok", value: { kind: "skipped" } };
592
- }
593
- return {
594
- outcome: "ok",
595
- value: {
596
- kind: "syntax",
597
- begin: ({ sourceFile, anchorAt }) => {
598
- const hits = [];
599
- return {
600
- enter: ({ node }) => {
601
- const form = testBodyFormOf({ syntaxApi, node });
602
- if (form === void 0) return;
603
- const reaching = clauses.filter(
604
- (clause) => editionReaches({
605
- edition: clause.edition,
606
- introducedIn: form.introducedIn
607
- }) === "reached"
608
- );
609
- if (reaching.length === 0) return;
610
- const position = node.getStart(sourceFile);
611
- const anchor = anchorAt({ position });
612
- const snippet = snippetAt({ source: sourceFile.text, position });
613
- hits.push(
614
- ...reaching.map((clause) => ({
615
- clause: clause.address,
616
- anchor,
617
- snippet,
618
- remedy: form.remedy
619
- }))
620
- );
621
- },
622
- finish: () => hits
623
- };
624
- }
673
+ prepare: ({ bindings, repository, syntaxApi }) => {
674
+ const ownPackageNames = ownPackageNamesOf({ repository });
675
+ return {
676
+ outcome: "ok",
677
+ value: {
678
+ prepareFile: ({ file }) => {
679
+ if (testFileEligibility({ file, testFiles: repository.testFiles }) === "skipped") {
680
+ return { outcome: "ok", value: { kind: "skipped" } };
625
681
  }
626
- };
627
- },
628
- finish: () => ({ outcome: "ok", value: [] })
629
- }
630
- })
682
+ return {
683
+ outcome: "ok",
684
+ value: {
685
+ kind: "syntax",
686
+ begin: ({ sourceFile, anchorAt }) => {
687
+ const hits = [];
688
+ const declarations = declarationsOf({ syntaxApi, sourceFile });
689
+ return {
690
+ enter: ({ node }) => {
691
+ const form = testBodyFormOf({
692
+ syntaxApi,
693
+ declarations,
694
+ ownPackageNames,
695
+ node
696
+ });
697
+ if (form === void 0) return;
698
+ const binding = bindings.find(
699
+ ({ address, forms, edition }) => forms?.[form.remedy.section] === address && editionReaches({ edition, introducedIn: form.introducedIn }) === "reached"
700
+ );
701
+ if (binding === void 0) return;
702
+ const position = node.getStart(sourceFile);
703
+ const anchor = anchorAt({ position });
704
+ const snippet = sourceSnippetAt({ source: sourceFile.text, position });
705
+ hits.push({ check: binding.address, anchor, snippet, remedy: form.remedy });
706
+ },
707
+ finish: () => hits
708
+ };
709
+ }
710
+ }
711
+ };
712
+ },
713
+ finish: () => ({ outcome: "ok", value: [] })
714
+ }
715
+ };
716
+ }
631
717
  };
632
718
  export {
633
719
  TEST_BODY_REMEDIES,
634
720
  TEST_BODY_SECTIONS,
635
721
  check,
722
+ declarationsOf,
636
723
  testBodyFormOf
637
724
  };
@@ -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
+ }