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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/ADOPTING.md +10 -19
  2. package/CHANGELOG.md +46 -0
  3. package/MIGRATING.md +25 -14
  4. package/README.md +3 -4
  5. package/chunks/chunk-2U5EKYGS.js +14348 -0
  6. package/chunks/{chunk-FPIP7JEC.js → chunk-4AJQHZ7I.js} +1 -1
  7. package/chunks/chunk-4PHKVNM3.js +2377 -0
  8. package/chunks/{chunk-CXM5KBZX.js → chunk-6LTJRJOE.js} +1 -1
  9. package/chunks/{chunk-PVSC4SE3.js → chunk-BISP2JOL.js} +4 -6
  10. package/chunks/{chunk-BRANVR7K.js → chunk-FRE5IA3C.js} +1 -1
  11. package/chunks/{chunk-E4D5WDRX.js → chunk-GMLT3MHO.js} +252 -254
  12. package/chunks/chunk-M4VSJ27S.js +139 -0
  13. package/chunks/{chunk-YGMO5Z6U.js → chunk-P2VHWLK4.js} +182 -193
  14. package/chunks/{chunk-LD766VWU.js → chunk-U6W65ZOF.js} +31 -2
  15. package/chunks/{chunk-BKQ3K766.js → chunk-WPEOCLTP.js} +39 -33
  16. package/chunks/{chunk-A3RL4O5V.js → chunk-XNIXPQQ5.js} +35 -2
  17. package/docs/extending.md +2 -2
  18. package/methods/lenses/function-first.md +2 -2
  19. package/package.json +1 -1
  20. package/rules/README.md +5 -3
  21. package/rules/SPIRIT.md +1 -1
  22. package/rules/numbers.md +4 -4
  23. package/rules/principles/no-leak-across-a-boundary.md +1 -1
  24. package/rules/principles.md +1 -1
  25. package/rules/record-kinds/authorised-location.md +1 -1
  26. package/rules/records.md +11 -19
  27. package/rules/rules.md +5 -5
  28. package/rules/sources.md +6 -7
  29. package/rules/typescript/checks.md +55 -387
  30. package/rules/typescript/recipes/adapter-per-outside-party.md +10 -5
  31. package/rules/typescript/recipes/assert-to-narrow.md +114 -4
  32. package/rules/typescript/recipes/closure-factory.md +5 -5
  33. package/rules/typescript/recipes/companion-test-file.md +5 -3
  34. package/rules/typescript/recipes/composed-orchestrator.md +6 -4
  35. package/rules/typescript/recipes/composition-root.md +5 -3
  36. package/rules/typescript/recipes/{bounded-context-generic.md → constrained-context-generic.md} +6 -4
  37. package/rules/typescript/recipes/copy-never-write-in.md +6 -4
  38. package/rules/typescript/recipes/declared-not-bundled.md +5 -3
  39. package/rules/typescript/recipes/dependency-record.md +5 -3
  40. package/rules/typescript/recipes/domain-vocabulary-list.md +5 -3
  41. package/rules/typescript/recipes/entity-module.md +8 -5
  42. package/rules/typescript/recipes/exact-pins-and-a-lock-file.md +5 -3
  43. package/rules/typescript/recipes/extension-outside-the-vendored-code.md +5 -3
  44. package/rules/typescript/recipes/failure-asserted-as-a-value.md +44 -4
  45. package/rules/typescript/recipes/failure-mapping-at-the-adapter.md +8 -5
  46. package/rules/typescript/recipes/fix-the-declaration-not-the-value.md +5 -3
  47. package/rules/typescript/recipes/functional-iteration.md +8 -3
  48. package/rules/typescript/recipes/guard-clauses.md +5 -3
  49. package/rules/typescript/recipes/integration-test-owns-its-scratch.md +5 -3
  50. package/rules/typescript/recipes/integration-test-suffix.md +5 -3
  51. package/rules/typescript/recipes/it-each-over-typed-rows.md +117 -0
  52. package/rules/typescript/recipes/map-out-at-the-adapter.md +36 -4
  53. package/rules/typescript/recipes/meaning-in-names-not-comments.md +5 -5
  54. package/rules/typescript/recipes/named-exported-type.md +5 -3
  55. package/rules/typescript/recipes/narrow-ports.md +5 -3
  56. package/rules/typescript/recipes/one-argument-object.md +8 -3
  57. package/rules/typescript/recipes/{port-in-the-domain.md → port-in-a-module-of-its-own.md} +7 -5
  58. package/rules/typescript/recipes/ports-in-the-argument.md +5 -3
  59. package/rules/typescript/recipes/repo-scripts-only.md +5 -3
  60. package/rules/typescript/recipes/result-union.md +5 -5
  61. package/rules/typescript/recipes/screaming-folders.md +5 -5
  62. package/rules/typescript/recipes/shared-strict-base-config.md +5 -5
  63. package/rules/typescript/recipes/stub-with-vi-fn.md +130 -0
  64. package/rules/typescript/recipes/tagged-union-and-exhaustive-switch.md +5 -3
  65. package/rules/typescript/recipes/whole-words.md +5 -3
  66. package/rules/typescript/recipes/whole-written-out-expectation.md +284 -4
  67. package/rules/typescript/recipes/world-values-through-a-port.md +5 -3
  68. package/rules/typescript/recipes/zod-at-the-producers-adapter.md +8 -3
  69. package/rules/typescript/recipes.md +567 -21
  70. package/rules/typescript/symptoms/ambient-randomness.md +1 -1
  71. package/rules/typescript/symptoms/answer-set-in-a-hook.md +1 -1
  72. package/rules/typescript/symptoms/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site.md +1 -1
  73. package/rules/typescript/symptoms/{assertion-outside-a-test.md → assertion-outside-a-test-body.md} +1 -1
  74. package/rules/typescript/symptoms/branch-in-a-test/test-body.md +10 -184
  75. package/rules/typescript/symptoms/branch-in-a-test.md +11 -1
  76. package/rules/typescript/symptoms/claimed-type/non-null-assertions.md +1 -1
  77. package/rules/typescript/symptoms/{code-or-prose-read-as-text.md → code-or-prose-read-as-text-in-a-test.md} +2 -2
  78. package/rules/typescript/symptoms/computed-value-in-a-test/test-body.md +26 -117
  79. package/rules/typescript/symptoms/computed-value-in-a-test.md +1 -1
  80. package/rules/typescript/symptoms/date-used-directly.md +1 -1
  81. package/rules/typescript/symptoms/default-for-a-required-value.md +1 -1
  82. package/rules/typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md +1 -18
  83. package/rules/typescript/symptoms/double-with-a-body.md +1 -1
  84. package/rules/typescript/symptoms/{export-from-a-test-file.md → export-from-a-test.md} +1 -1
  85. package/rules/typescript/symptoms/failure-shaped-as-success.md +1 -1
  86. package/rules/typescript/symptoms/inherited-environment-in-a-subprocess/git-spawn-environment.md +1 -1
  87. package/rules/typescript/symptoms/inner-layer-imports-outer.md +1 -1
  88. package/rules/typescript/symptoms/library-class-built-in-place.md +1 -1
  89. package/rules/typescript/symptoms/loop-keyword/loop-statement.md +1 -1
  90. package/rules/typescript/symptoms/outside-import-past-a-boundary/import-or-require.md +1 -0
  91. package/rules/typescript/symptoms/outside-import-past-a-boundary.md +5 -4
  92. package/rules/typescript/symptoms/outside-type-in-a-signature.md +2 -2
  93. package/rules/typescript/symptoms/{port-outside-the-domain.md → port-beside-its-adapter.md} +2 -2
  94. package/rules/typescript/symptoms/port-named-for-a-mechanism.md +1 -1
  95. package/rules/typescript/symptoms/process-global-used-in-place.md +1 -1
  96. package/rules/typescript/symptoms/rebinding/test-body.md +1 -18
  97. package/rules/typescript/symptoms/rebinding.md +11 -1
  98. package/rules/typescript/symptoms/schema-past-its-adapter.md +2 -2
  99. package/rules/typescript/symptoms/text-past-its-reader/test-body.md +2 -17
  100. package/rules/typescript/symptoms/text-past-its-reader.md +1 -1
  101. package/rules/typescript/symptoms/throw-or-catch-in-a-test/try-block.md +1 -25
  102. package/rules/typescript/symptoms/type-declared-in-a-test/test-type-declaration.md +1 -1
  103. package/rules/typescript/symptoms/unasserted-call.md +1 -1
  104. package/rules/typescript/symptoms.md +35 -35
  105. package/src/application/conformance/conformance-testing-types.d.ts +2 -0
  106. package/src/domain/language-layer/authored-item-types.d.ts +21 -5
  107. package/src/domain/runner/runner-result-types.d.ts +1 -2
  108. package/src/eslint-plugin.js +40 -38
  109. package/src/hone.js +15 -13638
  110. package/src/infrastructure/disciplines-file/version-one-names.json +4 -5
  111. package/src/infrastructure/engines/eslint/runner/runner.js +56 -70
  112. package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/assertion-site.js +1 -1
  113. package/src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body-logic.js +39 -65
  114. package/src/infrastructure/engines/walker/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read/raw-read.js +1 -1
  115. package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/test-file-export.js +1 -1
  116. package/src/infrastructure/engines/walker/runner/runner.js +10 -10
  117. package/src/infrastructure/engines/walker/strictness-weakened/strict/compiler-overrides.js +3 -3
  118. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.examples.json +15 -3
  119. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.js +118 -4
  120. package/src/measure-engines.process.js +80 -0
  121. package/src/testing.d.ts +1 -0
  122. package/src/testing.js +111 -26
  123. package/chunks/chunk-7FVSZ2VL.js +0 -1304
  124. package/chunks/chunk-BIDD2YWP.js +0 -398
  125. package/rules/record-kinds/boundary-record.md +0 -9
  126. package/rules/typescript/recipes/iteach-over-typed-rows.md +0 -18
  127. package/rules/typescript/recipes/stub-with-vifn.md +0 -20
  128. /package/rules/typescript/symptoms/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read.md +0 -0
  129. /package/rules/typescript/symptoms/{export-from-a-test-file → export-from-a-test}/test-file-export.md +0 -0
  130. /package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/assertion-site.examples.json +0 -0
  131. /package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/piece.json +0 -0
  132. /package/src/infrastructure/engines/walker/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read/piece.json +0 -0
  133. /package/src/infrastructure/engines/walker/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read/raw-read.examples.json +0 -0
  134. /package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/piece.json +0 -0
  135. /package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/test-file-export.examples.json +0 -0
@@ -28,7 +28,7 @@
28
28
  "correctUses": [
29
29
  {
30
30
  "situation": "correct use",
31
- "kind": "boundary-record",
31
+ "kind": "authorised-location",
32
32
  "at": "on the adapter for random values or new ids"
33
33
  }
34
34
  ]
@@ -36,7 +36,7 @@
36
36
  ],
37
37
  "reports": "seen",
38
38
  "recipes": [
39
- "stub-with-vifn"
39
+ "stub-with-vi-fn"
40
40
  ],
41
41
  "correctUses": []
42
42
  }
@@ -7,4 +7,4 @@
7
7
  }
8
8
  ```
9
9
 
10
- An assertion in a hook, suite body or helper is detached from the test whose result it should determine. Put it in the case that exercises the behavior.
10
+ An assertion in a hook, suite body or helper is detached from the test whose result it should determine. Put it in the test body that exercises the behaviour.
@@ -1,4 +1,4 @@
1
- # Assertion outside a test
1
+ # Assertion outside a test body
2
2
 
3
3
  ```json
4
4
  {
@@ -7,207 +7,33 @@
7
7
  }
8
8
  ```
9
9
 
10
- `if` statements and ternary expressions in a test file; edition 2 adds short-circuits, optional chaining and `switch`. These run with the other [test-body checks](../../../README.md#checks-the-test-body-checks), which share their scope, editions and settings.
10
+ Branches in a test file. These run with the other [test-body checks](../../../README.md#checks-the-test-body-checks), which share their scope, editions and settings.
11
11
 
12
12
  ## Flags
13
- Edition 1:
14
- - `if` statements and ternary expressions.
15
-
16
- Edition 2 also flags:
17
- - `??`, `||` and `&&`, and their assignment forms `??=`, `||=` and `&&=`.
18
- - Optional chaining: `a?.b`, `a?.[key]` and `f?.()`.
19
- - `switch` statements.
20
-
21
- ## Allowed forms in a test
22
13
 
23
14
  ### Branching with if
24
- ```ts
25
- declare const parse: (text: string) => { readonly outcome: "ok"; readonly value: string } | { readonly outcome: "failed" };
26
- const parsed = parse("a");
27
- if (parsed.outcome === "ok") {
28
- expect(parsed.value).toBe("a");
29
- }
30
- ```
31
- Compare the whole result:
32
-
33
- ```ts
34
- declare const parse: (text: string) => { readonly outcome: "ok"; readonly value: string } | { readonly outcome: "failed" };
35
- expect(parse("a")).toEqual({ outcome: "ok", value: "a" });
36
- ```
37
-
38
- Or write one test per case, or one table:
39
-
40
- ```ts
41
- declare const parse: (text: string) => { readonly outcome: "ok"; readonly value: string } | { readonly outcome: "failed" };
42
- it.each([
43
- { text: "a", expected: { outcome: "ok", value: "a" } },
44
- { text: "", expected: { outcome: "failed" } },
45
- ])("parses $text", ({ text, expected }) => {
46
- expect(parse(text)).toEqual(expected);
47
- });
48
- ```
15
+ An `if` statement. Edition 1.
49
16
 
50
17
  ### A ternary
51
- ```ts
52
- declare const discountFor: (customer: { readonly tier: "premium" | "standard" }) => number;
53
- const tier = "premium";
54
- expect(discountFor({ tier })).toBe(tier === "premium" ? 10 : 0);
55
- ```
56
- Write the value out, with one table row per case:
57
-
58
- ```ts
59
- declare const discountFor: (customer: { readonly tier: "premium" | "standard" }) => number;
60
- it.each([
61
- { tier: "premium", expected: 10 },
62
- { tier: "standard", expected: 0 },
63
- ] as const)("gives $expected off to a $tier customer", ({ tier, expected }) => {
64
- expect(discountFor({ tier })).toBe(expected);
65
- });
66
- ```
18
+ A ternary expression. Edition 1.
67
19
 
68
20
  ### A short-circuit
69
- ```ts
70
- declare const lookup: (id: string) => { readonly name: string } | undefined;
71
- const found = lookup("a");
72
- expect(found !== undefined && found.name === "Ada").toBe(true);
73
- ```
74
- Write the value a fallback gives. To narrow a value that may be missing, assert it is defined, then read it:
75
-
76
- ```ts
77
- declare const lookup: (id: string) => { readonly name: string } | undefined;
78
- const found = lookup("a");
79
- assert.isDefined(found);
80
- expect(found.name).toBe("Ada");
81
- ```
21
+ `??`, `||` or `&&`, or an assignment form `??=`, `||=` or `&&=`. Edition 2 adds it.
82
22
 
83
23
  ### An optional chain after an index
84
- ```ts
85
- declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
86
- expect(listTasks()[0]?.id).toBe("a");
87
- ```
88
- Compare the whole element:
89
-
90
- ```ts
91
- declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
92
- expect(listTasks()[0]).toMatchObject({ id: "a" });
93
- ```
94
-
95
- Or destructure it and assert it is defined before reading it:
96
-
97
- ```ts
98
- declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
99
- const [first] = listTasks();
100
- assert.isDefined(first);
101
- expect(first.id).toBe("a");
102
- ```
24
+ Optional chaining straight after an index, as in `rows[0]?.id`, `mock.instances` and `mock.contexts` included. Edition 2 adds it.
103
25
 
104
26
  ### An optional chain on a mock call
105
- ```ts
106
- declare const start: (run: (task: { readonly id: string }) => void) => void;
107
- const run = vi.fn<(task: { readonly id: string }) => void>();
108
- start(run);
109
- expect(run.mock.calls[0]?.[0].id).toBe("a");
110
- ```
111
- Assert that call by its position:
112
-
113
- ```ts
114
- declare const start: (run: (task: { readonly id: string }) => void) => void;
115
- const run = vi.fn<(task: { readonly id: string }) => void>();
116
- start(run);
117
- expect(run).toHaveBeenNthCalledWith(1, expect.objectContaining({ id: "a" }));
118
- ```
119
-
120
- Reading `run.mock.lastCall?.[0]` names this section too. Assert the last call:
121
-
122
- ```ts
123
- declare const start: (run: (task: { readonly id: string }) => void) => void;
124
- const run = vi.fn<(task: { readonly id: string }) => void>();
125
- start(run);
126
- expect(run).toHaveBeenLastCalledWith({ id: "a" });
127
- ```
27
+ Optional chaining after an index into `mock.calls`, or on `mock.lastCall`. Edition 2 adds it.
128
28
 
129
29
  ### An optional chain on a mock result
130
- ```ts
131
- declare const pricing: { readonly priceOf: (amount: number) => number };
132
- declare const settle: (prices: { readonly priceOf: (amount: number) => number }) => void;
133
- const priceOf = vi.spyOn(pricing, "priceOf");
134
- settle(pricing);
135
- expect(priceOf.mock.results[0]?.value).toBe(4);
136
- ```
137
- Assert what that call returned, by its position:
138
-
139
- ```ts
140
- declare const pricing: { readonly priceOf: (amount: number) => number };
141
- declare const settle: (prices: { readonly priceOf: (amount: number) => number }) => void;
142
- const priceOf = vi.spyOn(pricing, "priceOf");
143
- settle(pricing);
144
- expect(priceOf).toHaveNthReturnedWith(1, 4);
145
- ```
146
-
147
- `toHaveLastReturnedWith` asserts what the last call returned.
148
-
149
- An optional chain on `mock.instances` or `mock.contexts` names [An optional chain after an index](#an-optional-chain-after-an-index).
30
+ Optional chaining after an index into `mock.results`. Edition 2 adds it.
150
31
 
151
32
  ### An optional chain on a property
152
- ```ts
153
- declare const findUser: (id: string) => { readonly name: string } | undefined;
154
- expect(findUser("a")?.name).toBe("Ada");
155
- ```
156
- Compare the whole value:
157
-
158
- ```ts
159
- declare const findUser: (id: string) => { readonly name: string } | undefined;
160
- expect(findUser("a")).toMatchObject({ name: "Ada" });
161
- ```
162
-
163
- Or assert it is defined before reading it:
164
-
165
- ```ts
166
- declare const findUser: (id: string) => { readonly name: string } | undefined;
167
- const user = findUser("a");
168
- assert.isDefined(user);
169
- expect(user.name).toBe("Ada");
170
- ```
33
+ Any other optional property or index, `a?.b` or `a?.[key]`. Edition 2 adds it.
171
34
 
172
35
  ### An optional call
173
- ```ts
174
- declare const observers: { readonly enter?: (node: string) => void };
175
- observers.enter?.("a");
176
- ```
177
- Destructure the function, assert it is defined, then call it:
178
-
179
- ```ts
180
- declare const observers: { readonly enter?: (node: string) => void };
181
- const { enter } = observers;
182
- assert.isDefined(enter);
183
- enter("a");
184
- ```
185
-
186
- A method that reads `this` loses it once taken off its object, so assert it is defined where it is and call it there:
187
-
188
- ```ts
189
- declare const tracker: { readonly entered: readonly string[]; enter?(node: string): void };
190
- assert.isDefined(tracker.enter);
191
- tracker.enter("a");
192
- ```
36
+ An optional call, `f?.()`. Edition 2 adds it.
193
37
 
194
38
  ### A switch
195
- ```ts
196
- declare const areaOf: (shape: { readonly kind: "square"; readonly side: number } | { readonly kind: "circle"; readonly radius: number }) => number;
197
- const shape = { kind: "square", side: 2 } as const;
198
- switch (shape.kind) {
199
- case "square":
200
- expect(areaOf(shape)).toBe(4);
201
- }
202
- ```
203
- Write one test per case, or one table:
204
-
205
- ```ts
206
- declare const areaOf: (shape: { readonly kind: "square"; readonly side: number } | { readonly kind: "circle"; readonly radius: number }) => number;
207
- it.each([
208
- { shape: { kind: "square", side: 2 } as const, expected: 4 },
209
- { shape: { kind: "circle", radius: 0 } as const, expected: 0 },
210
- ])("measures a $shape.kind", ({ shape, expected }) => {
211
- expect(areaOf(shape)).toBe(expected);
212
- });
213
- ```
39
+ A `switch` statement. Edition 2 adds it.
@@ -30,6 +30,15 @@
30
30
  "rule": "failures-are-values"
31
31
  }
32
32
  ]
33
+ },
34
+ {
35
+ "case": "uses-what-a-collaborator-gives-back",
36
+ "situation": "reads a double's recorded calls or results",
37
+ "points": [
38
+ {
39
+ "rule": "written-out-answers"
40
+ }
41
+ ]
33
42
  }
34
43
  ],
35
44
  "breachUsuallySits": "in the unit's output type, where optional or loose shapes force the test to branch",
@@ -39,7 +48,8 @@
39
48
  "reports": "seen-to-breach",
40
49
  "recipes": [
41
50
  "assert-to-narrow",
42
- "iteach-over-typed-rows"
51
+ "it-each-over-typed-rows",
52
+ "stub-with-vi-fn"
43
53
  ],
44
54
  "correctUses": [],
45
55
  "breachACheckCouldName": "the type branched on, by types.",
@@ -31,4 +31,4 @@ const name = user.name;
31
31
  ```
32
32
  Parse or narrow the value so the type follows from a check rather than from an assertion. For a value that may be absent, handle the absent case with a check or an early return; for a binding assigned later, initialise it where it is declared or make it a `const` built from what it needs.
33
33
 
34
- In a test file, [the test-body check](../branch-in-a-test/test-body.md) flags an `if` check at either edition, and its edition 2 flags the `??` fallback: there, `assert.isDefined` a value that may be missing before reading it, as [the allowed forms](../branch-in-a-test/test-body.md#a-short-circuit) show.
34
+ In a test file, [the test-body check](../branch-in-a-test/test-body.md) flags an `if` check at either edition, and its edition 2 flags the `??` fallback: read [Branch in a test](../branch-in-a-test.md) there.
@@ -1,4 +1,4 @@
1
- # Code or prose read as text
1
+ # Code or prose read as text in a test
2
2
 
3
3
  ```json
4
4
  {
@@ -14,7 +14,7 @@
14
14
  ]
15
15
  }
16
16
  ],
17
- "breachUsuallySits": "in a test that checks the words in a file instead of the code behavior",
17
+ "breachUsuallySits": "in a test that checks the words in a file instead of the code behaviour",
18
18
  "seenBy": [
19
19
  "syntax"
20
20
  ],
@@ -7,138 +7,47 @@
7
7
  }
8
8
  ```
9
9
 
10
- Computing and mutating string and array methods in a test file; edition 2 adds computing calls on `Object`, `Array` and `Math`. These run with the other [test-body checks](../../../README.md#checks-the-test-body-checks), which share their scope, editions and settings.
10
+ Values computed, mutated or picked in a test file. These run with the other [test-body checks](../../../README.md#checks-the-test-body-checks), which share their scope, editions and settings.
11
11
 
12
12
  ## Flags
13
- Edition 1:
14
- - A method call with a computing or mutating name, wherever it could be the string or array method of that name: `map`, `filter`, `reduce`, `find`, `forEach`, `join`, `slice`, `split`, `replace`, `includes`, `sort`, `trim`, `keys`, `values`, `push`, `pop`, `splice`, `fill` and similar string and array methods.
15
- - Not flagged: a call with one of those names whose arguments no string or array method of that name accepts, which makes it the unit's own API. Either it passes an object literal where none of them takes an object, such as `paths.join({ segments: ["a", "b"] })`, or it passes more arguments than any of them takes, such as `screen.keys("x", true, true)`.
16
- - Still flagged, though they look like that:
17
- - a call whose receiver traces back to a built-in namespace such as `Object` or `Math`, a package or `node:` module (imported, required or loaded with `import()`) other than a `#` import or a package some `package.json` in the repository names, or a string or array literal. The trace follows variables declared in the test file, including names destructured from a traced module or namespace, such as `posix` after `const { posix } = path`, and a property read directly off an object literal declared there, such as `deps.path` after `const deps = { path }`;
18
- - a call that spreads its arguments;
19
- - an object at a position where a string or array method takes one, such as `rows.includes({ id: "a" })`, `rows.push({ id: "a" })`, `rows.reduce(sum, { total: 0 })`, `rows.find(isA, {})` or `text.split({ [Symbol.split]: splitter })`.
20
- - What this check cannot know: it reads names and syntax, not types, so it cannot tell what a receiver is.
21
- - It flags the unit's own method given a variable, such as `repository.find(query)`.
22
- - It misses a string or array method taken off its receiver before the call.
23
- - It does not trace a receiver that is a function parameter, an `it.each` row, a value from another module (even a relative module that re-exports a package), a name destructured from an object literal, or a property nested deeper in one, such as `deps.nested.path`; it reads these as the unit's own.
24
- - It releases a method of another built-in or library type that shares a name, such as a stream's `values` or `reduce`, when that call passes an object or more arguments than the string or array method takes.
25
- Only a check that reads types knows a receiver's identity, and Hone does not have one yet.
26
-
27
- Edition 2 also flags:
28
- - Computing calls on a built-in namespace: `Object.assign`, `Object.fromEntries`, `Array.from` and any `Math` method. `JSON.stringify` and `JSON.parse` are [text-past-its-reader#test-body](../text-past-its-reader/test-body.md).
29
-
30
- ## Allowed forms in a test
31
13
 
32
14
  ### A method that picks or tests an element
33
- ```ts
34
- declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
35
- expect(listTasks().find((task) => task.id === "a")).toEqual({ id: "a", status: "open" });
36
- ```
37
- Assert on the whole array:
38
-
39
- ```ts
40
- declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
41
- expect(listTasks()).toContainEqual({ id: "a", status: "open" });
42
- ```
43
-
44
- ```ts
45
- declare const listTasks: () => readonly { readonly id: string; readonly status: "open" | "done" }[];
46
- expect(listTasks()).toEqual(expect.arrayContaining([expect.objectContaining({ id: "a" })]));
47
- ```
48
-
49
- The check cannot tell the unit's own method with one of these names from an array method when it is given a variable, such as `repository.find(query)`. That is a limit of the check, described under [What the check flags](#flags).
15
+ A call named `at`, `every`, `filter`, `find`, `findIndex`, `findLast`, `findLastIndex`, `includes`, `indexOf`, `lastIndexOf` or `some`. Edition 1.
50
16
 
51
17
  ### A method that computes a value
52
- ```ts
53
- declare const idsOf: (rows: readonly { readonly id: string }[]) => readonly string[];
54
- const rows = [{ id: "a1" }, { id: "b2" }];
55
- expect(idsOf(rows)).toEqual(rows.map((row) => row.id));
56
- ```
57
- Write the expected value out:
58
-
59
- ```ts
60
- declare const idsOf: (rows: readonly { readonly id: string }[]) => readonly string[];
61
- expect(idsOf([{ id: "a1" }, { id: "b2" }])).toEqual(["a1", "b2"]);
62
- ```
63
-
64
- Or match the part that matters:
65
-
66
- ```ts
67
- declare const receiptOf: (order: { readonly total: number }) => { readonly total: number; readonly label: string };
68
- expect(receiptOf({ total: 30 })).toMatchObject({ label: expect.stringContaining("30") });
69
- ```
18
+ A call named after a string or array method that gives back a new value or walks the list: `map`, `reduce`, `forEach`, `join`, `slice`, `split`, `replace`, `sort`, `trim`, `keys`, `values` and similar. Edition 1.
70
19
 
71
20
  ### A method that mutates
72
- ```ts
73
- declare const namesOf: (team: string) => readonly string[];
74
- const expected = ["Ada"];
75
- expected.push("Grace");
76
- expect(namesOf("core")).toEqual(expected);
77
- ```
78
- Write the finished array out:
79
-
80
- ```ts
81
- declare const namesOf: (team: string) => readonly string[];
82
- expect(namesOf("core")).toEqual(["Ada", "Grace"]);
83
- ```
21
+ A call named `copyWithin`, `fill`, `pop`, `push`, `reverse`, `shift`, `splice` or `unshift`. Edition 1.
84
22
 
85
23
  ### Merging objects
86
- ```ts
87
- const base = { method: "POST", path: "/tasks" } as const;
88
- const request = Object.assign({}, base, { body: "a" });
89
- expect(request.body).toBe("a");
90
- ```
91
- Write the object out, spreading what it copies:
92
-
93
- ```ts
94
- const base = { method: "POST", path: "/tasks" } as const;
95
- const request = { ...base, body: "a" };
96
- expect(request.body).toBe("a");
97
- ```
98
-
99
- A spread copies an `Error`'s own properties into a plain object, which is not an `Error`. To give an `Error` a property, assign it:
100
-
101
- ```ts
102
- declare const reasonOf: (error: Error & { readonly code?: string }) => string;
103
- const missing: Error & { code?: string } = new Error("ENOENT");
104
- missing.code = "ENOENT";
105
- expect(reasonOf(missing)).toBe("missing");
106
- ```
24
+ `Object.assign`. Edition 2 adds it.
107
25
 
108
26
  ### Building an object from entries
109
- ```ts
110
- declare const countsOf: (words: readonly string[]) => Readonly<Record<string, number>>;
111
- expect(countsOf(["a"])).toEqual(Object.fromEntries([["a", 1]]));
112
- ```
113
- Write the object out:
114
-
115
- ```ts
116
- declare const countsOf: (words: readonly string[]) => Readonly<Record<string, number>>;
117
- expect(countsOf(["a"])).toEqual({ a: 1 });
118
- ```
27
+ `Object.fromEntries`. Edition 2 adds it.
119
28
 
120
29
  ### Building an array from a length
121
- ```ts
122
- declare const pageOf: (rows: readonly { readonly id: number }[]) => readonly { readonly id: number }[];
123
- expect(pageOf(Array.from({ length: 3 }, (_, index) => ({ id: index })))).toHaveLength(3);
124
- ```
125
- Write a short array out:
30
+ `Array.from`. Edition 2 adds it.
126
31
 
127
- ```ts
128
- declare const pageOf: (rows: readonly { readonly id: number }[]) => readonly { readonly id: number }[];
129
- expect(pageOf([{ id: 0 }, { id: 1 }, { id: 2 }])).toHaveLength(3);
130
- ```
32
+ ### A Math call
33
+ Any `Math` method. Edition 2 adds it.
131
34
 
132
- An array too long to read written out, such as one row past a page size of 1,000, has no form on this page.
35
+ ## Margin
133
36
 
134
- ### A Math call
135
- ```ts
136
- declare const roundedOf: (amount: number) => number;
137
- expect(roundedOf(2.5)).toBe(Math.round(2.5));
138
- ```
139
- Write the number out:
37
+ A method call is flagged wherever it could be the string or array method of that name.
140
38
 
141
- ```ts
142
- declare const roundedOf: (amount: number) => number;
143
- expect(roundedOf(2.5)).toBe(3);
144
- ```
39
+ - Not flagged: a call with one of those names whose arguments no string or array method of that name accepts, which makes it the unit's own API. Either it passes an object literal where none of them takes an object, such as `paths.join({ segments: ["a", "b"] })`, or it passes more arguments than any of them takes, such as `screen.keys("x", true, true)`.
40
+ - Still flagged, though they look like that:
41
+ - a call whose receiver traces back to a built-in namespace such as `Object` or `Math`, a package or `node:` module (imported, required or loaded with `import()`) other than a `#` import or a package some `package.json` in the repository names, or a string or array literal. The trace follows variables declared in the test file, including names destructured from a traced module or namespace, such as `posix` after `const { posix } = path`, and a property read directly off an object literal declared there, such as `deps.path` after `const deps = { path }`;
42
+ - a call that spreads its arguments;
43
+ - an object at a position where a string or array method takes one, such as `rows.includes({ id: "a" })`, `rows.push({ id: "a" })`, `rows.reduce(sum, { total: 0 })`, `rows.find(isA, {})` or `text.split({ [Symbol.split]: splitter })`.
44
+ - What this check cannot know: it reads names and syntax, not types, so it cannot tell what a receiver is.
45
+ - It flags the unit's own method given a variable, such as `repository.find(query)`.
46
+ - It misses a string or array method taken off its receiver before the call.
47
+ - It does not trace a receiver that is a function parameter, an `it.each` row, a value from another module (even a relative module that re-exports a package), a name destructured from an object literal, or a property nested deeper in one, such as `deps.nested.path`; it reads these as the unit's own.
48
+ - It releases a method of another built-in or library type that shares a name, such as a stream's `values` or `reduce`, when that call passes an object or more arguments than the string or array method takes.
49
+ Only a check that reads types knows a receiver's identity, and Hone does not have one yet.
50
+
51
+ An array too long to read written out, such as one row past a page size of 1,000, is flagged too. A record at the site answers it.
52
+
53
+ `JSON.stringify` and `JSON.parse` are [text-past-its-reader#test-body](../text-past-its-reader/test-body.md).
@@ -29,7 +29,7 @@
29
29
  "reports": "seen",
30
30
  "recipes": [
31
31
  "whole-written-out-expectation",
32
- "iteach-over-typed-rows"
32
+ "it-each-over-typed-rows"
33
33
  ],
34
34
  "correctUses": []
35
35
  }
@@ -37,7 +37,7 @@
37
37
  "correctUses": [
38
38
  {
39
39
  "situation": "correct use",
40
- "kind": "boundary-record",
40
+ "kind": "authorised-location",
41
41
  "at": "on the clock adapter"
42
42
  }
43
43
  ],
@@ -38,7 +38,7 @@
38
38
  "reports": "seen",
39
39
  "recipes": [
40
40
  "zod-at-the-producers-adapter",
41
- "bounded-context-generic"
41
+ "constrained-context-generic"
42
42
  ],
43
43
  "correctUses": []
44
44
  }
@@ -10,23 +10,6 @@
10
10
  A construct any other test-body check flags, inside a function a test passes on. These run with the other [test-body checks](../../../README.md#checks-the-test-body-checks), which share their scope, editions and settings.
11
11
 
12
12
  ## Flags
13
- - A function a test writes as a property or method of an object literal, or gives to `vi.fn` or `mockImplementation`, holding a construct another test-body check flags at the edition that runs.
14
-
15
- ## Allowed forms in a test
16
13
 
17
14
  ### Logic inside a function the test passes on
18
- ```ts
19
- declare const isInstalled: (fileKind: { readonly kindOf: (path: string) => "file" | "missing" }) => "installed" | "missing";
20
- const installedFiles = ["bin/hone.js"];
21
- expect(isInstalled({ kindOf: (path) => (installedFiles.includes(path) ? "file" : "missing") })).toBe("installed");
22
- ```
23
- A function a test writes as a property or method of an object literal, or gives to `vi.fn` or `mockImplementation`, is passed on: to the unit, to a table row, or to a double. Any flagged construct inside it names this section. Make it a `vi.fn` spy with a written-out return, and write out what it was asked:
24
-
25
- ```ts
26
- declare const isInstalled: (fileKind: { readonly kindOf: (path: string) => "file" | "missing" }) => "installed" | "missing";
27
- const kindOf = vi.fn<(path: string) => "file" | "missing">().mockReturnValue("file");
28
- expect(isInstalled({ kindOf })).toBe("installed");
29
- expect(kindOf).toHaveBeenCalledExactlyOnceWith("bin/hone.js");
30
- ```
31
-
32
- The recipe is [Stub with vi.fn](../../recipes/stub-with-vifn.md).
15
+ A function a test writes as a property or method of an object literal, gives to `vi.fn`, `mockImplementation` or `mockImplementationOnce`, or passes straight to a function it calls in its own body, holding a construct another test-body check flags. The edition is that construct's.
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "reports": "seen-to-breach",
40
40
  "recipes": [
41
- "stub-with-vifn"
41
+ "stub-with-vi-fn"
42
42
  ],
43
43
  "correctUses": [
44
44
  {
@@ -1,4 +1,4 @@
1
- # Export from a test file
1
+ # Export from a test
2
2
 
3
3
  ```json
4
4
  {
@@ -23,6 +23,6 @@
23
23
  "result-union"
24
24
  ],
25
25
  "correctUses": [],
26
- "howItIsSeen": "syntax for a `catch` that returns."
26
+ "howItIsSeen": "syntax for an empty `catch` block or promise rejection handler."
27
27
  }
28
28
  ```
@@ -7,7 +7,7 @@
7
7
  }
8
8
  ```
9
9
 
10
- A git spawn in a test without a hermetic `env`.
10
+ A git spawn in a test whose `env` is inherited.
11
11
 
12
12
  ## Flags
13
13
 
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "reports": "seen",
28
28
  "recipes": [
29
- "port-in-the-domain"
29
+ "port-in-a-module-of-its-own"
30
30
  ],
31
31
  "correctUses": []
32
32
  }
@@ -34,7 +34,7 @@
34
34
  "correctUses": [
35
35
  {
36
36
  "situation": "correct use",
37
- "kind": "boundary-record",
37
+ "kind": "authorised-location",
38
38
  "at": "on that dependency's adapter"
39
39
  }
40
40
  ]
@@ -31,4 +31,4 @@ const totals = orders.map((order) => order.total);
31
31
  ```
32
32
  Replace a counted loop with `Array.from({ length }, (_, position) => ...)`.
33
33
 
34
- In a test file, the [computed-value-in-a-test check](../computed-value-in-a-test/test-body.md) flags `map` at either edition, and its edition 2 flags `Array.from`: write the values out instead, as [the allowed forms in a test](../computed-value-in-a-test/test-body.md#allowed-forms-in-a-test) show.
34
+ In a test file, the [computed-value-in-a-test check](../computed-value-in-a-test/test-body.md) flags `map` at either edition, and its edition 2 flags `Array.from`: read [Computed value in a test](../computed-value-in-a-test.md) there.
@@ -2,6 +2,7 @@
2
2
 
3
3
  ```json
4
4
  {
5
+ "findingSpecifics": ["outside-party"],
5
6
  "misses": "`import()`, `require`, globals.",
6
7
  "settingsTracedTo": "`confinedPackages`, empty by default on purpose: the universe of outside dependencies cannot be listed, and flagging every import would catch internal packages. Telling outside from internal needs the workspace layout, which Hone can read."
7
8
  }
@@ -3,7 +3,7 @@
3
3
  ```json
4
4
  {
5
5
  "group": "The outside world reached directly",
6
- "seen": "An import, `import()` or `require` of an outside dependency or runtime module (`node:*`) in a file with no boundary record.",
6
+ "seen": "An import, `import()` or `require` of an outside dependency or runtime module (`node:*`) in a file with no authorised location for that outside party.",
7
7
  "mayIndicate": [
8
8
  {
9
9
  "case": "uses-a-system-or-service-outside-the-program",
@@ -32,13 +32,14 @@
32
32
  "reports": "seen",
33
33
  "recipes": [
34
34
  "adapter-per-outside-party",
35
- "port-in-the-domain"
35
+ "port-in-a-module-of-its-own"
36
36
  ],
37
37
  "correctUses": [
38
38
  {
39
39
  "situation": "correct use",
40
- "kind": "boundary-record",
41
- "at": "on the adapter for that outside party"
40
+ "kind": "authorised-location",
41
+ "at": "on the adapter for that outside party",
42
+ "binds": ["outside-party"]
42
43
  }
43
44
  ]
44
45
  }
@@ -28,8 +28,8 @@
28
28
  "correctUses": [
29
29
  {
30
30
  "situation": "correct use",
31
- "kind": "boundary-record",
32
- "at": "on the adapter, or beyond it with a Conformist statement for an outside model adopted as ours"
31
+ "kind": "authorised-location",
32
+ "at": "on the adapter, or beyond it with a why-chain naming the outside model adopted as ours"
33
33
  }
34
34
  ],
35
35
  "breachACheckCouldName": "the adapter that returns it, by types."
@@ -1,4 +1,4 @@
1
- # Port outside the domain
1
+ # Port beside its adapter
2
2
 
3
3
  ```json
4
4
  {
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "reports": "seen",
23
23
  "recipes": [
24
- "port-in-the-domain"
24
+ "port-in-a-module-of-its-own"
25
25
  ],
26
26
  "correctUses": []
27
27
  }