@hailstails/hone 2.0.0-pre.4 → 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.
- package/ADOPTING.md +4 -15
- package/CHANGELOG.md +34 -0
- package/MIGRATING.md +6 -6
- package/README.md +3 -4
- package/chunks/{chunk-FPIP7JEC.js → chunk-4AJQHZ7I.js} +1 -1
- package/chunks/{chunk-CXM5KBZX.js → chunk-6LTJRJOE.js} +1 -1
- package/chunks/{chunk-PVSC4SE3.js → chunk-BISP2JOL.js} +4 -6
- package/chunks/{chunk-YGMO5Z6U.js → chunk-EFUWHLZK.js} +187 -193
- package/chunks/{chunk-BRANVR7K.js → chunk-FRE5IA3C.js} +1 -1
- package/chunks/{chunk-E4D5WDRX.js → chunk-GMLT3MHO.js} +252 -254
- package/chunks/chunk-M4VSJ27S.js +139 -0
- package/chunks/chunk-ND3EOGDK.js +2350 -0
- package/chunks/chunk-ONDBACCR.js +14332 -0
- package/chunks/{chunk-LD766VWU.js → chunk-U6W65ZOF.js} +31 -2
- package/chunks/{chunk-BKQ3K766.js → chunk-WPEOCLTP.js} +39 -33
- package/chunks/{chunk-A3RL4O5V.js → chunk-XNIXPQQ5.js} +35 -2
- package/docs/extending.md +2 -2
- package/methods/lenses/function-first.md +2 -2
- package/package.json +1 -1
- package/rules/README.md +5 -3
- package/rules/SPIRIT.md +1 -1
- package/rules/numbers.md +4 -4
- package/rules/principles/no-leak-across-a-boundary.md +1 -1
- package/rules/principles.md +1 -1
- package/rules/record-kinds/authorised-location.md +1 -1
- package/rules/records.md +11 -19
- package/rules/rules.md +5 -5
- package/rules/sources.md +6 -7
- package/rules/typescript/checks.md +55 -387
- package/rules/typescript/recipes/adapter-per-outside-party.md +10 -5
- package/rules/typescript/recipes/assert-to-narrow.md +114 -4
- package/rules/typescript/recipes/closure-factory.md +5 -5
- package/rules/typescript/recipes/companion-test-file.md +5 -3
- package/rules/typescript/recipes/composed-orchestrator.md +6 -4
- package/rules/typescript/recipes/composition-root.md +5 -3
- package/rules/typescript/recipes/{bounded-context-generic.md → constrained-context-generic.md} +6 -4
- package/rules/typescript/recipes/copy-never-write-in.md +6 -4
- package/rules/typescript/recipes/declared-not-bundled.md +5 -3
- package/rules/typescript/recipes/dependency-record.md +5 -3
- package/rules/typescript/recipes/domain-vocabulary-list.md +5 -3
- package/rules/typescript/recipes/entity-module.md +8 -5
- package/rules/typescript/recipes/exact-pins-and-a-lock-file.md +5 -3
- package/rules/typescript/recipes/extension-outside-the-vendored-code.md +5 -3
- package/rules/typescript/recipes/failure-asserted-as-a-value.md +44 -4
- package/rules/typescript/recipes/failure-mapping-at-the-adapter.md +8 -5
- package/rules/typescript/recipes/fix-the-declaration-not-the-value.md +5 -3
- package/rules/typescript/recipes/functional-iteration.md +8 -3
- package/rules/typescript/recipes/guard-clauses.md +5 -3
- package/rules/typescript/recipes/integration-test-owns-its-scratch.md +5 -3
- package/rules/typescript/recipes/integration-test-suffix.md +5 -3
- package/rules/typescript/recipes/it-each-over-typed-rows.md +117 -0
- package/rules/typescript/recipes/map-out-at-the-adapter.md +36 -4
- package/rules/typescript/recipes/meaning-in-names-not-comments.md +5 -5
- package/rules/typescript/recipes/named-exported-type.md +5 -3
- package/rules/typescript/recipes/narrow-ports.md +5 -3
- package/rules/typescript/recipes/one-argument-object.md +8 -3
- package/rules/typescript/recipes/{port-in-the-domain.md → port-in-a-module-of-its-own.md} +7 -5
- package/rules/typescript/recipes/ports-in-the-argument.md +5 -3
- package/rules/typescript/recipes/repo-scripts-only.md +5 -3
- package/rules/typescript/recipes/result-union.md +5 -5
- package/rules/typescript/recipes/screaming-folders.md +5 -5
- package/rules/typescript/recipes/shared-strict-base-config.md +5 -5
- package/rules/typescript/recipes/stub-with-vi-fn.md +130 -0
- package/rules/typescript/recipes/tagged-union-and-exhaustive-switch.md +5 -3
- package/rules/typescript/recipes/whole-words.md +5 -3
- package/rules/typescript/recipes/whole-written-out-expectation.md +284 -4
- package/rules/typescript/recipes/world-values-through-a-port.md +5 -3
- package/rules/typescript/recipes/zod-at-the-producers-adapter.md +8 -3
- package/rules/typescript/recipes.md +567 -21
- package/rules/typescript/symptoms/ambient-randomness.md +1 -1
- package/rules/typescript/symptoms/answer-set-in-a-hook.md +1 -1
- package/rules/typescript/symptoms/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site.md +1 -1
- package/rules/typescript/symptoms/{assertion-outside-a-test.md → assertion-outside-a-test-body.md} +1 -1
- package/rules/typescript/symptoms/branch-in-a-test/test-body.md +10 -184
- package/rules/typescript/symptoms/branch-in-a-test.md +11 -1
- package/rules/typescript/symptoms/claimed-type/non-null-assertions.md +1 -1
- package/rules/typescript/symptoms/{code-or-prose-read-as-text.md → code-or-prose-read-as-text-in-a-test.md} +2 -2
- package/rules/typescript/symptoms/computed-value-in-a-test/test-body.md +26 -117
- package/rules/typescript/symptoms/computed-value-in-a-test.md +1 -1
- package/rules/typescript/symptoms/date-used-directly.md +1 -1
- package/rules/typescript/symptoms/default-for-a-required-value.md +1 -1
- package/rules/typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md +1 -18
- package/rules/typescript/symptoms/double-with-a-body.md +1 -1
- package/rules/typescript/symptoms/{export-from-a-test-file.md → export-from-a-test.md} +1 -1
- package/rules/typescript/symptoms/failure-shaped-as-success.md +1 -1
- package/rules/typescript/symptoms/inherited-environment-in-a-subprocess/git-spawn-environment.md +1 -1
- package/rules/typescript/symptoms/inner-layer-imports-outer.md +1 -1
- package/rules/typescript/symptoms/library-class-built-in-place.md +1 -1
- package/rules/typescript/symptoms/loop-keyword/loop-statement.md +1 -1
- package/rules/typescript/symptoms/outside-import-past-a-boundary/import-or-require.md +1 -0
- package/rules/typescript/symptoms/outside-import-past-a-boundary.md +5 -4
- package/rules/typescript/symptoms/outside-type-in-a-signature.md +2 -2
- package/rules/typescript/symptoms/{port-outside-the-domain.md → port-beside-its-adapter.md} +2 -2
- package/rules/typescript/symptoms/port-named-for-a-mechanism.md +1 -1
- package/rules/typescript/symptoms/process-global-used-in-place.md +1 -1
- package/rules/typescript/symptoms/rebinding/test-body.md +1 -18
- package/rules/typescript/symptoms/rebinding.md +11 -1
- package/rules/typescript/symptoms/schema-past-its-adapter.md +2 -2
- package/rules/typescript/symptoms/text-past-its-reader/test-body.md +2 -17
- package/rules/typescript/symptoms/text-past-its-reader.md +1 -1
- package/rules/typescript/symptoms/throw-or-catch-in-a-test/try-block.md +1 -25
- package/rules/typescript/symptoms/type-declared-in-a-test/test-type-declaration.md +1 -1
- package/rules/typescript/symptoms/unasserted-call.md +1 -1
- package/rules/typescript/symptoms.md +35 -35
- package/src/domain/language-layer/authored-item-types.d.ts +21 -5
- package/src/domain/runner/runner-result-types.d.ts +1 -2
- package/src/eslint-plugin.js +40 -38
- package/src/hone.js +15 -13638
- package/src/infrastructure/disciplines-file/version-one-names.json +4 -5
- package/src/infrastructure/engines/eslint/runner/runner.js +55 -45
- package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/assertion-site.js +1 -1
- package/src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body-logic.js +39 -65
- 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
- package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/test-file-export.js +1 -1
- package/src/infrastructure/engines/walker/runner/runner.js +10 -10
- package/src/infrastructure/engines/walker/strictness-weakened/strict/compiler-overrides.js +3 -3
- package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.examples.json +15 -3
- package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.js +118 -4
- package/src/measure-engines.process.js +80 -0
- package/src/testing.js +81 -9
- package/chunks/chunk-7FVSZ2VL.js +0 -1304
- package/chunks/chunk-BIDD2YWP.js +0 -398
- package/rules/record-kinds/boundary-record.md +0 -9
- package/rules/typescript/recipes/iteach-over-typed-rows.md +0 -18
- package/rules/typescript/recipes/stub-with-vifn.md +0 -20
- /package/rules/typescript/symptoms/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read.md +0 -0
- /package/rules/typescript/symptoms/{export-from-a-test-file → export-from-a-test}/test-file-export.md +0 -0
- /package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/assertion-site.examples.json +0 -0
- /package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/piece.json +0 -0
- /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
- /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
- /package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/piece.json +0 -0
- /package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/test-file-export.examples.json +0 -0
|
@@ -10,23 +10,6 @@
|
|
|
10
10
|
`let` declarations 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
|
-
- `let` declarations.
|
|
15
|
-
|
|
16
|
-
## Allowed forms in a test
|
|
17
13
|
|
|
18
14
|
### A let
|
|
19
|
-
|
|
20
|
-
declare const record: (store: { readonly save: (text: string) => void }) => void;
|
|
21
|
-
let saved = "";
|
|
22
|
-
record({ save: (text) => { saved = text; } });
|
|
23
|
-
expect(saved).toBe("a");
|
|
24
|
-
```
|
|
25
|
-
Record the calls with `vi.fn` and assert them:
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
declare const record: (store: { readonly save: (text: string) => void }) => void;
|
|
29
|
-
const save = vi.fn<(text: string) => void>();
|
|
30
|
-
record({ save });
|
|
31
|
-
expect(save).toHaveBeenCalledWith("a");
|
|
32
|
-
```
|
|
15
|
+
A `let` declaration. Edition 1.
|
|
@@ -20,6 +20,15 @@
|
|
|
20
20
|
"rule": "doer-or-orchestrator"
|
|
21
21
|
}
|
|
22
22
|
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"case": "uses-what-a-collaborator-gives-back",
|
|
26
|
+
"situation": "in a test",
|
|
27
|
+
"points": [
|
|
28
|
+
{
|
|
29
|
+
"rule": "written-out-answers"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
23
32
|
}
|
|
24
33
|
],
|
|
25
34
|
"breachUsuallySits": "in the unit: no caller sees it, so on its own it shows no hidden effect, but it is suspect for work done inline in steps",
|
|
@@ -29,7 +38,8 @@
|
|
|
29
38
|
"reports": "seen",
|
|
30
39
|
"recipes": [
|
|
31
40
|
"copy-never-write-in",
|
|
32
|
-
"functional-iteration"
|
|
41
|
+
"functional-iteration",
|
|
42
|
+
"stub-with-vi-fn"
|
|
33
43
|
],
|
|
34
44
|
"correctUses": []
|
|
35
45
|
}
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"correctUses": [
|
|
34
34
|
{
|
|
35
35
|
"situation": "an outside model adopted as ours",
|
|
36
|
-
"kind": "
|
|
37
|
-
"at": "with a
|
|
36
|
+
"kind": "authorised-location",
|
|
37
|
+
"at": "with a why-chain naming the outside model adopted as ours"
|
|
38
38
|
}
|
|
39
39
|
]
|
|
40
40
|
}
|
|
@@ -7,24 +7,9 @@
|
|
|
7
7
|
}
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
JSON text made or read 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 2:
|
|
14
|
-
- `JSON.stringify` and `JSON.parse`. A finding names [Serialising or parsing JSON](#serialising-or-parsing-json).
|
|
15
|
-
|
|
16
|
-
## Allowed forms in a test
|
|
17
13
|
|
|
18
14
|
### Serialising or parsing JSON
|
|
19
|
-
|
|
20
|
-
declare const render: (row: { readonly id: string }) => string;
|
|
21
|
-
expect(JSON.parse(render({ id: "a" }))).toEqual({ id: "a" });
|
|
22
|
-
```
|
|
23
|
-
A finding on `JSON.stringify` or `JSON.parse` names this section. Assert the object the unit gives back, written out:
|
|
24
|
-
|
|
25
|
-
```ts
|
|
26
|
-
declare const rowOf: (row: { readonly id: string }) => { readonly id: string };
|
|
27
|
-
expect(rowOf({ id: "a" })).toEqual({ id: "a" });
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
A unit that gives back only text should hand over an object, leaving the text to the adapter at its edge.
|
|
15
|
+
`JSON.stringify` or `JSON.parse`. Edition 2 adds it.
|
|
@@ -10,30 +10,6 @@
|
|
|
10
10
|
`try` statements 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
|
-
- `try` statements.
|
|
15
|
-
|
|
16
|
-
## Allowed forms in a test
|
|
17
13
|
|
|
18
14
|
### A try block
|
|
19
|
-
|
|
20
|
-
declare const load: (path: string) => string;
|
|
21
|
-
try {
|
|
22
|
-
load("missing.json");
|
|
23
|
-
} catch (error) {
|
|
24
|
-
expect(error).toBeInstanceOf(Error);
|
|
25
|
-
}
|
|
26
|
-
```
|
|
27
|
-
Assert the throw:
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
declare const load: (path: string) => string;
|
|
31
|
-
expect(() => load("missing.json")).toThrow(Error);
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
declare const loadLater: (path: string) => Promise<string>;
|
|
36
|
-
it("refuses a missing file", async () => {
|
|
37
|
-
await expect(loadLater("missing.json")).rejects.toThrow(Error);
|
|
38
|
-
});
|
|
39
|
-
```
|
|
15
|
+
A `try` statement. Edition 1.
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
}
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
A test declares a type, interface or enum of its own. Import the contract owned by the unit or its boundary so the test and the unit rely on the same type. Module and global augmentations are allowed.
|
|
10
|
+
A test declares a type, interface or enum of its own. Import the contract owned by the unit or its boundary so the test and the unit rely on the same type. Module and global augmentations are allowed. So is a top-level `type`, not exported, used only as the `it.each` or `describe.each` row type: one flat object or tuple, readonly or not, whose members are primitives, types imported by name, or readonly lists of imported types.
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
- **Seen by:** types.
|
|
50
50
|
- **Reports:** seen.
|
|
51
51
|
- **Check today:** review.
|
|
52
|
-
- **Recipes:** [
|
|
52
|
+
- **Recipes:** [Constrained context generic](recipes.md#constrained-context-generic); [Zod at the producer's adapter](recipes.md#zod-at-the-producers-adapter).
|
|
53
53
|
|
|
54
54
|
### Default on a closed union
|
|
55
55
|
|
|
@@ -128,18 +128,9 @@
|
|
|
128
128
|
- **Seen by:** app.
|
|
129
129
|
- **Reports:** seen.
|
|
130
130
|
- **Check today:** review.
|
|
131
|
-
- **Recipes:** [Port in
|
|
131
|
+
- **Recipes:** [Port in a module of its own](recipes.md#port-in-a-module-of-its-own).
|
|
132
132
|
|
|
133
|
-
### Port
|
|
134
|
-
|
|
135
|
-
- **Seen:** A port named for a technology (`HttpClient`, `Fs`, `Sqlite`) rather than a capability.
|
|
136
|
-
- **May indicate:** Uses a system or service outside the program → Ports declared inside; Names something → One word everywhere.
|
|
137
|
-
- **Breach usually sits:** in the port.
|
|
138
|
-
- **Seen by:** person.
|
|
139
|
-
- **Check today:** only review.
|
|
140
|
-
- **Recipes:** [Port in the domain](recipes.md#port-in-the-domain).
|
|
141
|
-
|
|
142
|
-
### Port outside the domain
|
|
133
|
+
### Port beside its adapter
|
|
143
134
|
|
|
144
135
|
- **Seen:** A port interface declared in an adapter's module, or beside its default adapter.
|
|
145
136
|
- **May indicate:** Uses a system or service outside the program → Ports declared inside ("the port is domain and to be kept separate to the concrete implementation or use").
|
|
@@ -147,7 +138,16 @@
|
|
|
147
138
|
- **Seen by:** graph.
|
|
148
139
|
- **Reports:** seen.
|
|
149
140
|
- **Check today:** review.
|
|
150
|
-
- **Recipes:** [Port in
|
|
141
|
+
- **Recipes:** [Port in a module of its own](recipes.md#port-in-a-module-of-its-own).
|
|
142
|
+
|
|
143
|
+
### Port named for a mechanism
|
|
144
|
+
|
|
145
|
+
- **Seen:** A port named for a technology (`HttpClient`, `Fs`, `Sqlite`) rather than a capability.
|
|
146
|
+
- **May indicate:** Uses a system or service outside the program → Ports declared inside; Names something → One word everywhere.
|
|
147
|
+
- **Breach usually sits:** in the port.
|
|
148
|
+
- **Seen by:** person.
|
|
149
|
+
- **Check today:** only review.
|
|
150
|
+
- **Recipes:** [Port in a module of its own](recipes.md#port-in-a-module-of-its-own).
|
|
151
151
|
|
|
152
152
|
## The outside world reached directly
|
|
153
153
|
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
- **Seen:** `Math.random()`, `crypto.randomUUID()` or `crypto.getRandomValues()` outside their adapter.
|
|
157
157
|
- **May indicate:** Needs the current time, a random value, a new id or an outside ordering → Ports declared inside, Written-out answers.
|
|
158
158
|
- **Breach usually sits:** in the unit that should be passed the value, often a doer doing two jobs.
|
|
159
|
-
- **Covered by a record:** correct use:
|
|
159
|
+
- **Covered by a record:** correct use: an authorised location on the adapter for random values or new ids.
|
|
160
160
|
- **Seen by:** syntax.
|
|
161
161
|
- **Reports:** seen.
|
|
162
162
|
- **Check today:** partial.
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
- **Seen:** Any use of `Date` (`Date.now()`, `new Date()`, `new Date(value)`, `Date.parse`) or `performance.now()` outside the places that handle dates.
|
|
169
169
|
- **May indicate:** Needs the current time, a random value, a new id or an outside ordering → Ports declared inside, Written-out answers; Does one job → Doer or orchestrator ("Dating and numbering an order is not the same job as charging it").
|
|
170
170
|
- **Breach usually sits:** in the unit that should be passed the time, often a doer doing two jobs.
|
|
171
|
-
- **Covered by a record:** correct use:
|
|
171
|
+
- **Covered by a record:** correct use: an authorised location on the clock adapter.
|
|
172
172
|
- **Seen by:** syntax.
|
|
173
173
|
- **Reports:** seen.
|
|
174
174
|
- **To name the breach, a check needs:** person.
|
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
- **Seen:** `new` on a class from an outside dependency, outside that dependency's adapter.
|
|
182
182
|
- **May indicate:** Takes an outside dependency → Outside dependencies stay at boundaries; Keeps state or settings across calls → No hidden effects.
|
|
183
183
|
- **Breach usually sits:** at a missing adapter.
|
|
184
|
-
- **Covered by a record:** correct use:
|
|
184
|
+
- **Covered by a record:** correct use: an authorised location on that dependency's adapter.
|
|
185
185
|
- **Seen by:** types.
|
|
186
186
|
- **Reports:** seen.
|
|
187
187
|
- **Check today:** review.
|
|
@@ -189,22 +189,22 @@
|
|
|
189
189
|
|
|
190
190
|
### Outside import past a boundary
|
|
191
191
|
|
|
192
|
-
- **Seen:** An import, `import()` or `require` of an outside dependency or runtime module (`node:*`) in a file with no
|
|
192
|
+
- **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.
|
|
193
193
|
- **May indicate:** Uses a system or service outside the program → Outside dependencies stay at boundaries, Ports declared inside; Takes an outside dependency → Outside dependencies stay at boundaries.
|
|
194
194
|
- **Breach usually sits:** at a missing adapter and port.
|
|
195
|
-
- **Covered by a record:** correct use:
|
|
195
|
+
- **Covered by a record:** correct use: an authorised location on the adapter for that outside party.
|
|
196
196
|
- **Seen by:** graph.
|
|
197
197
|
- **Reports:** seen.
|
|
198
198
|
- **Check today:** partial.
|
|
199
199
|
- **Checks:** [import-or-require](symptoms/outside-import-past-a-boundary/import-or-require.md).
|
|
200
|
-
- **Recipes:** [Adapter per outside party](recipes.md#adapter-per-outside-party); [Port in
|
|
200
|
+
- **Recipes:** [Adapter per outside party](recipes.md#adapter-per-outside-party); [Port in a module of its own](recipes.md#port-in-a-module-of-its-own).
|
|
201
201
|
|
|
202
202
|
### Outside type in a signature
|
|
203
203
|
|
|
204
204
|
- **Seen:** A type from an outside dependency or runtime library in a business-logic parameter, field or return, imported or inferred.
|
|
205
205
|
- **May indicate:** Uses a system or service outside the program → Outside dependencies stay at boundaries, No leak across a boundary.
|
|
206
206
|
- **Breach usually sits:** in the adapter that hands the outside type inward.
|
|
207
|
-
- **Covered by a record:** correct use:
|
|
207
|
+
- **Covered by a record:** correct use: an authorised location on the adapter, or beyond it with a why-chain naming the outside model adopted as ours.
|
|
208
208
|
- **Seen by:** types.
|
|
209
209
|
- **Reports:** seen → breach.
|
|
210
210
|
- **The breach a check could name:** the adapter that returns it, by types.
|
|
@@ -216,7 +216,7 @@
|
|
|
216
216
|
- **Seen:** `process.env`, `process.argv`, `process.exit`, `process.on`, `console.*`, `globalThis`, `alert`, `confirm`, `prompt` or a `debugger` statement outside an adapter.
|
|
217
217
|
- **May indicate:** Reads data from outside (request, file, environment, stored row, response) → No leak across a boundary; Causes an effect (writes, logs, sends, exits) → Ports declared inside; Builds the real implementations → Ports declared inside.
|
|
218
218
|
- **Breach usually sits:** at a missing port, or at an adapter not built at the entry point.
|
|
219
|
-
- **Covered by a record:** correct use:
|
|
219
|
+
- **Covered by a record:** correct use: an authorised location on the adapter that wraps the process.
|
|
220
220
|
- **Seen by:** syntax.
|
|
221
221
|
- **Reports:** seen.
|
|
222
222
|
- **Check today:** partial.
|
|
@@ -240,7 +240,7 @@
|
|
|
240
240
|
|
|
241
241
|
"Nothing wrong with a reset in after each. But something wrong with a remock in after each. Implies the suite knows the input needed for each test." Sharing alone is not the breach: "I have no issue with shared boilerplate or even mock builders when it doesn't hide minimal interfaces issues and doesn't hide assumptions or coupling between tests. But it often does when not done with care."
|
|
242
242
|
|
|
243
|
-
### Assertion outside a test
|
|
243
|
+
### Assertion outside a test body
|
|
244
244
|
|
|
245
245
|
- **Seen:** An assertion outside a function passed to an it or test call.
|
|
246
246
|
- **May indicate:** States what the unit gives back, for one case or several → Straight-through tests.
|
|
@@ -248,7 +248,7 @@
|
|
|
248
248
|
- **Seen by:** syntax.
|
|
249
249
|
- **Reports:** seen.
|
|
250
250
|
- **Check today:** partial.
|
|
251
|
-
- **Checks:** [assertion-site](symptoms/assertion-outside-a-test/assertion-site.md).
|
|
251
|
+
- **Checks:** [assertion-site](symptoms/assertion-outside-a-test-body/assertion-site.md).
|
|
252
252
|
|
|
253
253
|
### Behaviour tested away from its owner
|
|
254
254
|
|
|
@@ -262,7 +262,7 @@
|
|
|
262
262
|
### Branch in a test
|
|
263
263
|
|
|
264
264
|
- **Seen:** `if`, a ternary, `&&`, `||`, `??`, `?.` or `switch` in a test file.
|
|
265
|
-
- **May indicate:** Checks a value that may be one of several outcomes → Straight-through tests; A value is one of several kinds or states: the unit's output → Kinds are named; An operation can fail: the unit's output → Failures are values.
|
|
265
|
+
- **May indicate:** Checks a value that may be one of several outcomes → Straight-through tests; A value is one of several kinds or states: the unit's output → Kinds are named; An operation can fail: the unit's output → Failures are values; Uses what a collaborator gives back: reads a double's recorded calls or results → Written-out answers.
|
|
266
266
|
- **Breach usually sits:** in the unit's output type, where optional or loose shapes force the test to branch.
|
|
267
267
|
- **Seen by:** syntax.
|
|
268
268
|
- **Reports:** seen → breach.
|
|
@@ -270,18 +270,18 @@
|
|
|
270
270
|
- **To name the breach, a check needs:** types: the declaring type of the member read.
|
|
271
271
|
- **Check today:** reuse.
|
|
272
272
|
- **Checks:** [test-body](symptoms/branch-in-a-test/test-body.md).
|
|
273
|
-
- **Recipes:** [Assert to narrow](recipes.md#assert-to-narrow); [it.each over typed rows](recipes.md#iteach-over-typed-rows).
|
|
273
|
+
- **Recipes:** [Assert to narrow](recipes.md#assert-to-narrow); [it.each over typed rows](recipes.md#iteach-over-typed-rows); [Stub with vi.fn](recipes.md#stub-with-vifn).
|
|
274
274
|
|
|
275
|
-
### Code or prose read as text
|
|
275
|
+
### Code or prose read as text in a test
|
|
276
276
|
|
|
277
277
|
- **Seen:** A test reads TypeScript or Markdown source through a file read, a raw import, or a raw glob.
|
|
278
278
|
- **May indicate:** States what the unit gives back, for one case or several → Tests are ours.
|
|
279
|
-
- **Breach usually sits:** in a test that checks the words in a file instead of the code
|
|
279
|
+
- **Breach usually sits:** in a test that checks the words in a file instead of the code behaviour.
|
|
280
280
|
- **Covered by a record:** parsing source to verify its syntax or toolchain compatibility: an authorised location at the test that owns that proof.
|
|
281
281
|
- **Seen by:** syntax.
|
|
282
282
|
- **Reports:** seen.
|
|
283
283
|
- **Check today:** partial.
|
|
284
|
-
- **Checks:** [raw-read](symptoms/code-or-prose-read-as-text/raw-read.md).
|
|
284
|
+
- **Checks:** [raw-read](symptoms/code-or-prose-read-as-text-in-a-test/raw-read.md).
|
|
285
285
|
|
|
286
286
|
### Computed value in a test
|
|
287
287
|
|
|
@@ -320,7 +320,7 @@
|
|
|
320
320
|
|
|
321
321
|
"Exact returns can use mockreturn or mockresolve".
|
|
322
322
|
|
|
323
|
-
### Export from a test
|
|
323
|
+
### Export from a test
|
|
324
324
|
|
|
325
325
|
- **Seen:** An export declaration, assignment or modifier in a test file, including a type export.
|
|
326
326
|
- **May indicate:** States what the unit gives back, for one case or several → Straight-through tests; Gives each unit its test → Tested where it's owned.
|
|
@@ -328,7 +328,7 @@
|
|
|
328
328
|
- **Seen by:** syntax.
|
|
329
329
|
- **Reports:** seen.
|
|
330
330
|
- **Check today:** partial.
|
|
331
|
-
- **Checks:** [test-file-export](symptoms/export-from-a-test
|
|
331
|
+
- **Checks:** [test-file-export](symptoms/export-from-a-test/test-file-export.md).
|
|
332
332
|
|
|
333
333
|
### Inherited environment in a subprocess
|
|
334
334
|
|
|
@@ -488,13 +488,13 @@
|
|
|
488
488
|
### Rebinding
|
|
489
489
|
|
|
490
490
|
- **Seen:** A `let` assigned again, or a parameter reassigned, incremented or destructured into.
|
|
491
|
-
- **May indicate:** Makes a new value from what it has → No hidden effects; Does one job → Doer or orchestrator.
|
|
491
|
+
- **May indicate:** Makes a new value from what it has → No hidden effects; Does one job → Doer or orchestrator; Uses what a collaborator gives back: in a test → Written-out answers.
|
|
492
492
|
- **Breach usually sits:** in the unit: no caller sees it, so on its own it shows no hidden effect, but it is suspect for work done inline in steps.
|
|
493
493
|
- **Seen by:** syntax.
|
|
494
494
|
- **Reports:** seen.
|
|
495
495
|
- **Check today:** partial.
|
|
496
496
|
- **Checks:** [parameter-reassignment](symptoms/rebinding/parameter-reassignment.md), [test-body](symptoms/rebinding/test-body.md).
|
|
497
|
-
- **Recipes:** [Copy, never write in](recipes.md#copy-never-write-in); [Functional iteration](recipes.md#functional-iteration).
|
|
497
|
+
- **Recipes:** [Copy, never write in](recipes.md#copy-never-write-in); [Functional iteration](recipes.md#functional-iteration); [Stub with vi.fn](recipes.md#stub-with-vifn).
|
|
498
498
|
|
|
499
499
|
### Write into a parameter
|
|
500
500
|
|
|
@@ -716,7 +716,7 @@
|
|
|
716
716
|
- **May indicate:** An operation can fail → Failures are values.
|
|
717
717
|
- **Breach usually sits:** in the unit's return type.
|
|
718
718
|
- **Seen by:** person, syntax.
|
|
719
|
-
- **How it is seen:** syntax for
|
|
719
|
+
- **How it is seen:** syntax for an empty `catch` block or promise rejection handler.
|
|
720
720
|
- **Check today:** partial.
|
|
721
721
|
- **Checks:** [empty-catch](symptoms/failure-shaped-as-success/empty-catch.md).
|
|
722
722
|
- **Recipes:** [Result union](recipes.md#result-union).
|
|
@@ -859,7 +859,7 @@
|
|
|
859
859
|
- **Seen:** A schema, a `.parse` call or a `z.infer` type outside the producer's adapter, or the same value parsed twice.
|
|
860
860
|
- **May indicate:** Reads data from outside (request, file, environment, stored row, response) → No leak across a boundary; Gives a value its type (declares it, or needs it narrower) → Declared, not asserted.
|
|
861
861
|
- **Breach usually sits:** in the adapter, which hands the wire type inward instead of mapping it.
|
|
862
|
-
- **Covered by a record:** an outside model adopted as ours:
|
|
862
|
+
- **Covered by a record:** an outside model adopted as ours: an authorised location with a why-chain naming the outside model adopted as ours.
|
|
863
863
|
- **Seen by:** graph.
|
|
864
864
|
- **Reports:** seen.
|
|
865
865
|
- **Check today:** review.
|
|
@@ -870,7 +870,7 @@
|
|
|
870
870
|
- **Seen:** `JSON.parse`, `JSON.stringify` or a YAML parse or dump outside the adapter for whoever produced or receives the text, tests included.
|
|
871
871
|
- **May indicate:** Reads data from outside (request, file, environment, stored row, response) → No leak across a boundary; Sends data out of the program → No leak across a boundary; Uses a system or service outside the program → External behaviour sits at a boundary; States what the unit gives back, for one case or several → Straight-through tests.
|
|
872
872
|
- **Breach usually sits:** in a port that takes or gives text where it should carry objects.
|
|
873
|
-
- **Covered by a record:** correct use:
|
|
873
|
+
- **Covered by a record:** correct use: an authorised location on the adapter for whoever produced or receives the text; a use at one test site: an authorised location for this symptom alone.
|
|
874
874
|
- **Seen by:** syntax, types.
|
|
875
875
|
- **Reports:** seen → breach.
|
|
876
876
|
- **How it is seen:** types to trace the port.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type Standing = "accepted" | "proposed";
|
|
2
|
-
export type RecordKindName = "authorised-location" | "deviation" | "debt" | "
|
|
2
|
+
export type RecordKindName = "authorised-location" | "deviation" | "debt" | "dependency-record";
|
|
3
|
+
export type Specific = "outside-party";
|
|
3
4
|
export type SeenBy = "syntax" | "types" | "graph" | "app" | "files" | "history" | "person";
|
|
4
5
|
export type AuthoredPointed = {
|
|
5
6
|
readonly rule: string;
|
|
@@ -10,13 +11,22 @@ export type CaseItem = {
|
|
|
10
11
|
readonly standing: Standing;
|
|
11
12
|
readonly owes: readonly AuthoredPointed[];
|
|
12
13
|
};
|
|
14
|
+
export type AuthoredAnswer = {
|
|
15
|
+
readonly check: string;
|
|
16
|
+
readonly form: string;
|
|
17
|
+
};
|
|
18
|
+
export type AuthoredRecipeExample = {
|
|
19
|
+
readonly anchor: string;
|
|
20
|
+
readonly answers: readonly AuthoredAnswer[];
|
|
21
|
+
};
|
|
13
22
|
export type RecipeItem = {
|
|
14
|
-
readonly serves: AuthoredPointed;
|
|
23
|
+
readonly serves: readonly AuthoredPointed[];
|
|
15
24
|
readonly standing: Standing;
|
|
16
25
|
readonly reason: {
|
|
17
26
|
readonly text: string;
|
|
18
27
|
readonly standing: Standing;
|
|
19
28
|
};
|
|
29
|
+
readonly examples?: readonly AuthoredRecipeExample[] | undefined;
|
|
20
30
|
};
|
|
21
31
|
export type RecordKindItem = {
|
|
22
32
|
readonly phrase: string;
|
|
@@ -34,16 +44,22 @@ export type SymptomItem = {
|
|
|
34
44
|
readonly seenBy: readonly SeenBy[];
|
|
35
45
|
readonly reports?: "seen" | "seen-to-breach" | undefined;
|
|
36
46
|
readonly recipes: readonly string[];
|
|
37
|
-
readonly correctUses: readonly {
|
|
47
|
+
readonly correctUses: readonly ({
|
|
38
48
|
readonly situation: string;
|
|
39
|
-
readonly kind:
|
|
49
|
+
readonly kind: "authorised-location";
|
|
40
50
|
readonly at?: string | undefined;
|
|
41
|
-
|
|
51
|
+
readonly binds?: readonly Specific[] | undefined;
|
|
52
|
+
} | {
|
|
53
|
+
readonly situation: string;
|
|
54
|
+
readonly kind: Exclude<RecordKindName, "authorised-location">;
|
|
55
|
+
readonly at?: string | undefined;
|
|
56
|
+
})[];
|
|
42
57
|
readonly howItIsSeen?: string | undefined;
|
|
43
58
|
readonly breachACheckCouldName?: string | undefined;
|
|
44
59
|
readonly toNameTheBreach?: string | undefined;
|
|
45
60
|
};
|
|
46
61
|
export type CheckItem = {
|
|
62
|
+
readonly findingSpecifics?: readonly Specific[] | undefined;
|
|
47
63
|
readonly flagsBeyondTheSymptom?: string | undefined;
|
|
48
64
|
readonly misses?: string | undefined;
|
|
49
65
|
readonly settingsTracedTo?: string | undefined;
|
|
@@ -3,8 +3,7 @@ import type { RepoPath } from "../repository/repo-path-types.js";
|
|
|
3
3
|
import type { ClauseAddress } from "../rule-set/clause-address-types.js";
|
|
4
4
|
export type Remedy = {
|
|
5
5
|
readonly fix: string;
|
|
6
|
-
readonly
|
|
7
|
-
readonly section: string;
|
|
6
|
+
readonly form: string;
|
|
8
7
|
};
|
|
9
8
|
export type MeasuredPair = {
|
|
10
9
|
readonly clause: ClauseAddress;
|
package/src/eslint-plugin.js
CHANGED
|
@@ -1,68 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SYMPTOM_CATALOGUE_SEGMENTS,
|
|
3
|
-
readBoundCatalogue
|
|
4
|
-
} from "../chunks/chunk-7FVSZ2VL.js";
|
|
5
|
-
import {
|
|
6
|
-
installRootOfApiEntry,
|
|
7
|
-
loadFailureText
|
|
8
|
-
} from "../chunks/chunk-A3RL4O5V.js";
|
|
9
1
|
import {
|
|
10
2
|
honePluginAt,
|
|
11
3
|
honePluginFailureText,
|
|
12
4
|
installedEslintBoundary
|
|
13
|
-
} from "../chunks/chunk-
|
|
14
|
-
import "../chunks/chunk-
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
} from "../chunks/chunk-GMLT3MHO.js";
|
|
6
|
+
import "../chunks/chunk-6LTJRJOE.js";
|
|
7
|
+
import {
|
|
8
|
+
createBoundCatalogueOf,
|
|
9
|
+
mapCataloguesToEngineChecks,
|
|
10
|
+
runLoadFailureLine,
|
|
11
|
+
toolCatalogueOf
|
|
12
|
+
} from "../chunks/chunk-ND3EOGDK.js";
|
|
13
|
+
import {
|
|
14
|
+
installRootOfApiEntry,
|
|
15
|
+
loadFailureText
|
|
16
|
+
} from "../chunks/chunk-XNIXPQQ5.js";
|
|
17
|
+
import "../chunks/chunk-U6W65ZOF.js";
|
|
18
|
+
import "../chunks/chunk-4AJQHZ7I.js";
|
|
19
|
+
import "../chunks/chunk-FRE5IA3C.js";
|
|
18
20
|
import {
|
|
19
21
|
TOOL_IDENTITY,
|
|
20
|
-
TOOL_RULE_SET,
|
|
21
22
|
createDefaultDirectoryPort,
|
|
22
23
|
createDefaultFileTextPort,
|
|
23
24
|
createDefaultModuleLoaderPort,
|
|
24
25
|
createDefaultPathPort
|
|
25
|
-
} from "../chunks/chunk-
|
|
26
|
+
} from "../chunks/chunk-WPEOCLTP.js";
|
|
26
27
|
import "../chunks/chunk-YONPKP3C.js";
|
|
27
28
|
import "../chunks/chunk-OO5KV7KN.js";
|
|
28
29
|
import "../chunks/chunk-RANIXNWY.js";
|
|
29
30
|
import "../chunks/chunk-DGOLOS5A.js";
|
|
30
31
|
|
|
32
|
+
// src/application/run/engines/tool-engine-checks.ts
|
|
33
|
+
var mapToolCatalogueToEngineChecks = (request) => {
|
|
34
|
+
const catalogue = toolCatalogueOf(request);
|
|
35
|
+
return catalogue.outcome === "failed" ? catalogue : mapCataloguesToEngineChecks({ catalogues: [catalogue.value] });
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/infrastructure/engines/eslint/runner/hone-plugin/plugin-build.ts
|
|
39
|
+
var createPluginAt = async (request) => {
|
|
40
|
+
const boundary = await installedEslintBoundary();
|
|
41
|
+
if (boundary.outcome === "failed") {
|
|
42
|
+
return boundary;
|
|
43
|
+
}
|
|
44
|
+
const plugin2 = await honePluginAt({ ...request, boundary: boundary.value });
|
|
45
|
+
return plugin2.outcome === "failed" ? { outcome: "failed", error: honePluginFailureText({ failure: plugin2.error }) } : plugin2;
|
|
46
|
+
};
|
|
47
|
+
|
|
31
48
|
// src/eslint-plugin.ts
|
|
32
49
|
var path = createDefaultPathPort({});
|
|
33
50
|
var fileText = createDefaultFileTextPort({});
|
|
34
51
|
var pluginAt = async (request) => {
|
|
35
|
-
const
|
|
52
|
+
const checks = mapToolCatalogueToEngineChecks({
|
|
36
53
|
fileText,
|
|
37
|
-
directory: createDefaultDirectoryPort({}),
|
|
38
54
|
path,
|
|
39
|
-
ruleSetRoot: request.installRoot,
|
|
40
|
-
ruleSet: TOOL_RULE_SET,
|
|
41
55
|
installRoot: request.installRoot,
|
|
42
|
-
|
|
56
|
+
boundCatalogueOf: createBoundCatalogueOf({ directory: createDefaultDirectoryPort({}) })
|
|
43
57
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
outcome: "failed",
|
|
50
|
-
error: `this install holds no ${SYMPTOM_CATALOGUE_SEGMENTS.join("/")} under ${request.installRoot}`
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
const boundary = await installedEslintBoundary();
|
|
54
|
-
if (boundary.outcome === "failed") {
|
|
55
|
-
return boundary;
|
|
56
|
-
}
|
|
57
|
-
const plugin2 = await honePluginAt({
|
|
58
|
-
checks: catalogue.value.catalogue.checks,
|
|
58
|
+
return checks.outcome === "failed" ? {
|
|
59
|
+
outcome: "failed",
|
|
60
|
+
error: runLoadFailureLine({ failure: checks.error, upgradeCommand: void 0 })
|
|
61
|
+
} : createPluginAt({
|
|
62
|
+
checks: checks.value,
|
|
59
63
|
installRoot: request.installRoot,
|
|
60
64
|
fileText,
|
|
61
65
|
path,
|
|
62
|
-
modules: createDefaultModuleLoaderPort({})
|
|
63
|
-
boundary: boundary.value
|
|
66
|
+
modules: createDefaultModuleLoaderPort({})
|
|
64
67
|
});
|
|
65
|
-
return plugin2.outcome === "failed" ? { outcome: "failed", error: honePluginFailureText({ failure: plugin2.error }) } : plugin2;
|
|
66
68
|
};
|
|
67
69
|
var installRoot = installRootOfApiEntry({ path, moduleUrl: import.meta.url });
|
|
68
70
|
var built = installRoot.outcome === "failed" ? { outcome: "failed", error: loadFailureText({ failure: installRoot.error }) } : await pluginAt({ installRoot: installRoot.value });
|