@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,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
|
package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/raw-read.examples.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"flag": [
|
|
3
|
+
{
|
|
4
|
+
"name": "file read with an embedded path",
|
|
5
|
+
"fileName": "src/order.test.ts",
|
|
6
|
+
"source": "readFileSync(join(dir, \"README.md\"), \"utf8\");",
|
|
7
|
+
"expectedLines": [1]
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "raw imports and globs",
|
|
11
|
+
"fileName": "src/order.test.ts",
|
|
12
|
+
"source": "import body from \"./order.ts?raw\";\nawait import(\"./guide.mdx?raw\");\nimport.meta.glob(\"./**/*.{ts,md}\", { query: \"?raw\" });",
|
|
13
|
+
"expectedLines": [1, 2, 3]
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"allow": [
|
|
17
|
+
{
|
|
18
|
+
"name": "ordinary file or module data",
|
|
19
|
+
"fileName": "src/order.test.ts",
|
|
20
|
+
"source": "readFileSync(\"./order.json\", \"utf8\");\nawait import(\"./order.ts\");\nimport.meta.glob(\"./*.ts\", { eager: true });",
|
|
21
|
+
"expectedLines": []
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "file reading in a production module",
|
|
25
|
+
"fileName": "src/order.ts",
|
|
26
|
+
"source": "readFileSync(\"./README.md\", \"utf8\");",
|
|
27
|
+
"expectedLines": []
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
syntaxNodeCheck
|
|
3
|
+
} from "../../../../../../chunks/chunk-LEFM7OPS.js";
|
|
4
|
+
import {
|
|
5
|
+
withoutParentheses
|
|
6
|
+
} from "../../../../../../chunks/chunk-EBX57Z3V.js";
|
|
7
|
+
import {
|
|
8
|
+
sourceBindingsPerFile
|
|
9
|
+
} from "../../../../../../chunks/chunk-75XWZYNN.js";
|
|
10
|
+
import "../../../../../../chunks/chunk-5AKHEW6V.js";
|
|
11
|
+
import {
|
|
12
|
+
testFileEligibility
|
|
13
|
+
} from "../../../../../../chunks/chunk-COQMPHWZ.js";
|
|
14
|
+
import "../../../../../../chunks/chunk-DGOLOS5A.js";
|
|
15
|
+
|
|
16
|
+
// src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/raw-read.ts
|
|
17
|
+
var TEXT_TYPES = /* @__PURE__ */ new Set(["ts", "tsx", "mts", "cts", "md", "mdx"]);
|
|
18
|
+
var PATH_BUILDERS = /* @__PURE__ */ new Set(["join", "resolve", "normalize", "fileURLToPath"]);
|
|
19
|
+
var FILE_READS = /* @__PURE__ */ new Set(["readFile", "readFileSync"]);
|
|
20
|
+
var FILE_SYSTEM_MODULES = /* @__PURE__ */ new Set(["fs", "fs/promises", "node:fs", "node:fs/promises"]);
|
|
21
|
+
var AMBIENT_FILE_SYSTEM_NAMES = /* @__PURE__ */ new Map([
|
|
22
|
+
["fs", ["module"]],
|
|
23
|
+
["readFile", ["readFile"]],
|
|
24
|
+
["readFileSync", ["readFileSync"]]
|
|
25
|
+
]);
|
|
26
|
+
var literalIn = ({ syntaxApi, node, accepts }) => {
|
|
27
|
+
if (syntaxApi.isStringLiteralLike(node)) return accepts(node.text) ? node : void 0;
|
|
28
|
+
if (!syntaxApi.isTemplateExpression(node)) return void 0;
|
|
29
|
+
const tail = node.templateSpans.at(-1)?.literal.text;
|
|
30
|
+
return tail !== void 0 && accepts(tail) ? node : void 0;
|
|
31
|
+
};
|
|
32
|
+
var textPath = (path) => {
|
|
33
|
+
const extension = /\.([^./?]+)$/u.exec(path)?.[1];
|
|
34
|
+
return extension !== void 0 && TEXT_TYPES.has(extension.toLowerCase());
|
|
35
|
+
};
|
|
36
|
+
var textGlob = (path) => {
|
|
37
|
+
if (path.startsWith("!")) return false;
|
|
38
|
+
const alternatives = /\.\{([^}]+)\}$/u.exec(path)?.[1];
|
|
39
|
+
return textPath(path) || (alternatives?.split(",").some((extension) => TEXT_TYPES.has(extension.toLowerCase())) ?? false);
|
|
40
|
+
};
|
|
41
|
+
var rawQuery = (query) => query.replace(/^\?/u, "").split("&").includes("raw");
|
|
42
|
+
var rawModule = (path) => {
|
|
43
|
+
const queryStart = path.indexOf("?");
|
|
44
|
+
return queryStart >= 0 && textPath(path.slice(0, queryStart)) && rawQuery(path.slice(queryStart));
|
|
45
|
+
};
|
|
46
|
+
var memberNameOf = ({ syntaxApi, node }) => {
|
|
47
|
+
if (syntaxApi.isIdentifier(node) || syntaxApi.isStringLiteralLike(node)) return node.text;
|
|
48
|
+
return syntaxApi.isPropertyAccessExpression(node) ? node.name.text : void 0;
|
|
49
|
+
};
|
|
50
|
+
var rawOptions = ({ syntaxApi, node }) => syntaxApi.isObjectLiteralExpression(node) && node.properties.some((property) => {
|
|
51
|
+
if (!syntaxApi.isPropertyAssignment(property)) return false;
|
|
52
|
+
const name = memberNameOf({ syntaxApi, node: property.name });
|
|
53
|
+
if (name === "query")
|
|
54
|
+
return syntaxApi.isStringLiteralLike(property.initializer) && rawQuery(property.initializer.text);
|
|
55
|
+
return name === "as" && syntaxApi.isStringLiteralLike(property.initializer) && property.initializer.text === "raw";
|
|
56
|
+
});
|
|
57
|
+
var filePathOf = (request) => {
|
|
58
|
+
const { syntaxApi } = request;
|
|
59
|
+
const node = withoutParentheses(request);
|
|
60
|
+
if (syntaxApi.isAsExpression(node) || syntaxApi.isTypeAssertionExpression(node) || syntaxApi.isNonNullExpression(node))
|
|
61
|
+
return filePathOf({ syntaxApi, node: node.expression });
|
|
62
|
+
const literal = literalIn({ syntaxApi, node, accepts: textPath });
|
|
63
|
+
if (literal !== void 0) return literal;
|
|
64
|
+
if (syntaxApi.isNewExpression(node) && syntaxApi.isIdentifier(node.expression) && node.expression.text === "URL") {
|
|
65
|
+
const path2 = node.arguments?.[0];
|
|
66
|
+
return path2 === void 0 ? void 0 : filePathOf({ syntaxApi, node: path2 });
|
|
67
|
+
}
|
|
68
|
+
if (!syntaxApi.isCallExpression(node)) return void 0;
|
|
69
|
+
const builder = memberNameOf({ syntaxApi, node: node.expression });
|
|
70
|
+
if (builder === void 0 || !PATH_BUILDERS.has(builder)) return void 0;
|
|
71
|
+
const path = builder === "join" || builder === "resolve" ? node.arguments.at(-1) : node.arguments[0];
|
|
72
|
+
return path === void 0 ? void 0 : filePathOf({ syntaxApi, node: path });
|
|
73
|
+
};
|
|
74
|
+
var fileSystemImportNameOf = ({ syntaxApi, node }) => {
|
|
75
|
+
if (syntaxApi.isImportSpecifier(node) && node.isTypeOnly) return void 0;
|
|
76
|
+
const binding = syntaxApi.isImportSpecifier(node) ? node.parent : node;
|
|
77
|
+
const clause = syntaxApi.isNamedImports(binding) || syntaxApi.isNamespaceImport(binding) ? binding.parent : binding;
|
|
78
|
+
if (!syntaxApi.isImportClause(clause) || clause.isTypeOnly) return void 0;
|
|
79
|
+
const declaration = clause.parent;
|
|
80
|
+
if (!syntaxApi.isImportDeclaration(declaration)) return void 0;
|
|
81
|
+
const module = declaration.moduleSpecifier;
|
|
82
|
+
if (!syntaxApi.isStringLiteral(module) || !FILE_SYSTEM_MODULES.has(module.text)) return void 0;
|
|
83
|
+
return syntaxApi.isImportSpecifier(node) ? (node.propertyName ?? node.name).text : "module";
|
|
84
|
+
};
|
|
85
|
+
var fileSystemImportsOf = ({ syntaxApi, node }) => node.getSourceFile().statements.filter(
|
|
86
|
+
(statement) => syntaxApi.isImportDeclaration(statement) && syntaxApi.isStringLiteral(statement.moduleSpecifier) && FILE_SYSTEM_MODULES.has(statement.moduleSpecifier.text)
|
|
87
|
+
);
|
|
88
|
+
var fileSystemNamesOf = (request) => {
|
|
89
|
+
const { syntaxApi, node, bindingsOf } = request;
|
|
90
|
+
const ambient = AMBIENT_FILE_SYSTEM_NAMES.get(node.text) ?? [];
|
|
91
|
+
if (ambient.length === 0 && fileSystemImportsOf(request).length === 0) return [];
|
|
92
|
+
const declarations = bindingsOf().getSymbolAtLocation(node)?.declarations ?? [];
|
|
93
|
+
if (declarations.length === 0) return ambient;
|
|
94
|
+
return declarations.flatMap(
|
|
95
|
+
(declaration) => fileSystemImportNameOf({ syntaxApi, node: declaration }) ?? []
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
var identifierPartOf = (request) => {
|
|
99
|
+
const names = fileSystemNamesOf(request);
|
|
100
|
+
if (names.includes("module")) return "module";
|
|
101
|
+
return names.includes("promises") ? "promises" : "other";
|
|
102
|
+
};
|
|
103
|
+
var requiredModuleOf = ({ syntaxApi, node }) => {
|
|
104
|
+
if (!syntaxApi.isCallExpression(node) || !syntaxApi.isIdentifier(node.expression) || node.expression.text !== "require")
|
|
105
|
+
return void 0;
|
|
106
|
+
const [module] = node.arguments;
|
|
107
|
+
return module !== void 0 && syntaxApi.isStringLiteral(module) ? module.text : void 0;
|
|
108
|
+
};
|
|
109
|
+
var fileSystemPartOf = (request) => {
|
|
110
|
+
const { syntaxApi } = request;
|
|
111
|
+
const node = withoutParentheses(request);
|
|
112
|
+
if (syntaxApi.isIdentifier(node)) return identifierPartOf({ ...request, node });
|
|
113
|
+
if (syntaxApi.isPropertyAccessExpression(node) && node.name.text === "promises")
|
|
114
|
+
return fileSystemPartOf({ ...request, node: node.expression }) === "module" ? "promises" : "other";
|
|
115
|
+
const required = requiredModuleOf({ syntaxApi, node });
|
|
116
|
+
return required !== void 0 && FILE_SYSTEM_MODULES.has(required) ? "module" : "other";
|
|
117
|
+
};
|
|
118
|
+
var fileReadCallee = (request) => {
|
|
119
|
+
const { syntaxApi, node } = request;
|
|
120
|
+
if (syntaxApi.isIdentifier(node))
|
|
121
|
+
return fileSystemNamesOf({ ...request, node }).some((name) => FILE_READS.has(name)) ? node : void 0;
|
|
122
|
+
if (!syntaxApi.isPropertyAccessExpression(node) || !FILE_READS.has(node.name.text))
|
|
123
|
+
return void 0;
|
|
124
|
+
return fileSystemPartOf({ ...request, node: node.expression }) === "other" ? void 0 : node;
|
|
125
|
+
};
|
|
126
|
+
var rawGlobPathOf = (request) => {
|
|
127
|
+
const { syntaxApi, node } = request;
|
|
128
|
+
if (!syntaxApi.isCallExpression(node)) return void 0;
|
|
129
|
+
const { expression, arguments: callArguments } = node;
|
|
130
|
+
if (syntaxApi.isPropertyAccessExpression(expression) && expression.name.text === "glob" && syntaxApi.isMetaProperty(expression.expression) && expression.expression.keywordToken === syntaxApi.SyntaxKind.ImportKeyword && expression.expression.name.text === "meta") {
|
|
131
|
+
const [pattern, options] = callArguments;
|
|
132
|
+
if (pattern !== void 0 && options !== void 0 && rawOptions({ syntaxApi, node: options })) {
|
|
133
|
+
const patterns = syntaxApi.isArrayLiteralExpression(pattern) ? pattern.elements : [pattern];
|
|
134
|
+
return patterns.map((element) => literalIn({ syntaxApi, node: element, accepts: textGlob })).find((path) => path !== void 0);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return void 0;
|
|
138
|
+
};
|
|
139
|
+
var readPathOf = (request) => {
|
|
140
|
+
const { syntaxApi, node } = request;
|
|
141
|
+
if (syntaxApi.isImportDeclaration(node))
|
|
142
|
+
return node.importClause?.isTypeOnly === true ? void 0 : literalIn({ syntaxApi, node: node.moduleSpecifier, accepts: rawModule });
|
|
143
|
+
if (!syntaxApi.isCallExpression(node)) return void 0;
|
|
144
|
+
const [path] = node.arguments;
|
|
145
|
+
if (path === void 0) return void 0;
|
|
146
|
+
if (node.expression.kind === syntaxApi.SyntaxKind.ImportKeyword)
|
|
147
|
+
return literalIn({ syntaxApi, node: path, accepts: rawModule });
|
|
148
|
+
if (fileReadCallee({ ...request, node: node.expression }) !== void 0)
|
|
149
|
+
return filePathOf({ syntaxApi, node: path });
|
|
150
|
+
return rawGlobPathOf(request);
|
|
151
|
+
};
|
|
152
|
+
var check = {
|
|
153
|
+
prepare: (request) => {
|
|
154
|
+
const fileBindingsOf = sourceBindingsPerFile();
|
|
155
|
+
return syntaxNodeCheck({
|
|
156
|
+
eligibility: testFileEligibility,
|
|
157
|
+
found: (visit) => {
|
|
158
|
+
const at = readPathOf({ ...visit, bindingsOf: () => fileBindingsOf(visit) });
|
|
159
|
+
return at === void 0 ? void 0 : { at, snippet: at.getText(visit.sourceFile) };
|
|
160
|
+
}
|
|
161
|
+
}).prepare(request);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
export {
|
|
165
|
+
check
|
|
166
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
folderScope
|
|
3
|
-
} from "../../../../../../chunks/chunk-
|
|
3
|
+
} from "../../../../../../chunks/chunk-COQMPHWZ.js";
|
|
4
4
|
import "../../../../../../chunks/chunk-DGOLOS5A.js";
|
|
5
5
|
|
|
6
6
|
// src/infrastructure/engines/walker/date-used-directly/clock-sources/clock-sources.ts
|
|
@@ -10,7 +10,7 @@ var sourceEligibility = (request) => {
|
|
|
10
10
|
return "eligible";
|
|
11
11
|
};
|
|
12
12
|
var check = {
|
|
13
|
-
prepare: ({
|
|
13
|
+
prepare: ({ bindings }) => ({
|
|
14
14
|
outcome: "ok",
|
|
15
15
|
value: {
|
|
16
16
|
prepareFile: ({ file, readText }) => {
|
|
@@ -19,8 +19,8 @@ var check = {
|
|
|
19
19
|
const text = readText();
|
|
20
20
|
if (text.outcome === "failed") return text;
|
|
21
21
|
const hits = text.value.split("\n").flatMap(
|
|
22
|
-
(line, index) => /\bDate\.now\(\)/.test(line) || /\bnew\x20Date\b/.test(line) ?
|
|
23
|
-
|
|
22
|
+
(line, index) => /\bDate\.now\(\)/.test(line) || /\bnew\x20Date\b/.test(line) ? bindings.map((binding) => ({
|
|
23
|
+
check: binding.address,
|
|
24
24
|
anchor: { line: index + 1, column: 0 },
|
|
25
25
|
snippet: line.trim()
|
|
26
26
|
})) : []
|
package/src/infrastructure/engines/walker/default-on-a-closed-union/default-arm/switch-defaults.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
compactSourceSnippetOf
|
|
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/default-on-a-closed-union/default-arm/switch-defaults.ts
|
|
@@ -13,7 +16,7 @@ var SWITCH_OPEN = /\bswitch\s*\(/g;
|
|
|
13
16
|
var CLOSING_BRACE = /\}/g;
|
|
14
17
|
var DEFAULT_ARM = /(^|[^.\w])default\s*:/;
|
|
15
18
|
var check = {
|
|
16
|
-
prepare: ({
|
|
19
|
+
prepare: ({ bindings }) => ({
|
|
17
20
|
outcome: "ok",
|
|
18
21
|
value: {
|
|
19
22
|
prepareFile: ({ file, readText }) => {
|
|
@@ -29,10 +32,9 @@ var check = {
|
|
|
29
32
|
return state;
|
|
30
33
|
const opens = (line.match(SWITCH_OPEN) ?? []).length;
|
|
31
34
|
const closes = (line.match(CLOSING_BRACE) ?? []).length;
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
clause: clause.address,
|
|
35
|
+
const snippet = compactSourceSnippetOf(trimmed);
|
|
36
|
+
const hits = state.depth + opens > 0 && DEFAULT_ARM.test(line) ? bindings.map((binding) => ({
|
|
37
|
+
check: binding.address,
|
|
36
38
|
anchor: { line: index + 1, column: 0 },
|
|
37
39
|
snippet
|
|
38
40
|
})) : [];
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../../../../../../chunks/chunk-
|
|
2
|
+
sourceSnippetAt
|
|
3
|
+
} from "../../../../../../chunks/chunk-5AKHEW6V.js";
|
|
4
|
+
import {
|
|
5
|
+
testFileEligibility
|
|
6
|
+
} from "../../../../../../chunks/chunk-COQMPHWZ.js";
|
|
4
7
|
import "../../../../../../chunks/chunk-DGOLOS5A.js";
|
|
5
8
|
|
|
6
9
|
// src/infrastructure/engines/walker/double-with-a-body/stub-implementation/dependency-isolation.ts
|
|
7
|
-
var testFileEligibility = (request) => {
|
|
8
|
-
if (folderScope({ file: request.file }) === "generated") return "skipped";
|
|
9
|
-
return request.file.endsWith(".test.ts") || request.file.endsWith(".test.tsx") ? "eligible" : "skipped";
|
|
10
|
-
};
|
|
11
|
-
var snippetAt = (request) => {
|
|
12
|
-
const snippet = request.source.slice(request.position, request.position + 80).replace(/\n/g, " ");
|
|
13
|
-
return snippet.length === 80 ? `${snippet}\u2026` : snippet;
|
|
14
|
-
};
|
|
15
10
|
var check = {
|
|
16
|
-
prepare: ({
|
|
11
|
+
prepare: ({ bindings, repository, syntaxApi }) => ({
|
|
17
12
|
outcome: "ok",
|
|
18
13
|
value: {
|
|
19
14
|
prepareFile: ({ file }) => {
|
|
20
|
-
if (testFileEligibility({ file }) === "skipped") {
|
|
15
|
+
if (testFileEligibility({ file, testFiles: repository.testFiles }) === "skipped") {
|
|
21
16
|
return { outcome: "ok", value: { kind: "skipped" } };
|
|
22
17
|
}
|
|
23
18
|
return {
|
|
@@ -36,9 +31,9 @@ var check = {
|
|
|
36
31
|
return;
|
|
37
32
|
const position = node.getStart(sourceFile);
|
|
38
33
|
const anchor = anchorAt({ position });
|
|
39
|
-
const snippet =
|
|
34
|
+
const snippet = sourceSnippetAt({ source: sourceFile.text, position });
|
|
40
35
|
hits.push(
|
|
41
|
-
...
|
|
36
|
+
...bindings.map((binding) => ({ check: binding.address, anchor, snippet }))
|
|
42
37
|
);
|
|
43
38
|
},
|
|
44
39
|
finish: () => hits
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
folderScope
|
|
3
|
-
} from "../../../../../../chunks/chunk-
|
|
3
|
+
} from "../../../../../../chunks/chunk-COQMPHWZ.js";
|
|
4
4
|
import "../../../../../../chunks/chunk-DGOLOS5A.js";
|
|
5
5
|
|
|
6
6
|
// src/infrastructure/engines/walker/drawer-path/drawer-names/categorical-paths.ts
|
|
@@ -37,7 +37,7 @@ var FORBIDDEN_FOLDERS = [
|
|
|
37
37
|
"__tests__"
|
|
38
38
|
];
|
|
39
39
|
var check = {
|
|
40
|
-
prepare: ({
|
|
40
|
+
prepare: ({ bindings }) => ({
|
|
41
41
|
outcome: "ok",
|
|
42
42
|
value: {
|
|
43
43
|
prepareFile: ({ file }) => {
|
|
@@ -52,8 +52,8 @@ var check = {
|
|
|
52
52
|
...folder === void 0 ? [] : [`forbidden categorical folder: ${folder}`]
|
|
53
53
|
];
|
|
54
54
|
const hits = snippets.flatMap(
|
|
55
|
-
(snippet) =>
|
|
56
|
-
|
|
55
|
+
(snippet) => bindings.map((binding) => ({
|
|
56
|
+
check: binding.address,
|
|
57
57
|
anchor: { line: 1, column: 0 },
|
|
58
58
|
snippet
|
|
59
59
|
}))
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"flag": [
|
|
3
|
+
{
|
|
4
|
+
"name": "named and type exports from a test",
|
|
5
|
+
"fileName": "src/order.test.ts",
|
|
6
|
+
"source": "export const sample = 1;\nexport type { Example } from \"./order.ts\";",
|
|
7
|
+
"expectedLines": [1, 2]
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "test module exports its default",
|
|
11
|
+
"fileName": "src/order.integration.test.ts",
|
|
12
|
+
"source": "export default { sample: 1 };",
|
|
13
|
+
"expectedLines": [1]
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"allow": [
|
|
17
|
+
{
|
|
18
|
+
"name": "export only appears as data",
|
|
19
|
+
"fileName": "src/order.test.tsx",
|
|
20
|
+
"source": "const input = \"export default 1\";",
|
|
21
|
+
"expectedLines": []
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "production module exports its unit",
|
|
25
|
+
"fileName": "src/order.ts",
|
|
26
|
+
"source": "export const order = 1;",
|
|
27
|
+
"expectedLines": []
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
syntaxNodeCheck
|
|
3
|
+
} from "../../../../../../chunks/chunk-LEFM7OPS.js";
|
|
4
|
+
import "../../../../../../chunks/chunk-5AKHEW6V.js";
|
|
5
|
+
import {
|
|
6
|
+
testFileEligibility
|
|
7
|
+
} from "../../../../../../chunks/chunk-COQMPHWZ.js";
|
|
8
|
+
import "../../../../../../chunks/chunk-DGOLOS5A.js";
|
|
9
|
+
|
|
10
|
+
// src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/test-file-export.ts
|
|
11
|
+
var exportAt = ({ syntaxApi, node, sourceFile }) => {
|
|
12
|
+
if (node.parent !== sourceFile) return void 0;
|
|
13
|
+
if (syntaxApi.isExportAssignment(node)) return node;
|
|
14
|
+
if (syntaxApi.isExportDeclaration(node)) {
|
|
15
|
+
const clause = node.exportClause;
|
|
16
|
+
if (clause !== void 0 && syntaxApi.isNamedExports(clause) && clause.elements.length === 0)
|
|
17
|
+
return void 0;
|
|
18
|
+
return node;
|
|
19
|
+
}
|
|
20
|
+
return syntaxApi.canHaveModifiers(node) ? syntaxApi.getModifiers(node)?.find((modifier) => modifier.kind === syntaxApi.SyntaxKind.ExportKeyword) : void 0;
|
|
21
|
+
};
|
|
22
|
+
var check = syntaxNodeCheck({
|
|
23
|
+
eligibility: testFileEligibility,
|
|
24
|
+
found: (visit) => {
|
|
25
|
+
const at = exportAt(visit);
|
|
26
|
+
return at === void 0 ? void 0 : { at, snippet: "export" };
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
export {
|
|
30
|
+
check
|
|
31
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"flag": [
|
|
3
|
+
{
|
|
4
|
+
"name": "empty catch and promise rejection handlers",
|
|
5
|
+
"fileName": "src/orders.ts",
|
|
6
|
+
"source": "try { save(); } catch { /* ignored */ }\nload().catch(() => {});\nload().then(useOrder, function () {});",
|
|
7
|
+
"expectedLines": [1, 2, 3]
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"allow": [
|
|
11
|
+
{
|
|
12
|
+
"name": "failures become observable values",
|
|
13
|
+
"fileName": "src/orders.ts",
|
|
14
|
+
"source": "try { save(); } catch (error) { return { outcome: \"failed\", error }; }\nload().catch(toFailure);\nload().then(() => {});",
|
|
15
|
+
"expectedLines": []
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
syntaxNodeCheck
|
|
3
|
+
} from "../../../../../../chunks/chunk-LEFM7OPS.js";
|
|
4
|
+
import "../../../../../../chunks/chunk-5AKHEW6V.js";
|
|
5
|
+
import {
|
|
6
|
+
typeScriptSourceEligibility
|
|
7
|
+
} from "../../../../../../chunks/chunk-COQMPHWZ.js";
|
|
8
|
+
import "../../../../../../chunks/chunk-DGOLOS5A.js";
|
|
9
|
+
|
|
10
|
+
// src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.ts
|
|
11
|
+
var emptyCallback = (request) => {
|
|
12
|
+
const { syntaxApi, argument } = request;
|
|
13
|
+
return argument !== void 0 && (syntaxApi.isArrowFunction(argument) || syntaxApi.isFunctionExpression(argument)) && syntaxApi.isBlock(argument.body) && argument.body.statements.length === 0;
|
|
14
|
+
};
|
|
15
|
+
var promiseHandlerAt = (request) => {
|
|
16
|
+
const { syntaxApi, node } = request;
|
|
17
|
+
if (!syntaxApi.isCallExpression(node)) return void 0;
|
|
18
|
+
const callee = node.expression;
|
|
19
|
+
const member = syntaxApi.isPropertyAccessExpression(callee) ? callee.name : syntaxApi.isElementAccessExpression(callee) && syntaxApi.isStringLiteralLike(callee.argumentExpression) ? callee.argumentExpression : void 0;
|
|
20
|
+
if (member?.text === "catch" && emptyCallback({ syntaxApi, argument: node.arguments[0] }))
|
|
21
|
+
return { at: member, snippet: "catch" };
|
|
22
|
+
if (member?.text === "then" && emptyCallback({ syntaxApi, argument: node.arguments[1] }))
|
|
23
|
+
return { at: member, snippet: "then" };
|
|
24
|
+
return void 0;
|
|
25
|
+
};
|
|
26
|
+
var check = syntaxNodeCheck({
|
|
27
|
+
eligibility: typeScriptSourceEligibility,
|
|
28
|
+
found: ({ syntaxApi, node }) => syntaxApi.isCatchClause(node) && node.block.statements.length === 0 ? { at: node, snippet: "catch" } : promiseHandlerAt({ syntaxApi, node })
|
|
29
|
+
});
|
|
30
|
+
export {
|
|
31
|
+
check
|
|
32
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"flag": [
|
|
3
|
+
{
|
|
4
|
+
"name": "floating lock-independent version",
|
|
5
|
+
"fileName": "package.json",
|
|
6
|
+
"source": "{\n \"devDependencies\": {\n \"some-tool\": \"^1.2.3\"\n }\n}",
|
|
7
|
+
"expectedLines": [3]
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "unpinned action and runtime",
|
|
11
|
+
"fileName": ".github/workflows/ci.yml",
|
|
12
|
+
"source": "- uses: actions/checkout@v4\n node-version: lts",
|
|
13
|
+
"expectedLines": [1, 2]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "package manager major selector",
|
|
17
|
+
"fileName": "package.json",
|
|
18
|
+
"source": "{\n \"packageManager\": \"pnpm@10\"\n}",
|
|
19
|
+
"expectedLines": [2]
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"allow": [
|
|
23
|
+
{
|
|
24
|
+
"name": "exact version",
|
|
25
|
+
"fileName": "package.json",
|
|
26
|
+
"source": "{\"devDependencies\":{\"some-tool\":\"1.2.3\"}}",
|
|
27
|
+
"expectedLines": []
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "pinned action and runtime",
|
|
31
|
+
"fileName": ".github/workflows/ci.yml",
|
|
32
|
+
"source": "- uses: actions/checkout@0123456789abcdef0123456789abcdef01234567\n node-version: '22.18.0'",
|
|
33
|
+
"expectedLines": []
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "exact package manager with a hash suffix",
|
|
37
|
+
"fileName": "package.json",
|
|
38
|
+
"source": "{\"packageManager\":\"pnpm@10.34.9+sha512.0123456789abcdef\"}",
|
|
39
|
+
"expectedLines": []
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "workspace, file and exact prerelease selectors",
|
|
43
|
+
"fileName": "package.json",
|
|
44
|
+
"source": "{\"devDependencies\":{\"workspace-tool\":\"workspace:*\",\"file-tool\":\"file:../tool\",\"preview\":\"1.2.3-rc.1+build\"}}",
|
|
45
|
+
"expectedLines": []
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "compatibility ranges offered by a published package",
|
|
49
|
+
"fileName": "package.json",
|
|
50
|
+
"source": "{\"dependencies\":{\"react\":\"^19.0.0\"},\"peerDependencies\":{\"react-dom\":\"^19.0.0\"}}",
|
|
51
|
+
"expectedLines": []
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|