@hailstails/hone 2.0.0-pre.2 → 2.0.0-pre.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADOPTING.md +7 -7
- package/CHANGELOG.md +76 -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 +10493 -10410
- 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 +953 -1189
- 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 +213 -126
- 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-MWLBA4B3.js +0 -849
- 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
|
@@ -2,35 +2,40 @@ import {
|
|
|
2
2
|
TYPE_DIRECTIVES,
|
|
3
3
|
directiveEscapesIn,
|
|
4
4
|
escapesOf
|
|
5
|
-
} from "../../../../../chunks/chunk-
|
|
5
|
+
} from "../../../../../chunks/chunk-MBEDAFVC.js";
|
|
6
6
|
import {
|
|
7
|
-
|
|
7
|
+
checkHitSchema,
|
|
8
8
|
runnerResultSchema
|
|
9
|
-
} from "../../../../../chunks/chunk-
|
|
10
|
-
import "../../../../../chunks/chunk-
|
|
9
|
+
} from "../../../../../chunks/chunk-PVSC4SE3.js";
|
|
10
|
+
import "../../../../../chunks/chunk-BRANVR7K.js";
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
} from "../../../../../chunks/chunk-
|
|
12
|
+
DEFAULT_TEST_FILES
|
|
13
|
+
} from "../../../../../chunks/chunk-D6645WPB.js";
|
|
14
|
+
import {
|
|
15
|
+
toolchainBoundNamedChecksRunner
|
|
16
|
+
} from "../../../../../chunks/chunk-FHVNKG5Q.js";
|
|
14
17
|
import {
|
|
15
18
|
createDefaultPackageLocationPort,
|
|
16
19
|
installRootOfRunnerEntry
|
|
17
|
-
} from "../../../../../chunks/chunk-
|
|
20
|
+
} from "../../../../../chunks/chunk-CXM5KBZX.js";
|
|
18
21
|
import "../../../../../chunks/chunk-Z6JHBNDS.js";
|
|
19
22
|
import {
|
|
20
23
|
createDefaultEntryKindPort,
|
|
21
24
|
createDefaultFileTextPort,
|
|
22
25
|
createDefaultModuleLoaderPort,
|
|
23
26
|
createDefaultPathPort,
|
|
27
|
+
createPathPort,
|
|
24
28
|
installFormOf,
|
|
25
29
|
isRepoPathText,
|
|
26
30
|
loadedPeer,
|
|
27
31
|
moduleExtensionOf,
|
|
28
32
|
moduleFileForm
|
|
29
|
-
} from "../../../../../chunks/chunk-
|
|
33
|
+
} from "../../../../../chunks/chunk-BKQ3K766.js";
|
|
30
34
|
import {
|
|
31
|
-
gatheredOutcomes
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
gatheredOutcomes
|
|
36
|
+
} from "../../../../../chunks/chunk-YONPKP3C.js";
|
|
37
|
+
import "../../../../../chunks/chunk-OO5KV7KN.js";
|
|
38
|
+
import "../../../../../chunks/chunk-RANIXNWY.js";
|
|
34
39
|
import "../../../../../chunks/chunk-DGOLOS5A.js";
|
|
35
40
|
|
|
36
41
|
// src/infrastructure/engines/walker/runner/create-walker-runner.ts
|
|
@@ -38,7 +43,7 @@ import { z as z4 } from "zod";
|
|
|
38
43
|
|
|
39
44
|
// src/infrastructure/engines/walker/runner/observe-walker-file.ts
|
|
40
45
|
import { z } from "zod";
|
|
41
|
-
var pieceHitsSchema = z.array(
|
|
46
|
+
var pieceHitsSchema = z.array(checkHitSchema.unwrap().omit({ file: true }).readonly());
|
|
42
47
|
var callSchema = z.function({ input: [z.unknown()], output: z.unknown() });
|
|
43
48
|
var functionSchema = () => z.custom().superRefine((candidate, refinement) => {
|
|
44
49
|
if (typeof candidate !== "function") {
|
|
@@ -62,7 +67,7 @@ var pieceInvalid = (request) => ({
|
|
|
62
67
|
outcome: "failed",
|
|
63
68
|
error: {
|
|
64
69
|
kind: "piece-invalid",
|
|
65
|
-
pieceRoot: request.piece.
|
|
70
|
+
pieceRoot: request.piece.bindings[0]?.pieceRoot ?? request.piece.modulePath,
|
|
66
71
|
detail: request.detail
|
|
67
72
|
}
|
|
68
73
|
});
|
|
@@ -199,13 +204,11 @@ var observeSource = (request) => {
|
|
|
199
204
|
};
|
|
200
205
|
var attributedHits = (request) => {
|
|
201
206
|
if (request.hits.some(
|
|
202
|
-
(hit) => !request.piece.
|
|
203
|
-
(clause) => sameClauseAddress({ left: hit.clause, right: clause.address }) === "same"
|
|
204
|
-
)
|
|
207
|
+
(hit) => !request.piece.bindings.some((binding) => hit.check === binding.address)
|
|
205
208
|
)) {
|
|
206
209
|
return pieceInvalid({
|
|
207
210
|
piece: request.piece,
|
|
208
|
-
detail: "the piece emitted a hit for a
|
|
211
|
+
detail: "the piece emitted a hit for a binding outside its selected bindings"
|
|
209
212
|
});
|
|
210
213
|
}
|
|
211
214
|
return { outcome: "ok", value: request.hits };
|
|
@@ -234,13 +237,13 @@ var completedFile = (request) => {
|
|
|
234
237
|
),
|
|
235
238
|
nativeExceptions: request.nativeExceptions,
|
|
236
239
|
applicable: request.active.flatMap(
|
|
237
|
-
(active) => active.piece.
|
|
240
|
+
(active) => active.piece.bindings.map((binding) => binding.address)
|
|
238
241
|
)
|
|
239
242
|
}
|
|
240
243
|
};
|
|
241
244
|
};
|
|
242
|
-
var
|
|
243
|
-
(active) => active.completion.kind === "syntax" ? active.piece.
|
|
245
|
+
var syntaxChecksOf = (request) => request.active.flatMap(
|
|
246
|
+
(active) => active.completion.kind === "syntax" ? active.piece.bindings.map((binding) => binding.address) : []
|
|
244
247
|
);
|
|
245
248
|
var observeWalkerFile = (request) => {
|
|
246
249
|
const cache = cachedFile(request);
|
|
@@ -286,7 +289,7 @@ var observeWalkerFile = (request) => {
|
|
|
286
289
|
comments: observed.value,
|
|
287
290
|
escapes: escapesOf({
|
|
288
291
|
escapes: request.escapes,
|
|
289
|
-
|
|
292
|
+
checks: syntaxChecksOf({ active: active.value })
|
|
290
293
|
}),
|
|
291
294
|
anchorAt: ({ position }) => anchorAt({ tree: parsed.value, position })
|
|
292
295
|
})
|
|
@@ -364,15 +367,23 @@ var pieceInvalid2 = (request) => ({
|
|
|
364
367
|
detail: request.detail
|
|
365
368
|
}
|
|
366
369
|
});
|
|
367
|
-
var
|
|
368
|
-
|
|
369
|
-
)
|
|
370
|
-
|
|
370
|
+
var groupsByImplementation = (request) => {
|
|
371
|
+
const groups = /* @__PURE__ */ new Map();
|
|
372
|
+
for (const selected of request.selected) {
|
|
373
|
+
const group = groups.get(selected.modulePath);
|
|
374
|
+
if (group === void 0) {
|
|
375
|
+
groups.set(selected.modulePath, { selected, bindings: [selected.binding] });
|
|
376
|
+
} else {
|
|
377
|
+
group.bindings.push(selected.binding);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return [...groups.values()];
|
|
381
|
+
};
|
|
371
382
|
var acceptedPreparation = (request) => {
|
|
372
383
|
const parsed = walkerPreparationResultSchema.safeParse(request.returned);
|
|
373
384
|
if (!parsed.success) {
|
|
374
385
|
return pieceInvalid2({
|
|
375
|
-
pieceRoot: request.selected.
|
|
386
|
+
pieceRoot: request.selected.binding.pieceRoot,
|
|
376
387
|
detail: parsed.error.message
|
|
377
388
|
});
|
|
378
389
|
}
|
|
@@ -383,7 +394,7 @@ var acceptedPreparation = (request) => {
|
|
|
383
394
|
outcome: "ok",
|
|
384
395
|
value: {
|
|
385
396
|
modulePath: request.selected.modulePath,
|
|
386
|
-
|
|
397
|
+
bindings: request.bindings,
|
|
387
398
|
check: parsed.data.value
|
|
388
399
|
}
|
|
389
400
|
};
|
|
@@ -391,44 +402,41 @@ var acceptedPreparation = (request) => {
|
|
|
391
402
|
var acceptedModule = (request) => {
|
|
392
403
|
if (request.loaded.outcome === "failed") {
|
|
393
404
|
return pieceInvalid2({
|
|
394
|
-
pieceRoot: request.selected.
|
|
405
|
+
pieceRoot: request.selected.binding.pieceRoot,
|
|
395
406
|
detail: request.loaded.error.detail
|
|
396
407
|
});
|
|
397
408
|
}
|
|
398
409
|
const parsed = registeredWalkerPieceModuleSchema.safeParse(request.loaded.value);
|
|
399
410
|
if (!parsed.success) {
|
|
400
411
|
return pieceInvalid2({
|
|
401
|
-
pieceRoot: request.selected.
|
|
412
|
+
pieceRoot: request.selected.binding.pieceRoot,
|
|
402
413
|
detail: parsed.error.message
|
|
403
414
|
});
|
|
404
415
|
}
|
|
405
416
|
try {
|
|
406
417
|
return acceptedPreparation({
|
|
407
418
|
returned: parsed.data.check.prepare({
|
|
408
|
-
|
|
419
|
+
bindings: request.bindings,
|
|
409
420
|
repository: request.repository,
|
|
410
421
|
syntaxApi: request.syntaxApi
|
|
411
422
|
}),
|
|
412
423
|
selected: request.selected,
|
|
413
|
-
|
|
424
|
+
bindings: request.bindings
|
|
414
425
|
});
|
|
415
426
|
} catch (thrown) {
|
|
416
427
|
return pieceInvalid2({
|
|
417
|
-
pieceRoot: request.selected.
|
|
428
|
+
pieceRoot: request.selected.binding.pieceRoot,
|
|
418
429
|
detail: thrown instanceof Error ? thrown.message : String(thrown)
|
|
419
430
|
});
|
|
420
431
|
}
|
|
421
432
|
};
|
|
422
433
|
var loadModule = (request) => {
|
|
423
|
-
const
|
|
424
|
-
|
|
425
|
-
modulePath: request.selected.modulePath
|
|
426
|
-
});
|
|
427
|
-
return request.preparation.modules.load({ path: request.selected.modulePath }).then(
|
|
434
|
+
const { selected, bindings } = request.group;
|
|
435
|
+
return request.preparation.modules.load({ path: selected.modulePath }).then(
|
|
428
436
|
(loaded) => acceptedModule({
|
|
429
437
|
loaded,
|
|
430
|
-
selected
|
|
431
|
-
|
|
438
|
+
selected,
|
|
439
|
+
bindings,
|
|
432
440
|
repository: request.preparation.repository,
|
|
433
441
|
syntaxApi: request.preparation.syntaxApi
|
|
434
442
|
})
|
|
@@ -447,20 +455,20 @@ var collectPreparations = (request) => request.preparations.reduce(
|
|
|
447
455
|
{ outcome: "ok", value: [] }
|
|
448
456
|
);
|
|
449
457
|
var prepareWalkerPieces = (request) => Promise.all(
|
|
450
|
-
|
|
458
|
+
groupsByImplementation(request).map((group) => loadModule({ group, preparation: request }))
|
|
451
459
|
).then((preparations) => collectPreparations({ preparations }));
|
|
452
460
|
|
|
453
461
|
// src/infrastructure/engines/walker/runner/create-walker-runner.ts
|
|
454
|
-
var finishedHitsSchema = runnerResultSchema({ value: z4.array(
|
|
462
|
+
var finishedHitsSchema = runnerResultSchema({ value: z4.array(checkHitSchema).readonly() });
|
|
455
463
|
var pieceInvalid3 = (request) => ({
|
|
456
464
|
outcome: "failed",
|
|
457
465
|
error: { kind: "piece-invalid", pieceRoot: request.pieceRoot, detail: request.detail }
|
|
458
466
|
});
|
|
459
467
|
var thrownDetail2 = (request) => request.thrown instanceof Error ? request.thrown.message : String(request.thrown);
|
|
460
|
-
var
|
|
461
|
-
const settings = walkerPieceSettingsSchema.safeParse(request.
|
|
468
|
+
var settledBinding = (request) => {
|
|
469
|
+
const settings = walkerPieceSettingsSchema.safeParse(request.binding.settings);
|
|
462
470
|
if (!settings.success) {
|
|
463
|
-
return pieceInvalid3({ pieceRoot: request.
|
|
471
|
+
return pieceInvalid3({ pieceRoot: request.binding.pieceRoot, detail: settings.error.message });
|
|
464
472
|
}
|
|
465
473
|
return {
|
|
466
474
|
outcome: "ok",
|
|
@@ -468,22 +476,22 @@ var settledClause = (request) => {
|
|
|
468
476
|
{
|
|
469
477
|
selected: [
|
|
470
478
|
{
|
|
471
|
-
|
|
479
|
+
binding: request.binding,
|
|
472
480
|
modulePath: request.path.join({
|
|
473
|
-
segments: [request.
|
|
481
|
+
segments: [request.binding.pieceRoot, settings.data.module]
|
|
474
482
|
})
|
|
475
483
|
}
|
|
476
484
|
],
|
|
477
485
|
escapes: [
|
|
478
|
-
{
|
|
486
|
+
{ check: request.binding.address, directives: settings.data.escapingDirectives ?? [] }
|
|
479
487
|
]
|
|
480
488
|
}
|
|
481
489
|
]
|
|
482
490
|
};
|
|
483
491
|
};
|
|
484
|
-
var
|
|
492
|
+
var settledBindings = (request) => {
|
|
485
493
|
const settled = gatheredOutcomes({
|
|
486
|
-
outcomes: request.
|
|
494
|
+
outcomes: request.bindings.map((binding) => settledBinding({ binding, path: request.path }))
|
|
487
495
|
});
|
|
488
496
|
if (settled.outcome === "failed") return settled;
|
|
489
497
|
return {
|
|
@@ -495,7 +503,7 @@ var settledClauses = (request) => {
|
|
|
495
503
|
};
|
|
496
504
|
};
|
|
497
505
|
var preparedPieces = (request) => {
|
|
498
|
-
const settled =
|
|
506
|
+
const settled = settledBindings({ bindings: request.bindings, path: request.ports.path });
|
|
499
507
|
if (settled.outcome === "failed") return Promise.resolve(settled);
|
|
500
508
|
return prepareWalkerPieces({
|
|
501
509
|
selected: settled.value.selected,
|
|
@@ -506,11 +514,9 @@ var preparedPieces = (request) => {
|
|
|
506
514
|
(pieces) => pieces.outcome === "failed" ? pieces : { outcome: "ok", value: { pieces: pieces.value, escapes: settled.value.escapes } }
|
|
507
515
|
);
|
|
508
516
|
};
|
|
509
|
-
var
|
|
510
|
-
(clause) => sameClauseAddress({ left: clause.address, right: request.hit.clause }) === "same"
|
|
511
|
-
);
|
|
517
|
+
var checkRank = (request) => request.bindings.findIndex((binding) => binding.address === request.hit.check);
|
|
512
518
|
var inSourceOrder = (request) => [...request.hits].sort(
|
|
513
|
-
(left, right) => left.anchor.line - right.anchor.line || left.anchor.column - right.anchor.column ||
|
|
519
|
+
(left, right) => left.anchor.line - right.anchor.line || left.anchor.column - right.anchor.column || checkRank({ bindings: request.bindings, hit: left }) - checkRank({ bindings: request.bindings, hit: right })
|
|
514
520
|
);
|
|
515
521
|
var observedReport = (request) => {
|
|
516
522
|
const observed = observeWalkerFile({
|
|
@@ -524,10 +530,10 @@ var observedReport = (request) => {
|
|
|
524
530
|
outcome: "ok",
|
|
525
531
|
value: [
|
|
526
532
|
{
|
|
527
|
-
hits: inSourceOrder({
|
|
533
|
+
hits: inSourceOrder({ bindings: request.bindings, hits: observed.value.hits }),
|
|
528
534
|
nativeExceptions: observed.value.nativeExceptions,
|
|
529
|
-
measured: observed.value.applicable.map((
|
|
530
|
-
|
|
535
|
+
measured: observed.value.applicable.map((check) => ({
|
|
536
|
+
check,
|
|
531
537
|
file: request.file.file
|
|
532
538
|
}))
|
|
533
539
|
}
|
|
@@ -535,7 +541,7 @@ var observedReport = (request) => {
|
|
|
535
541
|
};
|
|
536
542
|
};
|
|
537
543
|
var finishedPiece = (request) => {
|
|
538
|
-
const pieceRoot = request.piece.
|
|
544
|
+
const pieceRoot = request.piece.bindings[0]?.pieceRoot ?? request.piece.modulePath;
|
|
539
545
|
try {
|
|
540
546
|
const parsed = finishedHitsSchema.safeParse(request.piece.check.finish());
|
|
541
547
|
if (!parsed.success) return pieceInvalid3({ pieceRoot, detail: parsed.error.message });
|
|
@@ -591,15 +597,16 @@ var runOverRepository = (request) => {
|
|
|
591
597
|
root: request.run.repoRoot,
|
|
592
598
|
entryKind: request.ports.entryKind,
|
|
593
599
|
fileText: request.ports.fileText
|
|
594
|
-
})
|
|
600
|
+
}),
|
|
601
|
+
testFiles: request.run.testFiles
|
|
595
602
|
};
|
|
596
|
-
return preparedPieces({ ports: request.ports,
|
|
603
|
+
return preparedPieces({ ports: request.ports, bindings: request.run.bindings, repository }).then(
|
|
597
604
|
(prepared) => {
|
|
598
605
|
if (prepared.outcome === "failed") return prepared;
|
|
599
606
|
return walkedReport({
|
|
600
607
|
ports: request.ports,
|
|
601
608
|
prepared: prepared.value,
|
|
602
|
-
|
|
609
|
+
bindings: request.run.bindings,
|
|
603
610
|
files: request.run.trackedPaths.map(
|
|
604
611
|
(file) => repositoryFile({ ports: request.ports, repoRoot: request.run.repoRoot, file })
|
|
605
612
|
)
|
|
@@ -618,15 +625,16 @@ var caseVerdict = (request) => {
|
|
|
618
625
|
disk: textsDisk({
|
|
619
626
|
root: CASE_ROOT,
|
|
620
627
|
texts: { [request.sourceCase.fileName]: request.sourceCase.source }
|
|
621
|
-
})
|
|
628
|
+
}),
|
|
629
|
+
testFiles: DEFAULT_TEST_FILES
|
|
622
630
|
};
|
|
623
|
-
return preparedPieces({ ports: request.ports,
|
|
631
|
+
return preparedPieces({ ports: request.ports, bindings: [request.binding], repository }).then(
|
|
624
632
|
(prepared) => {
|
|
625
633
|
if (prepared.outcome === "failed") return prepared;
|
|
626
634
|
const report = walkedReport({
|
|
627
635
|
ports: request.ports,
|
|
628
636
|
prepared: prepared.value,
|
|
629
|
-
|
|
637
|
+
bindings: [request.binding],
|
|
630
638
|
files: [caseFile(request)]
|
|
631
639
|
});
|
|
632
640
|
if (report.outcome === "failed") return report;
|
|
@@ -644,17 +652,185 @@ var caseVerdict = (request) => {
|
|
|
644
652
|
};
|
|
645
653
|
var conformCases = (request) => request.cases.reduce(
|
|
646
654
|
(pending, sourceCase) => pending.then(
|
|
647
|
-
(collected) => collected.outcome === "failed" ? collected : caseVerdict({ ports: request.ports,
|
|
655
|
+
(collected) => collected.outcome === "failed" ? collected : caseVerdict({ ports: request.ports, binding: request.binding, sourceCase }).then(
|
|
648
656
|
(next) => gatheredOutcomes({ outcomes: [collected, next] })
|
|
649
657
|
)
|
|
650
658
|
),
|
|
651
659
|
Promise.resolve({ outcome: "ok", value: [] })
|
|
652
660
|
);
|
|
653
661
|
var createWalkerRunner = (ports) => ({
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
662
|
+
run: async (request) => {
|
|
663
|
+
const walked = await runOverRepository({ ports, run: request });
|
|
664
|
+
return walked.outcome === "failed" ? walked : {
|
|
665
|
+
outcome: "ok",
|
|
666
|
+
value: {
|
|
667
|
+
...walked.value,
|
|
668
|
+
projection: "none",
|
|
669
|
+
slices: [],
|
|
670
|
+
misnamedRuleIds: [],
|
|
671
|
+
nestedConfigurations: [],
|
|
672
|
+
unprojectedFolders: []
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
},
|
|
676
|
+
conform: (request) => conformCases({ ports, binding: request.binding, cases: request.cases }),
|
|
677
|
+
project: () => Promise.resolve({ outcome: "ok", value: [] })
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
// src/infrastructure/engines/walker/runner/moved-imports.ts
|
|
681
|
+
var SCRIPT_FILE = /\.[cm]?[jt]sx?$/;
|
|
682
|
+
var RELATIVE_SPECIFIER = /^\.\.?(\/|$)/;
|
|
683
|
+
var PARENT_SPECIFIER = /^\.\.(\/|$)/;
|
|
684
|
+
var MOCKING_RECEIVERS = /* @__PURE__ */ new Set(["vi", "jest"]);
|
|
685
|
+
var MOCKING_METHODS = /* @__PURE__ */ new Set([
|
|
686
|
+
"mock",
|
|
687
|
+
"doMock",
|
|
688
|
+
"unmock",
|
|
689
|
+
"importActual",
|
|
690
|
+
"importMock",
|
|
691
|
+
"requireActual"
|
|
692
|
+
]);
|
|
693
|
+
var REQUIRE = "require";
|
|
694
|
+
var ANCHOR = "/";
|
|
695
|
+
var CURRENT_FOLDER = ".";
|
|
696
|
+
var PARENT_FOLDER = "..";
|
|
697
|
+
var RESOLVED_EXTENSIONS = [".ts", ".tsx", ".d.ts", ".js", ".jsx"];
|
|
698
|
+
var SOURCE_FOR_EMITTED = [
|
|
699
|
+
{ written: ".js", onDisk: ".ts" },
|
|
700
|
+
{ written: ".js", onDisk: ".tsx" },
|
|
701
|
+
{ written: ".mjs", onDisk: ".mts" },
|
|
702
|
+
{ written: ".cjs", onDisk: ".cts" },
|
|
703
|
+
{ written: ".jsx", onDisk: ".tsx" }
|
|
704
|
+
];
|
|
705
|
+
var RESOLUTION_CANDIDATES = [
|
|
706
|
+
{ written: "", onDisk: "" },
|
|
707
|
+
...RESOLVED_EXTENSIONS.flatMap((extension) => [
|
|
708
|
+
{ written: "", onDisk: extension },
|
|
709
|
+
{ written: "", onDisk: `/index${extension}` }
|
|
710
|
+
]),
|
|
711
|
+
...SOURCE_FOR_EMITTED
|
|
712
|
+
];
|
|
713
|
+
var QUOTE_LENGTH = 1;
|
|
714
|
+
var importCallOf = (request) => request.syntaxApi.isCallExpression(request.node) && request.node.expression.kind === request.syntaxApi.SyntaxKind.ImportKeyword ? request.node : void 0;
|
|
715
|
+
var callSpecifierOf = (request) => {
|
|
716
|
+
const { syntaxApi, node } = request;
|
|
717
|
+
if (!syntaxApi.isCallExpression(node)) return void 0;
|
|
718
|
+
const callee = node.expression;
|
|
719
|
+
const [first] = node.arguments;
|
|
720
|
+
if (first !== void 0 && importCallOf({ syntaxApi, node: first }) !== void 0)
|
|
721
|
+
return void 0;
|
|
722
|
+
const named = importCallOf(request) !== void 0 || syntaxApi.isIdentifier(callee) && callee.text === REQUIRE || syntaxApi.isPropertyAccessExpression(callee) && syntaxApi.isIdentifier(callee.expression) && MOCKING_RECEIVERS.has(callee.expression.text) && MOCKING_METHODS.has(callee.name.text);
|
|
723
|
+
return named ? first ?? node : void 0;
|
|
724
|
+
};
|
|
725
|
+
var specifierNodeOf = (request) => {
|
|
726
|
+
const { syntaxApi, node } = request;
|
|
727
|
+
if (syntaxApi.isImportDeclaration(node)) return node.moduleSpecifier;
|
|
728
|
+
if (syntaxApi.isExportDeclaration(node)) return node.moduleSpecifier;
|
|
729
|
+
if (syntaxApi.isImportEqualsDeclaration(node) && syntaxApi.isExternalModuleReference(node.moduleReference)) {
|
|
730
|
+
return node.moduleReference.expression;
|
|
731
|
+
}
|
|
732
|
+
if (syntaxApi.isImportTypeNode(node)) {
|
|
733
|
+
return syntaxApi.isLiteralTypeNode(node.argument) ? node.argument.literal : node.argument;
|
|
734
|
+
}
|
|
735
|
+
return callSpecifierOf(request);
|
|
736
|
+
};
|
|
737
|
+
var siteOf = (request) => {
|
|
738
|
+
const specifier = specifierNodeOf(request);
|
|
739
|
+
if (specifier === void 0) return [];
|
|
740
|
+
return request.syntaxApi.isStringLiteralLike(specifier) ? [{ site: "literal", node: specifier, text: specifier.text }] : [{ site: "computed", node: specifier }];
|
|
741
|
+
};
|
|
742
|
+
var sitesOf = (request) => [
|
|
743
|
+
...siteOf({ syntaxApi: request.parse.syntaxApi, node: request.node }),
|
|
744
|
+
...request.parse.children({ node: request.node }).flatMap((child) => sitesOf({ parse: request.parse, node: child }))
|
|
745
|
+
];
|
|
746
|
+
var anchored = (path) => `${ANCHOR}${path}`;
|
|
747
|
+
var TRAILING_SEPARATORS = /\/+$/;
|
|
748
|
+
var unanchored = (path) => path.slice(ANCHOR.length).replace(TRAILING_SEPARATORS, "");
|
|
749
|
+
var targetFormOf = (request) => {
|
|
750
|
+
const [form] = RESOLUTION_CANDIDATES.filter(
|
|
751
|
+
({ written }) => request.target.endsWith(written)
|
|
752
|
+
).flatMap((candidate) => {
|
|
753
|
+
const path = `${request.target.slice(0, request.target.length - candidate.written.length)}${candidate.onDisk}`;
|
|
754
|
+
return [...request.moved.keys()].filter((key) => key === path).map((found) => ({ found, candidate }));
|
|
755
|
+
});
|
|
756
|
+
return form;
|
|
757
|
+
};
|
|
758
|
+
var writtenTargetOf = (request) => `${request.to.slice(0, request.to.length - request.candidate.onDisk.length)}${request.candidate.written}`;
|
|
759
|
+
var segmentsOf = (path) => path.split(ANCHOR).filter((segment) => segment !== "");
|
|
760
|
+
var relativeBetween = (request) => {
|
|
761
|
+
const from = segmentsOf(request.from);
|
|
762
|
+
const to = segmentsOf(request.to);
|
|
763
|
+
const diverging = from.findIndex((segment, index) => to[index] !== segment);
|
|
764
|
+
const shared = diverging === -1 ? from.length : diverging;
|
|
765
|
+
return [...from.slice(shared).map(() => PARENT_FOLDER), ...to.slice(shared)].join(ANCHOR);
|
|
766
|
+
};
|
|
767
|
+
var specifierTextOf = (relative) => {
|
|
768
|
+
if (relative === "") return CURRENT_FOLDER;
|
|
769
|
+
return PARENT_SPECIFIER.test(relative) ? relative : `${CURRENT_FOLDER}${ANCHOR}${relative}`;
|
|
770
|
+
};
|
|
771
|
+
var lineOf = (request) => request.tree.getLineAndCharacterOfPosition(request.node.getStart(request.tree)).line + 1;
|
|
772
|
+
var refusedAt = (request) => ({
|
|
773
|
+
outcome: "failed",
|
|
774
|
+
error: { reason: request.reason, line: lineOf(request) }
|
|
657
775
|
});
|
|
776
|
+
var destinationOf = (request) => {
|
|
777
|
+
const form = targetFormOf(request);
|
|
778
|
+
const to = form === void 0 ? void 0 : request.moved.get(form.found);
|
|
779
|
+
if (form !== void 0 && to !== void 0) {
|
|
780
|
+
return writtenTargetOf({ to, candidate: form.candidate });
|
|
781
|
+
}
|
|
782
|
+
const inFolder = request.target === request.folder || request.target.startsWith(`${request.folder}${ANCHOR}`);
|
|
783
|
+
return inFolder ? "not-moved" : request.target;
|
|
784
|
+
};
|
|
785
|
+
var rewriteOf = (request) => {
|
|
786
|
+
const { path, tree, site } = request;
|
|
787
|
+
if (site.site === "computed") {
|
|
788
|
+
return refusedAt({ tree, node: site.node, reason: "specifier-not-literal" });
|
|
789
|
+
}
|
|
790
|
+
if (!RELATIVE_SPECIFIER.test(site.text)) return { outcome: "ok", value: [] };
|
|
791
|
+
const target = unanchored(
|
|
792
|
+
path.join({ segments: [path.directoryOf({ path: anchored(request.file) }), site.text] })
|
|
793
|
+
);
|
|
794
|
+
const destination = destinationOf({ ...request, target });
|
|
795
|
+
if (destination === "not-moved") {
|
|
796
|
+
return refusedAt({ tree, node: site.node, reason: "target-not-moved" });
|
|
797
|
+
}
|
|
798
|
+
return {
|
|
799
|
+
outcome: "ok",
|
|
800
|
+
value: [
|
|
801
|
+
{
|
|
802
|
+
start: site.node.getStart(tree) + QUOTE_LENGTH,
|
|
803
|
+
end: site.node.getEnd() - QUOTE_LENGTH,
|
|
804
|
+
text: specifierTextOf(
|
|
805
|
+
relativeBetween({
|
|
806
|
+
from: path.directoryOf({ path: anchored(request.movedTo) }),
|
|
807
|
+
to: destination
|
|
808
|
+
})
|
|
809
|
+
)
|
|
810
|
+
}
|
|
811
|
+
]
|
|
812
|
+
};
|
|
813
|
+
};
|
|
814
|
+
var rewrittenText = (request) => request.rewrites.reduceRight(
|
|
815
|
+
(text, rewrite) => `${text.slice(0, rewrite.start)}${rewrite.text}${text.slice(rewrite.end)}`,
|
|
816
|
+
request.text
|
|
817
|
+
);
|
|
818
|
+
var createImportsRewrittenOf = (options) => (request) => {
|
|
819
|
+
if (!SCRIPT_FILE.test(request.file)) return { outcome: "ok", value: request.text };
|
|
820
|
+
const tree = options.parse.parse({ fileName: request.file, source: request.text });
|
|
821
|
+
const rewrites = sitesOf({ parse: options.parse, node: tree }).map(
|
|
822
|
+
(site) => rewriteOf({ ...request, path: options.path, tree, site })
|
|
823
|
+
);
|
|
824
|
+
const refused = rewrites.find((rewrite) => rewrite.outcome === "failed");
|
|
825
|
+
if (refused?.outcome === "failed") return refused;
|
|
826
|
+
return {
|
|
827
|
+
outcome: "ok",
|
|
828
|
+
value: rewrittenText({
|
|
829
|
+
text: request.text,
|
|
830
|
+
rewrites: rewrites.flatMap((rewrite) => rewrite.outcome === "ok" ? rewrite.value : []).toSorted((left, right) => left.start - right.start)
|
|
831
|
+
})
|
|
832
|
+
};
|
|
833
|
+
};
|
|
658
834
|
|
|
659
835
|
// src/infrastructure/engines/walker/runner/toolchain/typescript-toolchain.ts
|
|
660
836
|
import { z as z5 } from "zod";
|
|
@@ -706,15 +882,18 @@ var loadParsePort = (request) => loadedPeer({
|
|
|
706
882
|
);
|
|
707
883
|
|
|
708
884
|
// src/infrastructure/engines/walker/runner/runner.ts
|
|
709
|
-
var
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
moduleExtension: moduleExtensionOf({ moduleUrl: import.meta.url })
|
|
715
|
-
})
|
|
885
|
+
var parsePort = loadParsePort({
|
|
886
|
+
peers: defaultTypeScriptPeers({
|
|
887
|
+
installRoot: installRootOfRunnerEntry({ entryFile: import.meta.filename }),
|
|
888
|
+
installForm: installFormOf({
|
|
889
|
+
moduleExtension: moduleExtensionOf({ moduleUrl: import.meta.url })
|
|
716
890
|
})
|
|
717
|
-
})
|
|
891
|
+
})
|
|
892
|
+
});
|
|
893
|
+
var namedChecksRunner = toolchainBoundNamedChecksRunner({
|
|
894
|
+
fileScope: "tracked",
|
|
895
|
+
toolchain: parsePort,
|
|
896
|
+
projectedKinds: ["inline-disable"],
|
|
718
897
|
runnerOf: (parse) => createWalkerRunner({
|
|
719
898
|
fileText: createDefaultFileTextPort({}),
|
|
720
899
|
modules: createDefaultModuleLoaderPort({}),
|
|
@@ -723,6 +902,16 @@ var runner = toolchainBoundStandaloneRunner({
|
|
|
723
902
|
entryKind: createDefaultEntryKindPort({})
|
|
724
903
|
})
|
|
725
904
|
});
|
|
905
|
+
var importsRewriterOf = () => parsePort.then(
|
|
906
|
+
(parse) => parse.outcome === "failed" ? parse : {
|
|
907
|
+
outcome: "ok",
|
|
908
|
+
value: createImportsRewrittenOf({
|
|
909
|
+
path: createPathPort({ flavour: "posix", workingDirectory: () => "/" }),
|
|
910
|
+
parse: parse.value
|
|
911
|
+
})
|
|
912
|
+
}
|
|
913
|
+
);
|
|
726
914
|
export {
|
|
727
|
-
|
|
915
|
+
importsRewriterOf,
|
|
916
|
+
namedChecksRunner
|
|
728
917
|
};
|
|
@@ -2,9 +2,12 @@ import type typescript from "typescript";
|
|
|
2
2
|
export type SyntaxApi = typeof typescript;
|
|
3
3
|
export type SyntaxTree = typescript.SourceFile;
|
|
4
4
|
export type SyntaxNode = typescript.Node;
|
|
5
|
+
export type TypeChecker = typescript.TypeChecker;
|
|
5
6
|
export type CommentRange = typescript.CommentRange;
|
|
6
7
|
export type Statement = typescript.Statement;
|
|
8
|
+
export type Identifier = typescript.Identifier;
|
|
7
9
|
export type ImportDeclaration = typescript.ImportDeclaration;
|
|
10
|
+
export type ImportSpecifier = typescript.ImportSpecifier;
|
|
8
11
|
export type CallExpression = typescript.CallExpression;
|
|
9
12
|
export type PropertyAccessExpression = typescript.PropertyAccessExpression;
|
|
10
13
|
export type ExportDeclaration = typescript.ExportDeclaration;
|
package/src/infrastructure/engines/walker/shorthand-name/identifier-names/identifier-names.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sourceSnippetAt
|
|
3
|
+
} from "../../../../../../chunks/chunk-5AKHEW6V.js";
|
|
1
4
|
import {
|
|
2
5
|
folderScope
|
|
3
|
-
} from "../../../../../../chunks/chunk-
|
|
6
|
+
} from "../../../../../../chunks/chunk-COQMPHWZ.js";
|
|
4
7
|
import "../../../../../../chunks/chunk-DGOLOS5A.js";
|
|
5
8
|
|
|
6
9
|
// src/infrastructure/engines/walker/shorthand-name/identifier-names/identifier-names.ts
|
|
@@ -9,7 +12,6 @@ var sourceEligibility = (request) => {
|
|
|
9
12
|
if (folderScope({ file: request.file }) === "generated") return "excluded";
|
|
10
13
|
return "eligible";
|
|
11
14
|
};
|
|
12
|
-
var SNIPPET_MAX_LENGTH = 80;
|
|
13
15
|
var BANNED_SHORTHAND_NAMES = [
|
|
14
16
|
"c",
|
|
15
17
|
"op",
|
|
@@ -63,7 +65,7 @@ var classifyName = (request) => {
|
|
|
63
65
|
return "ok";
|
|
64
66
|
};
|
|
65
67
|
var check = {
|
|
66
|
-
prepare: ({
|
|
68
|
+
prepare: ({ bindings, syntaxApi }) => ({
|
|
67
69
|
outcome: "ok",
|
|
68
70
|
value: {
|
|
69
71
|
prepareFile: ({ file }) => {
|
|
@@ -81,15 +83,18 @@ var check = {
|
|
|
81
83
|
const recordName = (request) => {
|
|
82
84
|
if (request.name.startsWith("_")) return;
|
|
83
85
|
if (classifyName(request) === "ok") return;
|
|
84
|
-
const snippet =
|
|
86
|
+
const snippet = sourceSnippetAt({
|
|
87
|
+
source: sourceFile.text,
|
|
88
|
+
position: request.position
|
|
89
|
+
});
|
|
85
90
|
const anchor = anchorAt({ position: request.position });
|
|
86
91
|
hits.push(
|
|
87
|
-
...
|
|
92
|
+
...bindings.map((binding) => ({
|
|
88
93
|
owner: request.owner,
|
|
89
94
|
hit: {
|
|
90
|
-
|
|
95
|
+
check: binding.address,
|
|
91
96
|
anchor,
|
|
92
|
-
snippet
|
|
97
|
+
snippet
|
|
93
98
|
}
|
|
94
99
|
}))
|
|
95
100
|
);
|