@hailstails/hone 2.0.0-pre.3 → 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.
- package/ADOPTING.md +7 -7
- package/CHANGELOG.md +70 -0
- package/MIGRATING.md +15 -6
- package/README.md +12 -13
- package/chunks/chunk-3CWFUD5B.js +38 -0
- package/chunks/chunk-5AKHEW6V.js +15 -0
- package/chunks/chunk-75XWZYNN.js +64 -0
- package/chunks/chunk-7FVSZ2VL.js +1304 -0
- package/chunks/chunk-A3RL4O5V.js +146 -0
- package/chunks/chunk-BIDD2YWP.js +398 -0
- package/chunks/{chunk-GNOMK7CR.js → chunk-BKQ3K766.js} +489 -52
- package/chunks/{chunk-NRIQD3PI.js → chunk-BRANVR7K.js} +3 -5
- package/chunks/chunk-COQMPHWZ.js +37 -0
- package/chunks/{chunk-L7BGRC6D.js → chunk-CXM5KBZX.js} +1 -1
- package/chunks/chunk-D6645WPB.js +6 -0
- package/chunks/chunk-DJMF6JIM.js +42 -0
- package/chunks/{chunk-OKLYWD2Z.js → chunk-E4D5WDRX.js} +27 -20
- package/chunks/chunk-EBX57Z3V.js +8 -0
- package/chunks/chunk-FHVNKG5Q.js +19 -0
- package/chunks/chunk-FPIP7JEC.js +191 -0
- package/chunks/{chunk-QP5TLOBY.js → chunk-HVZVKZPW.js} +12 -9
- package/chunks/chunk-LD766VWU.js +57 -0
- package/chunks/chunk-LEFM7OPS.js +41 -0
- package/chunks/chunk-LNMDMRGQ.js +51 -0
- package/chunks/{chunk-RGSHTPLA.js → chunk-MBEDAFVC.js} +3 -11
- package/chunks/chunk-OO5KV7KN.js +17 -0
- package/chunks/{chunk-ASUN4AVC.js → chunk-PVSC4SE3.js} +71 -5
- package/chunks/chunk-SKDQ3QJD.js +75 -0
- package/chunks/chunk-W5OIAUDW.js +18 -0
- package/chunks/chunk-X73RZUPO.js +63 -0
- package/chunks/chunk-XE2KKWYH.js +45 -0
- package/chunks/chunk-YGMO5Z6U.js +432 -0
- package/chunks/chunk-YONPKP3C.js +15 -0
- package/docs/adding-a-discipline-or-mechanism.md +1 -1
- package/docs/extending.md +7 -388
- package/package.json +7 -6
- package/rules/README.md +2 -2
- package/rules/typescript/checks.md +236 -18
- package/rules/typescript/symptoms/ambient-randomness/random-call.md +10 -0
- package/rules/typescript/symptoms/answer-set-in-a-hook/hook-answer.md +10 -0
- package/rules/typescript/symptoms/assertion-outside-a-test/assertion-site.md +10 -0
- package/rules/typescript/symptoms/assertion-outside-a-test.md +25 -0
- package/rules/typescript/symptoms/built-unit-called-in-place/call-of-a-call.md +10 -0
- package/rules/typescript/symptoms/built-unit-called-in-place.md +25 -0
- package/rules/typescript/symptoms/code-or-prose-read-as-text/raw-read.md +10 -0
- package/rules/typescript/symptoms/code-or-prose-read-as-text.md +31 -0
- package/rules/typescript/symptoms/computed-value-in-a-test/test-body.md +1 -1
- package/rules/typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md +1 -1
- package/rules/typescript/symptoms/double-with-a-body/stub-implementation.md +2 -2
- package/rules/typescript/symptoms/export-from-a-test-file/test-file-export.md +10 -0
- package/rules/typescript/symptoms/export-from-a-test-file.md +33 -0
- package/rules/typescript/symptoms/failure-shaped-as-success/empty-catch.md +10 -0
- package/rules/typescript/symptoms/floating-version/version-selector.md +10 -0
- package/rules/typescript/symptoms/inherited-environment-in-a-subprocess/git-spawn-environment.md +1 -1
- package/rules/typescript/symptoms/many-spellings-of-one-concept/test-call-aliases.md +10 -0
- package/rules/typescript/symptoms/many-spellings-of-one-concept.md +3 -2
- package/rules/typescript/symptoms/module-or-global-patched/module-mock-call.md +4 -4
- package/rules/typescript/symptoms/no-lock-file/committed-lock-file.md +12 -0
- package/rules/typescript/symptoms/process-global-used-in-place/debugger-statement.md +10 -0
- package/rules/typescript/symptoms/process-global-used-in-place/direct-global-use.md +14 -0
- package/rules/typescript/symptoms/process-global-used-in-place.md +1 -1
- package/rules/typescript/symptoms/prose-in-code/comment-prose.md +12 -0
- package/rules/typescript/symptoms/test-switched-off/skipped-tests.md +3 -6
- package/rules/typescript/symptoms/test-switched-off.md +1 -1
- package/rules/typescript/symptoms/throw-between-our-units/throw-statement.md +10 -0
- package/rules/typescript/symptoms/throw-or-catch-in-a-test/throw-statement.md +1 -1
- package/rules/typescript/symptoms/tool-fetched-at-run-time/fetch-command.md +10 -0
- package/rules/typescript/symptoms/type-declared-in-a-test/test-type-declaration.md +10 -0
- package/rules/typescript/symptoms/type-declared-in-a-test.md +33 -0
- package/rules/typescript/symptoms/unit-without-a-running-test/companion-test-file.md +2 -2
- package/rules/typescript/symptoms/wide-input/unread-parameter.md +10 -0
- package/rules/typescript/symptoms/wide-input.md +3 -2
- package/rules/typescript/symptoms.md +183 -121
- package/src/application/conformance/conformance-testing-types.d.ts +13 -16
- package/src/domain/language-layer/authored-item-types.d.ts +50 -0
- package/src/domain/language-layer/catalogue-name.d.ts +5 -0
- package/src/domain/language-layer/check-address-text.d.ts +12 -0
- package/src/domain/rule-set/authored-rule-set-types.d.ts +31 -32
- package/src/domain/rule-set/clause-address-types.d.ts +4 -3
- package/src/domain/rule-set/rule-set-name-of.d.ts +10 -0
- package/src/domain/runner/check-binding.d.ts +18 -0
- package/src/domain/runner/check-observations.d.ts +39 -0
- package/src/domain/runner/conformance-types.d.ts +8 -2
- package/src/domain/settings/test-files.d.ts +7 -0
- package/src/eslint-plugin.js +16 -12
- package/src/hone.js +10677 -10754
- package/src/infrastructure/engines/eslint/authored-class-or-this/static-members-only/piece.json +0 -6
- package/src/infrastructure/engines/eslint/long-function/function-length/piece.json +0 -6
- package/src/infrastructure/engines/eslint/runner/pieces/eslint-piece-settings-types.d.ts +2 -0
- package/src/infrastructure/engines/eslint/runner/runner.js +945 -1188
- package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/README.md +0 -3
- package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/eslint-plugin.js +33 -21
- package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/piece.json +11 -4
- package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/skipped-tests.examples.json +28 -0
- package/src/infrastructure/engines/eslint/untyped-value/implicit-any-let/piece.json +0 -2
- package/src/infrastructure/engines/eslint/wide-input/unread-parameter/eslint-plugin.js +94 -0
- package/src/infrastructure/engines/eslint/wide-input/unread-parameter/piece.json +11 -0
- package/src/infrastructure/engines/eslint/wide-input/unread-parameter/unread-parameter.examples.json +48 -0
- package/src/infrastructure/engines/walker/ambient-randomness/random-call/ambient-randomness.js +109 -0
- package/src/infrastructure/engines/walker/ambient-randomness/random-call/piece.json +9 -0
- package/src/infrastructure/engines/walker/ambient-randomness/random-call/random-call.examples.json +48 -0
- package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/hook-answer.examples.json +42 -0
- package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/hook-answers.js +72 -0
- package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/piece.json +9 -0
- package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/assertion-site.examples.json +30 -0
- package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/assertion-site.js +123 -0
- package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/piece.json +9 -0
- package/src/infrastructure/engines/walker/authored-class-or-this/class-keyword/class-syntax.js +3 -3
- package/src/infrastructure/engines/walker/boolean-in-a-signature/boolean-annotation/boolean-signatures.js +7 -5
- package/src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body-logic.js +169 -98
- package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/call-of-a-call.examples.json +24 -0
- package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/call-of-a-call.js +34 -0
- package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/piece.json +9 -0
- package/src/infrastructure/engines/walker/claimed-type/cast-to-any/any-cast.js +6 -4
- package/src/infrastructure/engines/walker/claimed-type/unlisted-cast-site/cast-expressions.js +6 -4
- package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/piece.json +9 -0
- package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/raw-read.examples.json +30 -0
- package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/raw-read.js +166 -0
- package/src/infrastructure/engines/walker/computed-value-in-a-test/test-body/piece.json +0 -10
- package/src/infrastructure/engines/walker/date-used-directly/clock-sources/clock-sources.js +4 -4
- package/src/infrastructure/engines/walker/default-on-a-closed-union/default-arm/switch-defaults.js +8 -6
- package/src/infrastructure/engines/walker/double-with-a-body/logic-in-a-passed-function/piece.json +0 -10
- package/src/infrastructure/engines/walker/double-with-a-body/stub-implementation/dependency-isolation.js +9 -14
- package/src/infrastructure/engines/walker/drawer-path/drawer-names/categorical-paths.js +4 -4
- package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/piece.json +9 -0
- package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/test-file-export.examples.json +30 -0
- package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/test-file-export.js +31 -0
- package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.examples.json +18 -0
- package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.js +32 -0
- package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/piece.json +9 -0
- package/src/infrastructure/engines/walker/floating-version/version-selector/piece.json +9 -0
- package/src/infrastructure/engines/walker/floating-version/version-selector/version-selector.examples.json +54 -0
- package/src/infrastructure/engines/walker/floating-version/version-selector/version-selector.js +75 -0
- package/src/infrastructure/engines/walker/inherited-environment-in-a-subprocess/git-spawn-environment/hermetic-git-spawns.js +8 -17
- package/src/infrastructure/engines/walker/loop-keyword/loop-statement/loops.js +8 -6
- package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/piece.json +9 -0
- package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/test-call-aliases.examples.json +36 -0
- package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/test-call-aliases.js +67 -0
- package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mock-call.examples.json +34 -0
- package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mocking.js +64 -16
- package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/piece.json +5 -1
- package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/committed-lock-file.examples.json +24 -0
- package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/committed-lock-file.js +41 -0
- package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/piece.json +9 -0
- package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/import-boundaries.js +18 -16
- package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/piece.json +1 -1
- package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/debugger-statement.examples.json +18 -0
- package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/debugger-statement.js +17 -0
- package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/piece.json +9 -0
- package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/direct-global-use.examples.json +63 -0
- package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/piece.json +13 -0
- package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/process-global-used-in-place.js +126 -0
- package/src/infrastructure/engines/walker/prose-in-code/comment-prose/comment-prose.examples.json +42 -0
- package/src/infrastructure/engines/walker/prose-in-code/comment-prose/piece.json +16 -0
- package/src/infrastructure/engines/walker/prose-in-code/comment-prose/prose-in-code.js +90 -0
- package/src/infrastructure/engines/walker/rebinding/test-body/piece.json +0 -10
- package/src/infrastructure/engines/walker/runner/pieces/walker-piece.d.ts +7 -5
- package/src/infrastructure/engines/walker/runner/runner.js +266 -77
- package/src/infrastructure/engines/walker/runner/toolchain/typescript-parse.d.ts +3 -0
- package/src/infrastructure/engines/walker/shorthand-name/identifier-names/identifier-names.js +12 -7
- package/src/infrastructure/engines/walker/strictness-weakened/exact-optional-property-types/piece.json +0 -10
- package/src/infrastructure/engines/walker/strictness-weakened/no-fallthrough-cases-in-switch/piece.json +0 -10
- package/src/infrastructure/engines/walker/strictness-weakened/no-implicit-override/piece.json +0 -10
- package/src/infrastructure/engines/walker/strictness-weakened/no-property-access-from-index-signature/piece.json +0 -10
- package/src/infrastructure/engines/walker/strictness-weakened/no-unchecked-indexed-access/piece.json +0 -10
- package/src/infrastructure/engines/walker/strictness-weakened/strict/compiler-overrides.js +30 -52
- package/src/infrastructure/engines/walker/strictness-weakened/use-unknown-in-catch-variables/piece.json +0 -10
- package/src/infrastructure/engines/walker/text-past-its-reader/test-body/piece.json +0 -10
- package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/piece.json +9 -0
- package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/throw-statement.examples.json +36 -0
- package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/throws-in-production.js +12 -0
- package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throw-statement.examples.json +6 -6
- package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throws-in-tests.js +5 -44
- package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/try-block/piece.json +0 -10
- package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/fetch-command.examples.json +42 -0
- package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/fetch-command.js +152 -0
- package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/piece.json +9 -0
- package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/piece.json +9 -0
- package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.examples.json +24 -0
- package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.js +27 -0
- package/src/infrastructure/engines/walker/type-derived-from-code/factory-return-types/factory-return-types.js +8 -6
- package/src/infrastructure/engines/walker/unit-without-a-running-test/companion-test-file/export-test-sibling.js +16 -10
- package/src/infrastructure/engines/walker/untracked-escape/directive-pointers/comments-directives.js +18 -64
- package/src/infrastructure/engines/walker/write-into-a-parameter/parameter-mutation/parameter-mutation.js +7 -5
- package/src/rule-set.d.ts +2 -1
- package/src/testing.d.ts +2 -4
- package/src/testing.js +104 -317
- package/src/{audit.d.ts → walker.d.ts} +13 -8
- package/src/walker.js +28 -0
- package/chunks/chunk-5HRMJ4O2.js +0 -608
- package/chunks/chunk-IX2VZTBO.js +0 -887
- package/chunks/chunk-K2W3D3NB.js +0 -17
- package/chunks/chunk-M6SOGWT7.js +0 -82
- package/chunks/chunk-Q62Y25WS.js +0 -843
- package/chunks/chunk-R75QELTA.js +0 -481
- package/chunks/chunk-RANAKCTW.js +0 -31
- package/chunks/chunk-TNY2PASL.js +0 -38
- package/chunks/chunk-UJONWHA4.js +0 -22
- package/docs/output-contract.md +0 -1155
- package/src/audit.js +0 -18
- 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
|
-
|
|
6
|
-
} from "../../../../../../chunks/chunk-
|
|
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/
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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: "
|
|
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
|
|
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;
|
|
@@ -433,23 +461,30 @@ var declarationsOf = (request) => {
|
|
|
433
461
|
};
|
|
434
462
|
var declarationsNamed = (request) => request.declarations.get(request.name) ?? [];
|
|
435
463
|
var declarationTarget = (request) => {
|
|
436
|
-
const { syntaxApi, declarations, node, visited } = request;
|
|
464
|
+
const { syntaxApi, declarations, ownPackageNames, node, visited } = request;
|
|
437
465
|
if (syntaxApi.isImportEqualsDeclaration(node)) {
|
|
438
466
|
const reference = node.moduleReference;
|
|
439
|
-
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";
|
|
440
468
|
}
|
|
441
469
|
if (!syntaxApi.isVariableDeclaration(node) || node.initializer === void 0) return "own-api";
|
|
442
|
-
return originTarget({
|
|
470
|
+
return originTarget({
|
|
471
|
+
syntaxApi,
|
|
472
|
+
declarations,
|
|
473
|
+
ownPackageNames,
|
|
474
|
+
node: node.initializer,
|
|
475
|
+
visited
|
|
476
|
+
});
|
|
443
477
|
};
|
|
444
478
|
var nameTarget = (request) => {
|
|
445
|
-
const { syntaxApi, declarations, node, name, visited } = request;
|
|
479
|
+
const { syntaxApi, declarations, ownPackageNames, node, name, visited } = request;
|
|
446
480
|
if (visited.includes(name)) return "own-api";
|
|
447
|
-
if (BUILT_IN_NAMESPACES.includes(name) || packageBindingsOf({ syntaxApi, node }).includes(name))
|
|
481
|
+
if (BUILT_IN_NAMESPACES.includes(name) || packageBindingsOf({ syntaxApi, ownPackageNames, node }).includes(name))
|
|
448
482
|
return "built-in-or-library";
|
|
449
483
|
const fromLibrary = declarationsNamed({ declarations, name }).some(
|
|
450
484
|
(declaration) => declarationTarget({
|
|
451
485
|
syntaxApi,
|
|
452
486
|
declarations,
|
|
487
|
+
ownPackageNames,
|
|
453
488
|
node: declaration,
|
|
454
489
|
visited: [...visited, name]
|
|
455
490
|
}) === "built-in-or-library"
|
|
@@ -457,11 +492,18 @@ var nameTarget = (request) => {
|
|
|
457
492
|
return fromLibrary ? "built-in-or-library" : "own-api";
|
|
458
493
|
};
|
|
459
494
|
var memberTarget = (request) => {
|
|
460
|
-
const { syntaxApi, declarations, member, visited } = request;
|
|
495
|
+
const { syntaxApi, declarations, ownPackageNames, member, visited } = request;
|
|
461
496
|
if (syntaxApi.isShorthandPropertyAssignment(member)) {
|
|
462
|
-
return nameTarget({
|
|
497
|
+
return nameTarget({
|
|
498
|
+
syntaxApi,
|
|
499
|
+
declarations,
|
|
500
|
+
ownPackageNames,
|
|
501
|
+
node: member,
|
|
502
|
+
name: member.name.text,
|
|
503
|
+
visited
|
|
504
|
+
});
|
|
463
505
|
}
|
|
464
|
-
return syntaxApi.isPropertyAssignment(member) ? originTarget({ syntaxApi, declarations, node: member.initializer, visited }) : "own-api";
|
|
506
|
+
return syntaxApi.isPropertyAssignment(member) ? originTarget({ syntaxApi, declarations, ownPackageNames, node: member.initializer, visited }) : "own-api";
|
|
465
507
|
};
|
|
466
508
|
var heldMembersNamed = (request) => {
|
|
467
509
|
const { syntaxApi, declarations, holder, member } = request;
|
|
@@ -476,7 +518,7 @@ var heldMembersNamed = (request) => {
|
|
|
476
518
|
});
|
|
477
519
|
};
|
|
478
520
|
var heldValueTarget = (request) => {
|
|
479
|
-
const { syntaxApi, declarations, node, visited } = request;
|
|
521
|
+
const { syntaxApi, declarations, ownPackageNames, node, visited } = request;
|
|
480
522
|
if (!syntaxApi.isPropertyAccessExpression(node) || !syntaxApi.isIdentifier(node.expression))
|
|
481
523
|
return void 0;
|
|
482
524
|
const members = heldMembersNamed({
|
|
@@ -488,29 +530,32 @@ var heldValueTarget = (request) => {
|
|
|
488
530
|
});
|
|
489
531
|
if (members.length === 0) return void 0;
|
|
490
532
|
const fromLibrary = members.some(
|
|
491
|
-
(member) => memberTarget({ syntaxApi, declarations, node, member, visited }) === "built-in-or-library"
|
|
533
|
+
(member) => memberTarget({ syntaxApi, declarations, ownPackageNames, node, member, visited }) === "built-in-or-library"
|
|
492
534
|
);
|
|
493
535
|
return fromLibrary ? "built-in-or-library" : "own-api";
|
|
494
536
|
};
|
|
495
537
|
var originTarget = (request) => {
|
|
496
|
-
const { syntaxApi, declarations, node, visited } = request;
|
|
538
|
+
const { syntaxApi, declarations, ownPackageNames, node, visited } = request;
|
|
497
539
|
const loadedModule = loadedModuleOf({ syntaxApi, node });
|
|
498
|
-
if (loadedModule !== void 0) return moduleTarget({ specifier: loadedModule });
|
|
540
|
+
if (loadedModule !== void 0) return moduleTarget({ specifier: loadedModule, ownPackageNames });
|
|
499
541
|
const held = heldValueTarget(request);
|
|
500
542
|
if (held !== void 0) return held;
|
|
501
543
|
if (syntaxApi.isIdentifier(node))
|
|
502
|
-
return nameTarget({ syntaxApi, declarations, node, name: node.text, visited });
|
|
544
|
+
return nameTarget({ syntaxApi, declarations, ownPackageNames, node, name: node.text, visited });
|
|
503
545
|
if (syntaxApi.isStringLiteralLike(node) || syntaxApi.isArrayLiteralExpression(node) || syntaxApi.isTemplateExpression(node)) {
|
|
504
546
|
return "built-in-or-library";
|
|
505
547
|
}
|
|
506
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);
|
|
507
|
-
return isChain ? originTarget({ syntaxApi, declarations, node: node.expression, visited }) : "own-api";
|
|
549
|
+
return isChain ? originTarget({ syntaxApi, declarations, ownPackageNames, node: node.expression, visited }) : "own-api";
|
|
508
550
|
};
|
|
509
551
|
var packageBindingsOf = (request) => request.node.getSourceFile().statements.flatMap((statement) => {
|
|
510
552
|
const { syntaxApi } = request;
|
|
511
553
|
if (!syntaxApi.isImportDeclaration(statement) || !syntaxApi.isStringLiteral(statement.moduleSpecifier))
|
|
512
554
|
return [];
|
|
513
|
-
if (
|
|
555
|
+
if (moduleTarget({
|
|
556
|
+
specifier: statement.moduleSpecifier.text,
|
|
557
|
+
ownPackageNames: request.ownPackageNames
|
|
558
|
+
}) === "own-api" || statement.importClause === void 0)
|
|
514
559
|
return [];
|
|
515
560
|
const { name, namedBindings } = statement.importClause;
|
|
516
561
|
const named = namedBindings === void 0 ? [] : syntaxApi.isNamespaceImport(namedBindings) ? [namedBindings.name.text] : namedBindings.elements.map((element) => element.name.text);
|
|
@@ -528,8 +573,14 @@ var argumentsTarget = (request) => {
|
|
|
528
573
|
return objectNoBuiltInTakes ? "own-api" : "built-in-or-library";
|
|
529
574
|
};
|
|
530
575
|
var callTargetOf = (request) => {
|
|
531
|
-
const { syntaxApi, declarations, call, method } = request;
|
|
532
|
-
const target = originTarget({
|
|
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
|
+
});
|
|
533
584
|
if (target === "built-in-or-library") return "built-in-or-library";
|
|
534
585
|
return argumentsTarget({ syntaxApi, call, name: method.name.text });
|
|
535
586
|
};
|
|
@@ -539,9 +590,15 @@ var listedMethodForm = (request) => {
|
|
|
539
590
|
return callTargetOf(request) === "own-api" ? void 0 : form;
|
|
540
591
|
};
|
|
541
592
|
var callForm = (request) => {
|
|
542
|
-
const { syntaxApi, declarations, node } = request;
|
|
593
|
+
const { syntaxApi, declarations, ownPackageNames, node } = request;
|
|
543
594
|
if (!syntaxApi.isCallExpression(node)) return void 0;
|
|
544
|
-
const calledForm = syntaxApi.isPropertyAccessExpression(node.expression) ? listedMethodForm({
|
|
595
|
+
const calledForm = syntaxApi.isPropertyAccessExpression(node.expression) ? listedMethodForm({
|
|
596
|
+
syntaxApi,
|
|
597
|
+
declarations,
|
|
598
|
+
ownPackageNames,
|
|
599
|
+
call: node,
|
|
600
|
+
method: node.expression
|
|
601
|
+
}) ?? namespaceForm({
|
|
545
602
|
syntaxApi,
|
|
546
603
|
node: node.expression.expression,
|
|
547
604
|
name: node.expression.name.text
|
|
@@ -566,11 +623,21 @@ var expressionForm = (request) => {
|
|
|
566
623
|
return callForm(request) ?? optionalChainForm(request);
|
|
567
624
|
};
|
|
568
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
|
+
]);
|
|
569
636
|
var takesImplementation = (request) => {
|
|
570
637
|
const { syntaxApi, node } = request;
|
|
571
|
-
if (!syntaxApi.isCallExpression(node)
|
|
572
|
-
return "other";
|
|
638
|
+
if (!syntaxApi.isCallExpression(node)) return "other";
|
|
573
639
|
const callee = node.expression;
|
|
640
|
+
if (!syntaxApi.isPropertyAccessExpression(callee)) return "other";
|
|
574
641
|
const isViFn = callee.name.text === "fn" && syntaxApi.isIdentifier(callee.expression) && callee.expression.text === "vi";
|
|
575
642
|
return isViFn || IMPLEMENTATION_TAKERS.includes(callee.name.text) ? "takes" : "other";
|
|
576
643
|
};
|
|
@@ -579,12 +646,22 @@ var enclosingFunctionOf = (request) => {
|
|
|
579
646
|
if (request.syntaxApi.isFunctionLike(request.node)) return request.node;
|
|
580
647
|
return enclosingFunctionOf({ syntaxApi: request.syntaxApi, node: request.node.parent });
|
|
581
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
|
+
};
|
|
582
659
|
var enclosureOf = (request) => {
|
|
583
660
|
const { syntaxApi } = request;
|
|
584
661
|
const enclosing = enclosingFunctionOf({ syntaxApi, node: request.node.parent });
|
|
585
662
|
if (enclosing === void 0) return "elsewhere";
|
|
586
663
|
const holder = syntaxApi.isPropertyAssignment(enclosing.parent) ? enclosing.parent.parent : enclosing.parent;
|
|
587
|
-
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 });
|
|
588
665
|
return passedOn ? "passed-on-function" : "elsewhere";
|
|
589
666
|
};
|
|
590
667
|
var testBodyFormOf = (request) => {
|
|
@@ -592,57 +669,51 @@ var testBodyFormOf = (request) => {
|
|
|
592
669
|
if (form === void 0) return void 0;
|
|
593
670
|
return enclosureOf(request) === "passed-on-function" ? { introducedIn: form.introducedIn, remedy: PASSED_ON_FUNCTION } : form;
|
|
594
671
|
};
|
|
595
|
-
var snippetAt = (request) => {
|
|
596
|
-
const snippet = request.source.slice(request.position, request.position + 80).replace(/\n/g, " ");
|
|
597
|
-
return snippet.length === 80 ? `${snippet}\u2026` : snippet;
|
|
598
|
-
};
|
|
599
672
|
var check = {
|
|
600
|
-
prepare: ({
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
outcome: "ok",
|
|
609
|
-
value: {
|
|
610
|
-
kind: "syntax",
|
|
611
|
-
begin: ({ sourceFile, anchorAt }) => {
|
|
612
|
-
const hits = [];
|
|
613
|
-
const declarations = declarationsOf({ syntaxApi, sourceFile });
|
|
614
|
-
return {
|
|
615
|
-
enter: ({ node }) => {
|
|
616
|
-
const form = testBodyFormOf({ syntaxApi, declarations, node });
|
|
617
|
-
if (form === void 0) return;
|
|
618
|
-
const reaching = clauses.filter(
|
|
619
|
-
(clause) => editionReaches({
|
|
620
|
-
edition: clause.edition,
|
|
621
|
-
introducedIn: form.introducedIn
|
|
622
|
-
}) === "reached"
|
|
623
|
-
);
|
|
624
|
-
if (reaching.length === 0) return;
|
|
625
|
-
const position = node.getStart(sourceFile);
|
|
626
|
-
const anchor = anchorAt({ position });
|
|
627
|
-
const snippet = snippetAt({ source: sourceFile.text, position });
|
|
628
|
-
hits.push(
|
|
629
|
-
...reaching.map((clause) => ({
|
|
630
|
-
clause: clause.address,
|
|
631
|
-
anchor,
|
|
632
|
-
snippet,
|
|
633
|
-
remedy: form.remedy
|
|
634
|
-
}))
|
|
635
|
-
);
|
|
636
|
-
},
|
|
637
|
-
finish: () => hits
|
|
638
|
-
};
|
|
639
|
-
}
|
|
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" } };
|
|
640
681
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
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
|
+
}
|
|
646
717
|
};
|
|
647
718
|
export {
|
|
648
719
|
TEST_BODY_REMEDIES,
|
|
@@ -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
|
+
};
|
|
@@ -2,10 +2,12 @@ import {
|
|
|
2
2
|
anyBearingOf,
|
|
3
3
|
assertionOf,
|
|
4
4
|
castSnippetAt
|
|
5
|
-
} from "../../../../../../chunks/chunk-
|
|
5
|
+
} from "../../../../../../chunks/chunk-HVZVKZPW.js";
|
|
6
|
+
import "../../../../../../chunks/chunk-EBX57Z3V.js";
|
|
7
|
+
import "../../../../../../chunks/chunk-5AKHEW6V.js";
|
|
6
8
|
import {
|
|
7
9
|
folderScope
|
|
8
|
-
} from "../../../../../../chunks/chunk-
|
|
10
|
+
} from "../../../../../../chunks/chunk-COQMPHWZ.js";
|
|
9
11
|
import "../../../../../../chunks/chunk-DGOLOS5A.js";
|
|
10
12
|
|
|
11
13
|
// src/infrastructure/engines/walker/claimed-type/cast-to-any/any-cast.ts
|
|
@@ -15,7 +17,7 @@ var sourceEligibility = (request) => {
|
|
|
15
17
|
return "eligible";
|
|
16
18
|
};
|
|
17
19
|
var check = {
|
|
18
|
-
prepare: ({
|
|
20
|
+
prepare: ({ bindings, syntaxApi }) => ({
|
|
19
21
|
outcome: "ok",
|
|
20
22
|
value: {
|
|
21
23
|
prepareFile: ({ file }) => {
|
|
@@ -37,7 +39,7 @@ var check = {
|
|
|
37
39
|
const snippet = castSnippetAt({ sourceFile, position });
|
|
38
40
|
const anchor = anchorAt({ position });
|
|
39
41
|
hits.push(
|
|
40
|
-
...
|
|
42
|
+
...bindings.map((binding) => ({ check: binding.address, anchor, snippet }))
|
|
41
43
|
);
|
|
42
44
|
},
|
|
43
45
|
finish: () => hits
|
package/src/infrastructure/engines/walker/claimed-type/unlisted-cast-site/cast-expressions.js
CHANGED
|
@@ -3,10 +3,12 @@ import {
|
|
|
3
3
|
assertionOf,
|
|
4
4
|
castShapeOf,
|
|
5
5
|
castSnippetAt
|
|
6
|
-
} from "../../../../../../chunks/chunk-
|
|
6
|
+
} from "../../../../../../chunks/chunk-HVZVKZPW.js";
|
|
7
|
+
import "../../../../../../chunks/chunk-EBX57Z3V.js";
|
|
8
|
+
import "../../../../../../chunks/chunk-5AKHEW6V.js";
|
|
7
9
|
import {
|
|
8
10
|
folderScope
|
|
9
|
-
} from "../../../../../../chunks/chunk-
|
|
11
|
+
} from "../../../../../../chunks/chunk-COQMPHWZ.js";
|
|
10
12
|
import "../../../../../../chunks/chunk-DGOLOS5A.js";
|
|
11
13
|
|
|
12
14
|
// src/infrastructure/engines/walker/claimed-type/unlisted-cast-site/cast-expressions.ts
|
|
@@ -18,7 +20,7 @@ var sourceEligibility = (request) => {
|
|
|
18
20
|
};
|
|
19
21
|
var reportedSnippet = (request) => request.shape === "through-unknown" ? `${THROUGH_UNKNOWN_MESSAGE}: ${request.snippet}` : request.snippet;
|
|
20
22
|
var check = {
|
|
21
|
-
prepare: ({
|
|
23
|
+
prepare: ({ bindings, syntaxApi }) => ({
|
|
22
24
|
outcome: "ok",
|
|
23
25
|
value: {
|
|
24
26
|
prepareFile: ({ file }) => {
|
|
@@ -46,7 +48,7 @@ var check = {
|
|
|
46
48
|
});
|
|
47
49
|
const anchor = anchorAt({ position });
|
|
48
50
|
hits.push(
|
|
49
|
-
...
|
|
51
|
+
...bindings.map((binding) => ({ check: binding.address, anchor, snippet }))
|
|
50
52
|
);
|
|
51
53
|
},
|
|
52
54
|
finish: () => hits
|