@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
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
editionOf
|
|
3
|
+
} from "../../../../../../chunks/chunk-RFR3ITBS.js";
|
|
4
|
+
import {
|
|
5
|
+
builtInImportOf
|
|
6
|
+
} from "../../../../../../chunks/chunk-LNMDMRGQ.js";
|
|
7
|
+
import {
|
|
8
|
+
sourceValueLookupOf
|
|
9
|
+
} from "../../../../../../chunks/chunk-75XWZYNN.js";
|
|
10
|
+
import {
|
|
11
|
+
typeScriptSourceEligibility
|
|
12
|
+
} from "../../../../../../chunks/chunk-COQMPHWZ.js";
|
|
13
|
+
import {
|
|
14
|
+
editionReaches
|
|
15
|
+
} from "../../../../../../chunks/chunk-RANIXNWY.js";
|
|
16
|
+
import "../../../../../../chunks/chunk-DGOLOS5A.js";
|
|
17
|
+
|
|
18
|
+
// src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/process-global-used-in-place.ts
|
|
19
|
+
var PROCESS_MEMBERS = /* @__PURE__ */ new Set(["env", "argv", "exit", "on"]);
|
|
20
|
+
var DIALOGS = /* @__PURE__ */ new Set(["alert", "confirm", "prompt"]);
|
|
21
|
+
var FIRST_DIALOG_EDITION = editionOf("2");
|
|
22
|
+
var processOrConsole = ({
|
|
23
|
+
syntaxApi,
|
|
24
|
+
node,
|
|
25
|
+
declarationsOf
|
|
26
|
+
}) => {
|
|
27
|
+
if (!syntaxApi.isPropertyAccessExpression(node) && !syntaxApi.isElementAccessExpression(node))
|
|
28
|
+
return void 0;
|
|
29
|
+
const receiver = node.expression;
|
|
30
|
+
if (!syntaxApi.isIdentifier(receiver) || receiver.text !== "process" && receiver.text !== "console")
|
|
31
|
+
return void 0;
|
|
32
|
+
if (declarationsOf(receiver).length > 0) {
|
|
33
|
+
const imported = builtInImportOf({
|
|
34
|
+
syntaxApi,
|
|
35
|
+
identifier: receiver,
|
|
36
|
+
declarationsOf,
|
|
37
|
+
builtIn: receiver.text
|
|
38
|
+
});
|
|
39
|
+
if (imported === void 0 || imported.kind === "named") return void 0;
|
|
40
|
+
}
|
|
41
|
+
if (receiver.text === "console") return node;
|
|
42
|
+
if (syntaxApi.isPropertyAccessExpression(node))
|
|
43
|
+
return PROCESS_MEMBERS.has(node.name.text) ? node : void 0;
|
|
44
|
+
return syntaxApi.isStringLiteralLike(node.argumentExpression) && PROCESS_MEMBERS.has(node.argumentExpression.text) ? node : void 0;
|
|
45
|
+
};
|
|
46
|
+
var globalThisRead = ({
|
|
47
|
+
syntaxApi,
|
|
48
|
+
node,
|
|
49
|
+
declarationsOf
|
|
50
|
+
}) => {
|
|
51
|
+
if (!syntaxApi.isIdentifier(node) || node.text !== "globalThis") return void 0;
|
|
52
|
+
const parent = node.parent;
|
|
53
|
+
if (syntaxApi.isTypeNode(parent) || syntaxApi.isQualifiedName(parent) || syntaxApi.isBindingElement(parent))
|
|
54
|
+
return void 0;
|
|
55
|
+
if (syntaxApi.isJsxOpeningElement(parent) || syntaxApi.isJsxSelfClosingElement(parent) || syntaxApi.isJsxClosingElement(parent))
|
|
56
|
+
return void 0;
|
|
57
|
+
if (syntaxApi.isImportSpecifier(parent) || syntaxApi.isExportSpecifier(parent)) return void 0;
|
|
58
|
+
if ("label" in parent && parent.label === node) return void 0;
|
|
59
|
+
if ("name" in parent && parent.name === node && !syntaxApi.isShorthandPropertyAssignment(parent))
|
|
60
|
+
return void 0;
|
|
61
|
+
return declarationsOf(node).length > 0 ? void 0 : node;
|
|
62
|
+
};
|
|
63
|
+
var browserDialogOf = ({ syntaxApi, node }) => {
|
|
64
|
+
if (!syntaxApi.isCallExpression(node)) return void 0;
|
|
65
|
+
const callee = node.expression;
|
|
66
|
+
if (syntaxApi.isIdentifier(callee)) {
|
|
67
|
+
return DIALOGS.has(callee.text) ? { use: callee, binding: callee } : void 0;
|
|
68
|
+
}
|
|
69
|
+
if (!syntaxApi.isPropertyAccessExpression(callee) && !syntaxApi.isElementAccessExpression(callee))
|
|
70
|
+
return void 0;
|
|
71
|
+
const receiver = callee.expression;
|
|
72
|
+
if (!syntaxApi.isIdentifier(receiver) || receiver.text !== "window") return void 0;
|
|
73
|
+
const member = syntaxApi.isPropertyAccessExpression(callee) ? callee.name : callee.argumentExpression;
|
|
74
|
+
if (syntaxApi.isElementAccessExpression(callee) && !syntaxApi.isStringLiteralLike(member))
|
|
75
|
+
return void 0;
|
|
76
|
+
return (syntaxApi.isIdentifier(member) || syntaxApi.isStringLiteralLike(member)) && DIALOGS.has(member.text) ? { use: callee, binding: receiver } : void 0;
|
|
77
|
+
};
|
|
78
|
+
var unboundDialogOf = (request) => {
|
|
79
|
+
const dialog = browserDialogOf(request);
|
|
80
|
+
return dialog !== void 0 && request.declarationsOf(dialog.binding).length === 0 ? dialog.use : void 0;
|
|
81
|
+
};
|
|
82
|
+
var check = {
|
|
83
|
+
prepare: ({ bindings, syntaxApi }) => {
|
|
84
|
+
const dialogBindings = bindings.filter(
|
|
85
|
+
({ edition }) => editionReaches({ edition, introducedIn: FIRST_DIALOG_EDITION }) === "reached"
|
|
86
|
+
);
|
|
87
|
+
return {
|
|
88
|
+
outcome: "ok",
|
|
89
|
+
value: {
|
|
90
|
+
prepareFile: ({ file }) => {
|
|
91
|
+
if (typeScriptSourceEligibility({ file }) === "skipped")
|
|
92
|
+
return { outcome: "ok", value: { kind: "skipped" } };
|
|
93
|
+
return {
|
|
94
|
+
outcome: "ok",
|
|
95
|
+
value: {
|
|
96
|
+
kind: "syntax",
|
|
97
|
+
begin: ({ sourceFile, anchorAt }) => {
|
|
98
|
+
const hits = [];
|
|
99
|
+
const declarationsOf = sourceValueLookupOf({ syntaxApi, sourceFile });
|
|
100
|
+
return {
|
|
101
|
+
enter: ({ node }) => {
|
|
102
|
+
const existingUse = processOrConsole({ syntaxApi, node, declarationsOf }) ?? globalThisRead({ syntaxApi, node, declarationsOf });
|
|
103
|
+
const active = existingUse === void 0 ? dialogBindings : bindings;
|
|
104
|
+
if (active.length === 0) return;
|
|
105
|
+
const use = existingUse ?? unboundDialogOf({ syntaxApi, node, declarationsOf });
|
|
106
|
+
if (use === void 0) return;
|
|
107
|
+
const anchor = anchorAt({ position: use.getStart(sourceFile) });
|
|
108
|
+
const snippet = use.getText(sourceFile).replace(/\r?\n/g, " ");
|
|
109
|
+
hits.push(
|
|
110
|
+
...active.map(({ address }) => ({ check: address, anchor, snippet }))
|
|
111
|
+
);
|
|
112
|
+
},
|
|
113
|
+
finish: () => hits
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
finish: () => ({ outcome: "ok", value: [] })
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
export {
|
|
125
|
+
check
|
|
126
|
+
};
|
package/src/infrastructure/engines/walker/prose-in-code/comment-prose/comment-prose.examples.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"flag": [
|
|
3
|
+
{
|
|
4
|
+
"name": "line and documentation prose",
|
|
5
|
+
"fileName": "src/order.ts",
|
|
6
|
+
"source": "// The fallback is safe.\n/** Reads an order. */\nexport const order = 1;",
|
|
7
|
+
"expectedLines": [1, 2]
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "prose after a tracked reference",
|
|
11
|
+
"fileName": "src/order.ts",
|
|
12
|
+
"source": "// TODO(#16) because the source changed\nexport const order = 1;",
|
|
13
|
+
"expectedLines": [1]
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"allow": [
|
|
17
|
+
{
|
|
18
|
+
"name": "tracked follow-up",
|
|
19
|
+
"fileName": "src/order.ts",
|
|
20
|
+
"source": "// TODO(#16)\nexport const order = 1;",
|
|
21
|
+
"expectedLines": []
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "supported tool directives",
|
|
25
|
+
"fileName": "src/order.ts",
|
|
26
|
+
"source": "// @vitest-environment jsdom\nconst order = /* @__PURE__ */ open();\n/* eslint-env node */",
|
|
27
|
+
"expectedLines": []
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "comment markers inside a string",
|
|
31
|
+
"fileName": "src/order.ts",
|
|
32
|
+
"source": "const marker = '// not a comment';",
|
|
33
|
+
"expectedLines": []
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "JavaScript is outside the TypeScript check",
|
|
37
|
+
"fileName": "src/order.js",
|
|
38
|
+
"source": "// A comment in JavaScript.",
|
|
39
|
+
"expectedLines": []
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"anchor": {
|
|
4
|
+
"kind": "file"
|
|
5
|
+
},
|
|
6
|
+
"settings": {
|
|
7
|
+
"module": "prose-in-code.js"
|
|
8
|
+
},
|
|
9
|
+
"checkSettings": {
|
|
10
|
+
"trackerPatterns": {
|
|
11
|
+
"default": [
|
|
12
|
+
"^\\((?:#[1-9]\\d*|[A-Za-z][\\w-]*-[1-9]\\d*|[Hh][Tt][Tt][Pp][Ss]?://\\S+)\\)$"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
numberedReferenceKind,
|
|
3
|
+
trackedChecksOf,
|
|
4
|
+
trackingReference
|
|
5
|
+
} from "../../../../../../chunks/chunk-X73RZUPO.js";
|
|
6
|
+
import "../../../../../../chunks/chunk-W5OIAUDW.js";
|
|
7
|
+
import {
|
|
8
|
+
sourceSnippetOf
|
|
9
|
+
} from "../../../../../../chunks/chunk-5AKHEW6V.js";
|
|
10
|
+
import {
|
|
11
|
+
folderScope
|
|
12
|
+
} from "../../../../../../chunks/chunk-COQMPHWZ.js";
|
|
13
|
+
import "../../../../../../chunks/chunk-YONPKP3C.js";
|
|
14
|
+
import "../../../../../../chunks/chunk-DGOLOS5A.js";
|
|
15
|
+
|
|
16
|
+
// src/infrastructure/engines/walker/prose-in-code/comment-prose/prose-in-code.ts
|
|
17
|
+
var TYPESCRIPT_FILE = /\.(?:ts|tsx|mts|cts)$/;
|
|
18
|
+
var TODO = /^TODO(?=\()/i;
|
|
19
|
+
var URL_REFERENCE = /^\(https?:\/\/[^()\s]+\)$/i;
|
|
20
|
+
var TOOL_DIRECTIVE = /^(?:(?:@ts-(?:check|nocheck|ignore|expect-error)|@jsx(?:Frag|ImportSource|Runtime)?|biome-ignore(?:-all|-start|-end)?|(?:eslint|oxlint)-(?:disable(?:-line|-next-line)?|enable)|prettier-ignore(?:-start|-end)?|(?:istanbul|v8|c8) ignore)\b|eslint\s+[\w@/.-]+\s*:|!\s*(?:@license|@preserve)(?=\s|$))/;
|
|
21
|
+
var TOOL_ANNOTATION = /^(?:[@#]__PURE__|!\s*license\s+[\w.+-]+|eslint-env\s+[\w-]+(?:\s*,\s*[\w-]+)*|@vitest-environment\s+\S+|webpackChunkName\s*:\s*(?:"[^"]+"|'[^']+'))$/;
|
|
22
|
+
var VITEST_OPTIONS = /^@vitest-environment-options\s+(?<settings>\{[\s\S]*\})$/;
|
|
23
|
+
var TYPESCRIPT_REFERENCE = /^\/\/\/\s*<(?:reference\s+(?:path|types|lib|no-default-lib)|amd-(?:module|dependency)\s+name)\b/;
|
|
24
|
+
var commentContent = (text) => text.replace(/^\/(?:\/+|\*+)/, "").replace(/\*\/$/, "").trim();
|
|
25
|
+
var vitestOptionsKind = (text) => {
|
|
26
|
+
const json = VITEST_OPTIONS.exec(text)?.groups?.settings;
|
|
27
|
+
if (json === void 0) return "other";
|
|
28
|
+
try {
|
|
29
|
+
JSON.parse(json);
|
|
30
|
+
return "options";
|
|
31
|
+
} catch {
|
|
32
|
+
return "other";
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var reportingChecksOf = (request) => {
|
|
36
|
+
const { comment, checks } = request;
|
|
37
|
+
const content = commentContent(comment);
|
|
38
|
+
if (TOOL_DIRECTIVE.test(content) || TOOL_ANNOTATION.test(content) || vitestOptionsKind(content) === "options" || TYPESCRIPT_REFERENCE.test(comment))
|
|
39
|
+
return [];
|
|
40
|
+
const todo = TODO.exec(content);
|
|
41
|
+
const reference = todo === null ? "" : content.slice(todo[0].length);
|
|
42
|
+
if (numberedReferenceKind(reference) === "other" && !URL_REFERENCE.test(reference)) return checks;
|
|
43
|
+
return checks.filter((tracked) => trackingReference({ tracked, reference }) === "untracked");
|
|
44
|
+
};
|
|
45
|
+
var check = {
|
|
46
|
+
prepare: ({ bindings }) => {
|
|
47
|
+
const configured = trackedChecksOf({ bindings });
|
|
48
|
+
if (configured.outcome === "failed") return configured;
|
|
49
|
+
return {
|
|
50
|
+
outcome: "ok",
|
|
51
|
+
value: {
|
|
52
|
+
prepareFile: ({ file }) => {
|
|
53
|
+
if (!TYPESCRIPT_FILE.test(file) || folderScope({ file }) === "generated") {
|
|
54
|
+
return { outcome: "ok", value: { kind: "skipped" } };
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
outcome: "ok",
|
|
58
|
+
value: {
|
|
59
|
+
kind: "syntax",
|
|
60
|
+
begin: ({ sourceFile, anchorAt }) => {
|
|
61
|
+
const hits = [];
|
|
62
|
+
return {
|
|
63
|
+
comment: ({ range }) => {
|
|
64
|
+
const comment = sourceFile.text.slice(range.pos, range.end);
|
|
65
|
+
const reporting = reportingChecksOf({ comment, checks: configured.value });
|
|
66
|
+
if (reporting.length === 0) return;
|
|
67
|
+
const anchor = anchorAt({ position: range.pos });
|
|
68
|
+
const snippet = sourceSnippetOf(comment);
|
|
69
|
+
hits.push(
|
|
70
|
+
...reporting.map(({ binding }) => ({
|
|
71
|
+
check: binding.address,
|
|
72
|
+
anchor,
|
|
73
|
+
snippet
|
|
74
|
+
}))
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
finish: () => hits
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
finish: () => ({ outcome: "ok", value: [] })
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
export {
|
|
89
|
+
check
|
|
90
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Anchor } from "../../../../../domain/finding/anchor.js";
|
|
2
2
|
import type { RepoPath } from "../../../../../domain/repository/repo-path-types.js";
|
|
3
3
|
import type { Result } from "../../../../../domain/result.js";
|
|
4
|
+
import type { CheckBinding } from "../../../../../domain/runner/check-binding.js";
|
|
5
|
+
import type { CheckHit } from "../../../../../domain/runner/check-observations.js";
|
|
4
6
|
import type { PieceFailure } from "../../../../../domain/runner/piece-failure-types.js";
|
|
5
|
-
import type {
|
|
6
|
-
import type { Hit } from "../../../../../domain/runner/runner-result-types.js";
|
|
7
|
+
import type { TestFiles } from "../../../../../domain/settings/test-files.js";
|
|
7
8
|
import type { CommentRange, SyntaxApi, SyntaxNode, SyntaxTree } from "../toolchain/typescript-parse.js";
|
|
8
|
-
export type PieceHit = Omit<
|
|
9
|
+
export type PieceHit = Omit<CheckHit, "file">;
|
|
9
10
|
export type WalkerFile = {
|
|
10
11
|
readonly file: RepoPath;
|
|
11
12
|
readonly readText: () => Result<string, PieceFailure>;
|
|
@@ -38,7 +39,7 @@ export type PreparedFileCheck = {
|
|
|
38
39
|
};
|
|
39
40
|
export type PreparedWalkerCheck = {
|
|
40
41
|
readonly prepareFile: (request: WalkerFile) => Result<PreparedFileCheck, PieceFailure>;
|
|
41
|
-
readonly finish: () => Result<readonly
|
|
42
|
+
readonly finish: () => Result<readonly CheckHit[], PieceFailure>;
|
|
42
43
|
};
|
|
43
44
|
export type WalkerDisk = {
|
|
44
45
|
readonly root: string;
|
|
@@ -57,10 +58,11 @@ export type WalkerRepository = {
|
|
|
57
58
|
readonly file: RepoPath;
|
|
58
59
|
}) => "present" | "absent";
|
|
59
60
|
readonly disk: WalkerDisk;
|
|
61
|
+
readonly testFiles: TestFiles;
|
|
60
62
|
};
|
|
61
63
|
export type WalkerPiece = {
|
|
62
64
|
readonly prepare: (request: {
|
|
63
|
-
readonly
|
|
65
|
+
readonly bindings: readonly CheckBinding[];
|
|
64
66
|
readonly repository: WalkerRepository;
|
|
65
67
|
readonly syntaxApi: SyntaxApi;
|
|
66
68
|
}) => Result<PreparedWalkerCheck, PieceFailure>;
|