@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,42 @@
|
|
|
1
|
+
// src/infrastructure/engines/walker/runner/pieces/jsonc-parse.ts
|
|
2
|
+
import { parse, parseTree } from "jsonc-parser";
|
|
3
|
+
var createJsoncParsePort = (options) => ({
|
|
4
|
+
parse: (request) => {
|
|
5
|
+
try {
|
|
6
|
+
const providerParse = options.parseProvider({ source: request.source });
|
|
7
|
+
const firstDiagnostic = providerParse.errors[0];
|
|
8
|
+
if (firstDiagnostic !== void 0) {
|
|
9
|
+
return {
|
|
10
|
+
outcome: "failed",
|
|
11
|
+
error: {
|
|
12
|
+
detail: `JSONC parse error ${firstDiagnostic.error} at offset ${firstDiagnostic.offset} (length ${firstDiagnostic.length})`
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return { outcome: "ok", value: providerParse.value };
|
|
17
|
+
} catch (thrown) {
|
|
18
|
+
return {
|
|
19
|
+
outcome: "failed",
|
|
20
|
+
error: { detail: thrown instanceof Error ? thrown.message : String(thrown) }
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var defaultProviderCallOf = (options) => (request) => {
|
|
26
|
+
const errors = [];
|
|
27
|
+
const parsedValue = options.read(request.source, errors, {
|
|
28
|
+
allowTrailingComma: options.trailingCommas === "allowed"
|
|
29
|
+
});
|
|
30
|
+
return { value: parsedValue, errors };
|
|
31
|
+
};
|
|
32
|
+
var createDefaultJsoncParsePort = (options) => createJsoncParsePort({
|
|
33
|
+
parseProvider: defaultProviderCallOf({ ...options, read: parse })
|
|
34
|
+
});
|
|
35
|
+
var createDefaultJsoncTreePort = (options) => createJsoncParsePort({
|
|
36
|
+
parseProvider: defaultProviderCallOf({ ...options, read: parseTree })
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
createDefaultJsoncParsePort,
|
|
41
|
+
createDefaultJsoncTreePort
|
|
42
|
+
};
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
everyOk
|
|
3
|
+
} from "./chunk-LD766VWU.js";
|
|
4
|
+
import {
|
|
5
5
|
namedPiecePathOf,
|
|
6
6
|
readNamedPiece
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FPIP7JEC.js";
|
|
8
8
|
import {
|
|
9
9
|
createDefaultPackageLocationPort
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-CXM5KBZX.js";
|
|
11
11
|
import {
|
|
12
|
+
TOOL_IDENTITY,
|
|
13
|
+
checkAddressTextOf,
|
|
14
|
+
checkNamesOf,
|
|
15
|
+
editionSchema,
|
|
12
16
|
gatheredPeerFailure,
|
|
13
17
|
installedPeer,
|
|
14
18
|
isRepoPathText,
|
|
15
19
|
loadedPeer,
|
|
16
20
|
moduleFileForm
|
|
17
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-BKQ3K766.js";
|
|
18
22
|
import {
|
|
19
|
-
TOOL_IDENTITY,
|
|
20
23
|
gatheredOutcomes,
|
|
21
24
|
listedOutcome
|
|
22
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-YONPKP3C.js";
|
|
26
|
+
import {
|
|
27
|
+
editionReaches
|
|
28
|
+
} from "./chunk-RANIXNWY.js";
|
|
23
29
|
import {
|
|
24
30
|
__glob
|
|
25
31
|
} from "./chunk-DGOLOS5A.js";
|
|
@@ -38,13 +44,23 @@ var pieceModulePathSchema = z.string().superRefine((text, context) => {
|
|
|
38
44
|
}
|
|
39
45
|
});
|
|
40
46
|
var pluginNamespaceSchema = z.string().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/);
|
|
47
|
+
var ruleOptionsSchema = z.array(z.json()).readonly();
|
|
48
|
+
var optionsByEditionSchema = z.record(z.string(), ruleOptionsSchema).transform((options) => new Map(Object.entries(options))).pipe(z.map(editionSchema, ruleOptionsSchema)).readonly();
|
|
41
49
|
var eslintPieceSettingsSchema = z.strictObject({
|
|
42
50
|
pluginNamespace: pluginNamespaceSchema,
|
|
43
51
|
pluginModule: pieceModulePathSchema,
|
|
44
52
|
rule: z.string(),
|
|
45
|
-
options:
|
|
53
|
+
options: ruleOptionsSchema.optional(),
|
|
54
|
+
optionsByEdition: optionsByEditionSchema.optional()
|
|
46
55
|
}).readonly();
|
|
47
|
-
var ruleOptionsOf = (request) =>
|
|
56
|
+
var ruleOptionsOf = (request) => {
|
|
57
|
+
const { settings, edition } = request;
|
|
58
|
+
const reached = [...settings.optionsByEdition ?? []].filter(([introducedIn]) => editionReaches({ edition, introducedIn }) === "reached").reduce((latest, candidate) => {
|
|
59
|
+
if (latest === void 0) return candidate;
|
|
60
|
+
return editionReaches({ edition: candidate[0], introducedIn: latest[0] }) === "reached" ? candidate : latest;
|
|
61
|
+
}, void 0);
|
|
62
|
+
return reached?.[1] ?? settings.options ?? [];
|
|
63
|
+
};
|
|
48
64
|
|
|
49
65
|
// src/infrastructure/engines/eslint/runner/hone-plugin/check-rule-id.ts
|
|
50
66
|
var CHECKS_PLUGIN_NAMESPACE = TOOL_IDENTITY.ownRuleSet;
|
|
@@ -53,12 +69,6 @@ var RULE_ID_PREFIX = `${CHECKS_PLUGIN_NAMESPACE}/`;
|
|
|
53
69
|
var checkRuleNameOf = (request) => checkAddressTextOf(request);
|
|
54
70
|
var checkRuleIdOf = (request) => `${RULE_ID_PREFIX}${checkRuleNameOf(request)}`;
|
|
55
71
|
var runsOnEslint = (request) => request.check.engines.some((engine) => engine.name === ESLINT_MECHANISM) ? "eslint" : "elsewhere";
|
|
56
|
-
var checkOfRuleId = (request) => {
|
|
57
|
-
const check = request.checks.find(
|
|
58
|
-
(candidate) => runsOnEslint({ check: candidate }) === "eslint" && checkRuleIdOf({ check: candidate }) === request.ruleId
|
|
59
|
-
);
|
|
60
|
-
return check === void 0 ? { found: "none" } : { found: "check", check };
|
|
61
|
-
};
|
|
62
72
|
var eslintRuleIdsOf = (request) => request.checks.filter((check) => runsOnEslint({ check }) === "eslint").map((check) => checkRuleIdOf({ check }));
|
|
63
73
|
|
|
64
74
|
// src/infrastructure/engines/eslint/runner/hone-plugin/checks-plugin.ts
|
|
@@ -210,9 +220,7 @@ var pieceSourceOf = async (request) => {
|
|
|
210
220
|
};
|
|
211
221
|
};
|
|
212
222
|
var honePluginAt = async (request) => {
|
|
213
|
-
const eslint = request.checks.filter(
|
|
214
|
-
(check) => runsOnEslint({ check }) === "eslint" && check.clause.ruleSet === TOOL_IDENTITY.ownRuleSet
|
|
215
|
-
);
|
|
223
|
+
const eslint = request.checks.filter((check) => runsOnEslint({ check }) === "eslint");
|
|
216
224
|
const sources = gatheredOutcomes({
|
|
217
225
|
outcomes: await Promise.all(
|
|
218
226
|
eslint.map(
|
|
@@ -807,7 +815,6 @@ export {
|
|
|
807
815
|
ESLINT_MECHANISM,
|
|
808
816
|
checkRuleIdOf,
|
|
809
817
|
runsOnEslint,
|
|
810
|
-
checkOfRuleId,
|
|
811
818
|
eslintRuleIdsOf,
|
|
812
819
|
eslintPluginModuleSchema,
|
|
813
820
|
honePluginAt,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// src/infrastructure/engines/walker/runner/pieces/syntax-parentheses.ts
|
|
2
|
+
var withoutParentheses = ({ syntaxApi, node }) => syntaxApi.isParenthesizedExpression(node) ? withoutParentheses({ syntaxApi, node: node.expression }) : node;
|
|
3
|
+
var outermostParenthesesOf = ({ syntaxApi, node }) => node.parent !== void 0 && syntaxApi.isParenthesizedExpression(node.parent) ? outermostParenthesesOf({ syntaxApi, node: node.parent }) : node;
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
withoutParentheses,
|
|
7
|
+
outermostParenthesesOf
|
|
8
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/infrastructure/engines/protocol/toolchain/toolchain-bound-runner.ts
|
|
2
|
+
var builtOnce = (request) => request.toolchain.then(
|
|
3
|
+
(loaded) => loaded.outcome === "failed" ? loaded : { outcome: "ok", value: request.runnerOf(loaded.value) }
|
|
4
|
+
);
|
|
5
|
+
var withRunner = (request) => request.runner.then((built) => built.outcome === "failed" ? built : request.act(built.value));
|
|
6
|
+
var toolchainBoundNamedChecksRunner = (request) => {
|
|
7
|
+
const runner = builtOnce(request);
|
|
8
|
+
return {
|
|
9
|
+
fileScope: request.fileScope,
|
|
10
|
+
projectedKinds: request.projectedKinds,
|
|
11
|
+
run: (run) => runner.then((built) => built.outcome === "failed" ? built : built.value.run(run)),
|
|
12
|
+
conform: (conform) => withRunner({ runner, act: (built) => built.conform(conform) }),
|
|
13
|
+
project: (project) => runner.then((built) => built.outcome === "failed" ? built : built.value.project(project))
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
toolchainBoundNamedChecksRunner
|
|
19
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TOOL_RULE_SET,
|
|
3
|
+
anchorKindSchema,
|
|
4
|
+
checkAddressOfNames,
|
|
5
|
+
isCatalogueName,
|
|
6
|
+
namedPieceFolderSegmentsOf,
|
|
7
|
+
parsedJson,
|
|
8
|
+
pieceFileSchema
|
|
9
|
+
} from "./chunk-BKQ3K766.js";
|
|
10
|
+
import {
|
|
11
|
+
isRuleSetName
|
|
12
|
+
} from "./chunk-OO5KV7KN.js";
|
|
13
|
+
|
|
14
|
+
// src/domain/rule-set/rule-set-identity.ts
|
|
15
|
+
var RULE_SET_SEPARATOR = "/";
|
|
16
|
+
var ownedNameText = (request) => request.ruleSet === TOOL_RULE_SET ? request.name : `${request.ruleSet.name}${RULE_SET_SEPARATOR}${request.name}`;
|
|
17
|
+
var sameOwnedName = (request) => ownedNameText(request.left) === ownedNameText(request.right) ? "same" : "different";
|
|
18
|
+
var teamRuleSetOf = (request) => isRuleSetName(request.name) && request.name !== TOOL_RULE_SET ? { name: request.name } : void 0;
|
|
19
|
+
var ownerOf = (request) => {
|
|
20
|
+
if (request.text === TOOL_RULE_SET) return TOOL_RULE_SET;
|
|
21
|
+
return teamRuleSetOf({ name: request.text });
|
|
22
|
+
};
|
|
23
|
+
var isOwnerAndName = (parts) => parts.length === 2;
|
|
24
|
+
var ownedNameOf = (request) => {
|
|
25
|
+
const parts = request.text.split(RULE_SET_SEPARATOR);
|
|
26
|
+
if (!isOwnerAndName(parts)) {
|
|
27
|
+
return parts.length === 1 ? { ruleSet: TOOL_RULE_SET, name: request.text } : "not-an-owned-name";
|
|
28
|
+
}
|
|
29
|
+
const [owner, name] = parts;
|
|
30
|
+
const ruleSet = ownerOf({ text: owner });
|
|
31
|
+
return ruleSet === void 0 || name === "" ? "not-an-owned-name" : { ruleSet, name };
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/infrastructure/engines/named-piece.ts
|
|
35
|
+
import { z } from "zod";
|
|
36
|
+
var legacyPieceEntry = pieceFileSchema.shape.clauses.element.shape;
|
|
37
|
+
var catalogueNameSchema = z.string().refine(isCatalogueName);
|
|
38
|
+
var namedPieceImplementationSchema = z.strictObject({
|
|
39
|
+
symptom: catalogueNameSchema,
|
|
40
|
+
check: catalogueNameSchema
|
|
41
|
+
});
|
|
42
|
+
var checkDeclaration = {
|
|
43
|
+
version: z.literal(2),
|
|
44
|
+
exceptions: z.enum(["allowed", "refused"]).default("allowed"),
|
|
45
|
+
checkSettings: legacyPieceEntry.clauseSettings
|
|
46
|
+
};
|
|
47
|
+
var implementationSchema = z.strictObject({
|
|
48
|
+
...checkDeclaration,
|
|
49
|
+
anchor: anchorKindSchema,
|
|
50
|
+
settings: z.record(z.string(), z.json()),
|
|
51
|
+
forms: z.record(z.string(), namedPieceImplementationSchema).default({}),
|
|
52
|
+
editions: legacyPieceEntry.editions
|
|
53
|
+
});
|
|
54
|
+
var SHARED_SETTING_FIELDS = /* @__PURE__ */ new Set([
|
|
55
|
+
"module",
|
|
56
|
+
"pluginModule",
|
|
57
|
+
"pluginNamespace"
|
|
58
|
+
]);
|
|
59
|
+
var pointerSchema = z.strictObject({
|
|
60
|
+
...checkDeclaration,
|
|
61
|
+
anchor: anchorKindSchema.optional(),
|
|
62
|
+
settings: z.record(z.string(), z.json()).refine((settings) => Object.keys(settings).every((key) => !SHARED_SETTING_FIELDS.has(key)), {
|
|
63
|
+
error: "implementation settings belong to the referenced declaration"
|
|
64
|
+
}).default({}),
|
|
65
|
+
implementation: namedPieceImplementationSchema,
|
|
66
|
+
editions: z.union([z.undefined(), legacyPieceEntry.editions]),
|
|
67
|
+
examples: z.literal("with-implementation").optional()
|
|
68
|
+
});
|
|
69
|
+
var namedPieceSchema = z.union([implementationSchema, pointerSchema]);
|
|
70
|
+
var readPieceDeclaration = (request) => {
|
|
71
|
+
const text = request.fileText.read({ path: request.path });
|
|
72
|
+
if (text.outcome === "failed") {
|
|
73
|
+
return {
|
|
74
|
+
outcome: "failed",
|
|
75
|
+
error: {
|
|
76
|
+
kind: "file-unreadable",
|
|
77
|
+
path: request.path,
|
|
78
|
+
detail: `${request.address}: ${text.error.detail}`
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const document = parsedJson({ text: text.value });
|
|
83
|
+
if (document.outcome === "failed") {
|
|
84
|
+
return {
|
|
85
|
+
outcome: "failed",
|
|
86
|
+
error: {
|
|
87
|
+
kind: "file-malformed",
|
|
88
|
+
path: request.path,
|
|
89
|
+
detail: `${request.address}: ${document.error}`
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const piece = namedPieceSchema.safeParse(document.value);
|
|
94
|
+
return piece.success ? { outcome: "ok", value: piece.data } : {
|
|
95
|
+
outcome: "failed",
|
|
96
|
+
error: {
|
|
97
|
+
kind: "file-malformed",
|
|
98
|
+
path: request.path,
|
|
99
|
+
detail: `${request.address}: ${z.prettifyError(piece.error)}`
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
var namedPiecePathOf = (request) => request.path.join({ segments: [...namedPieceFolderSegmentsOf(request), "piece.json"] });
|
|
104
|
+
var declarationAt = (request) => {
|
|
105
|
+
const address = `${request.symptom}#${request.check}`;
|
|
106
|
+
const path = request.declarationPath;
|
|
107
|
+
if (request.fileText.exists({ path }) === "absent") {
|
|
108
|
+
return {
|
|
109
|
+
outcome: "failed",
|
|
110
|
+
error: { kind: "piece-missing", address, mechanism: request.mechanism }
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return readPieceDeclaration({ fileText: request.fileText, path, address });
|
|
114
|
+
};
|
|
115
|
+
var sharedPieceAt = (request) => {
|
|
116
|
+
const declarationPath = namedPiecePathOf(request);
|
|
117
|
+
const shared = declarationAt({ ...request, declarationPath });
|
|
118
|
+
if (shared.outcome === "failed") {
|
|
119
|
+
return shared.error.kind === "piece-missing" ? {
|
|
120
|
+
outcome: "failed",
|
|
121
|
+
error: {
|
|
122
|
+
kind: "file-malformed",
|
|
123
|
+
path: declarationPath,
|
|
124
|
+
detail: "referenced implementation is missing"
|
|
125
|
+
}
|
|
126
|
+
} : shared;
|
|
127
|
+
}
|
|
128
|
+
return "implementation" in shared.value ? {
|
|
129
|
+
outcome: "failed",
|
|
130
|
+
error: {
|
|
131
|
+
kind: "file-malformed",
|
|
132
|
+
path: declarationPath,
|
|
133
|
+
detail: "an implementation reference must point to a piece declaring its implementation"
|
|
134
|
+
}
|
|
135
|
+
} : { outcome: "ok", value: shared.value };
|
|
136
|
+
};
|
|
137
|
+
var readNamedPiece = (request) => {
|
|
138
|
+
const declarationPath = namedPiecePathOf(request);
|
|
139
|
+
const declared = declarationAt({ ...request, declarationPath });
|
|
140
|
+
if (declared.outcome === "failed") return declared;
|
|
141
|
+
const piece = declared.value;
|
|
142
|
+
const localCheck = { symptom: request.symptom, check: request.check };
|
|
143
|
+
const implementation = "implementation" in piece ? piece.implementation : localCheck;
|
|
144
|
+
const shared = "implementation" in piece ? sharedPieceAt({ ...request, ...implementation }) : { outcome: "ok", value: piece };
|
|
145
|
+
if (shared.outcome === "failed") return shared;
|
|
146
|
+
const owner = shared.value;
|
|
147
|
+
const exampleOwner = "examples" in piece && piece.examples === "with-implementation" ? implementation : localCheck;
|
|
148
|
+
return {
|
|
149
|
+
outcome: "ok",
|
|
150
|
+
value: {
|
|
151
|
+
anchor: piece.anchor ?? owner.anchor,
|
|
152
|
+
exceptions: piece.exceptions,
|
|
153
|
+
settings: { ...owner.settings, ...piece.settings },
|
|
154
|
+
declarations: piece.checkSettings,
|
|
155
|
+
editions: piece.editions ?? owner.editions,
|
|
156
|
+
forms: owner.forms,
|
|
157
|
+
declarationPath,
|
|
158
|
+
exampleOwner,
|
|
159
|
+
examplesPath: request.path.join({
|
|
160
|
+
segments: [
|
|
161
|
+
...namedPieceFolderSegmentsOf({ ...request, ...exampleOwner }),
|
|
162
|
+
`${exampleOwner.check}.examples.json`
|
|
163
|
+
]
|
|
164
|
+
}),
|
|
165
|
+
pieceRoot: request.path.join({
|
|
166
|
+
segments: namedPieceFolderSegmentsOf({ ...request, ...implementation })
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
var checkPieceOf = (piece) => ({
|
|
172
|
+
anchor: piece.anchor,
|
|
173
|
+
exceptions: piece.exceptions,
|
|
174
|
+
pieceRoot: piece.pieceRoot,
|
|
175
|
+
settings: piece.settings,
|
|
176
|
+
declarations: piece.declarations,
|
|
177
|
+
editions: piece.editions,
|
|
178
|
+
forms: Object.fromEntries(
|
|
179
|
+
Object.entries(piece.forms).map(([form, name]) => [form, checkAddressOfNames(name)])
|
|
180
|
+
)
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
export {
|
|
184
|
+
ownedNameText,
|
|
185
|
+
sameOwnedName,
|
|
186
|
+
teamRuleSetOf,
|
|
187
|
+
ownedNameOf,
|
|
188
|
+
namedPiecePathOf,
|
|
189
|
+
readNamedPiece,
|
|
190
|
+
checkPieceOf
|
|
191
|
+
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
withoutParentheses
|
|
3
|
+
} from "./chunk-EBX57Z3V.js";
|
|
4
|
+
import {
|
|
5
|
+
sourceSnippetAt
|
|
6
|
+
} from "./chunk-5AKHEW6V.js";
|
|
7
|
+
|
|
1
8
|
// src/infrastructure/engines/walker/runner/pieces/cast-shape.ts
|
|
2
|
-
var
|
|
3
|
-
var castSnippetAt = (request) => {
|
|
4
|
-
const snippet = request.sourceFile.text.slice(request.position, request.position + SNIPPET_MAX_LENGTH).replace(/\n/g, " ");
|
|
5
|
-
return snippet.length === SNIPPET_MAX_LENGTH ? `${snippet}\u2026` : snippet;
|
|
6
|
-
};
|
|
9
|
+
var castSnippetAt = (request) => sourceSnippetAt({ source: request.sourceFile.text, position: request.position });
|
|
7
10
|
var assertionOf = (request) => {
|
|
8
11
|
const { node, syntaxApi } = request;
|
|
9
12
|
if (syntaxApi.isAsExpression(node))
|
|
@@ -25,13 +28,13 @@ var satisfiesOperand = (request) => {
|
|
|
25
28
|
};
|
|
26
29
|
var wrappedOperand = (request) => {
|
|
27
30
|
const { node, syntaxApi } = request;
|
|
28
|
-
if (syntaxApi.
|
|
29
|
-
return node.expression;
|
|
31
|
+
if (syntaxApi.isNonNullExpression(node)) return node.expression;
|
|
30
32
|
return satisfiesOperand({ node, syntaxApi });
|
|
31
33
|
};
|
|
32
34
|
var unwrappedExpression = (request) => {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
+
const node = withoutParentheses(request);
|
|
36
|
+
const operand = wrappedOperand({ ...request, node });
|
|
37
|
+
return operand === void 0 ? node : unwrappedExpression({ node: operand, syntaxApi: request.syntaxApi });
|
|
35
38
|
};
|
|
36
39
|
var unknownTypeOf = (request) => request.typeNode.kind === request.syntaxApi.SyntaxKind.UnknownKeyword ? "unknown" : "other";
|
|
37
40
|
var constTypeOf = (request) => {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ownedNameText
|
|
3
|
+
} from "./chunk-FPIP7JEC.js";
|
|
4
|
+
import {
|
|
5
|
+
checkAddressTextOf,
|
|
6
|
+
sameClauseAddress
|
|
7
|
+
} from "./chunk-BKQ3K766.js";
|
|
8
|
+
|
|
9
|
+
// src/domain/language-layer/check-address.ts
|
|
10
|
+
var NO_CHECK = { found: "none" };
|
|
11
|
+
var foundAmong = (request) => {
|
|
12
|
+
const [check] = request.checks;
|
|
13
|
+
return check === void 0 ? NO_CHECK : { found: "check", check };
|
|
14
|
+
};
|
|
15
|
+
var checkAddressOf = (request) => checkAddressTextOf(request);
|
|
16
|
+
var qualifiedCheckAddressOf = (request) => ownedNameText({ ruleSet: request.check.symptom.ruleSet, name: checkAddressTextOf(request) });
|
|
17
|
+
var qualifiedAddressOf = (request) => ownedNameText({ ruleSet: request.ruleSet, name: request.address });
|
|
18
|
+
var checkAt = (request) => foundAmong({
|
|
19
|
+
checks: request.catalogue.checks.filter(
|
|
20
|
+
(candidate) => checkAddressOf({ check: candidate }) === request.address
|
|
21
|
+
)
|
|
22
|
+
});
|
|
23
|
+
var checksOf = (request) => request.catalogue.checks.filter(
|
|
24
|
+
(check) => check.clause !== void 0 && sameClauseAddress({ left: check.clause, right: request.clause }) === "same"
|
|
25
|
+
);
|
|
26
|
+
var checkNamedAt = (request) => {
|
|
27
|
+
const { address } = request;
|
|
28
|
+
if (address === void 0) {
|
|
29
|
+
return { named: "unnamed" };
|
|
30
|
+
}
|
|
31
|
+
const found = foundAmong({
|
|
32
|
+
checks: checksOf(request).filter((check) => checkAddressOf({ check }) === address)
|
|
33
|
+
});
|
|
34
|
+
return found.found === "check" ? { named: "check", check: found.check } : { named: "not-of-the-clause", address };
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/domain/settings/every-ok.ts
|
|
38
|
+
var everyOk = (request) => request.entries.reduce(
|
|
39
|
+
(sofar, entry) => {
|
|
40
|
+
if (sofar.outcome === "failed") {
|
|
41
|
+
return sofar;
|
|
42
|
+
}
|
|
43
|
+
const resolved = request.resolve(entry);
|
|
44
|
+
return resolved.outcome === "failed" ? resolved : { outcome: "ok", value: [...sofar.value, resolved.value] };
|
|
45
|
+
},
|
|
46
|
+
{ outcome: "ok", value: [] }
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
checkAddressOf,
|
|
51
|
+
qualifiedCheckAddressOf,
|
|
52
|
+
qualifiedAddressOf,
|
|
53
|
+
checkAt,
|
|
54
|
+
checksOf,
|
|
55
|
+
checkNamedAt,
|
|
56
|
+
everyOk
|
|
57
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sourceSnippetOf
|
|
3
|
+
} from "./chunk-5AKHEW6V.js";
|
|
4
|
+
|
|
5
|
+
// src/infrastructure/engines/walker/runner/pieces/syntax-node-check.ts
|
|
6
|
+
var syntaxNodeCheck = (request) => ({
|
|
7
|
+
prepare: ({ bindings, repository, syntaxApi }) => ({
|
|
8
|
+
outcome: "ok",
|
|
9
|
+
value: {
|
|
10
|
+
prepareFile: ({ file }) => request.eligibility({ file, testFiles: repository.testFiles }) === "skipped" || bindings.length === 0 ? { outcome: "ok", value: { kind: "skipped" } } : {
|
|
11
|
+
outcome: "ok",
|
|
12
|
+
value: {
|
|
13
|
+
kind: "syntax",
|
|
14
|
+
begin: ({ sourceFile, anchorAt }) => {
|
|
15
|
+
const hits = [];
|
|
16
|
+
return {
|
|
17
|
+
enter: ({ node }) => {
|
|
18
|
+
const sight = request.found({ syntaxApi, node, sourceFile });
|
|
19
|
+
if (sight === void 0) return;
|
|
20
|
+
const anchor = anchorAt({ position: sight.at.getStart(sourceFile) });
|
|
21
|
+
hits.push(
|
|
22
|
+
...bindings.map(({ address }) => ({
|
|
23
|
+
check: address,
|
|
24
|
+
anchor,
|
|
25
|
+
snippet: sourceSnippetOf(sight.snippet)
|
|
26
|
+
}))
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
finish: () => hits
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
finish: () => ({ outcome: "ok", value: [] })
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
syntaxNodeCheck
|
|
41
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// src/infrastructure/engines/walker/runner/pieces/node-built-in-import.ts
|
|
2
|
+
var WHOLE_MODULE = { kind: "module" };
|
|
3
|
+
var NAMESPACE = { kind: "namespace" };
|
|
4
|
+
var requiredSpecifierOf = ({
|
|
5
|
+
syntaxApi,
|
|
6
|
+
initializer,
|
|
7
|
+
declarationsOf
|
|
8
|
+
}) => {
|
|
9
|
+
if (initializer === void 0 || !syntaxApi.isCallExpression(initializer)) return void 0;
|
|
10
|
+
const { expression, arguments: callArguments } = initializer;
|
|
11
|
+
return syntaxApi.isIdentifier(expression) && expression.text === "require" && declarationsOf(expression).length === 0 ? callArguments[0] : void 0;
|
|
12
|
+
};
|
|
13
|
+
var boundImportOf = ({
|
|
14
|
+
syntaxApi,
|
|
15
|
+
declaration,
|
|
16
|
+
declarationsOf
|
|
17
|
+
}) => {
|
|
18
|
+
if (syntaxApi.isVariableDeclaration(declaration))
|
|
19
|
+
return {
|
|
20
|
+
specifier: requiredSpecifierOf({
|
|
21
|
+
syntaxApi,
|
|
22
|
+
initializer: declaration.initializer,
|
|
23
|
+
declarationsOf
|
|
24
|
+
}),
|
|
25
|
+
shape: WHOLE_MODULE
|
|
26
|
+
};
|
|
27
|
+
if (syntaxApi.isImportEqualsDeclaration(declaration))
|
|
28
|
+
return syntaxApi.isExternalModuleReference(declaration.moduleReference) ? { specifier: declaration.moduleReference.expression, shape: WHOLE_MODULE } : void 0;
|
|
29
|
+
if (syntaxApi.isImportClause(declaration))
|
|
30
|
+
return { specifier: declaration.parent.moduleSpecifier, shape: WHOLE_MODULE };
|
|
31
|
+
if (syntaxApi.isNamespaceImport(declaration))
|
|
32
|
+
return { specifier: declaration.parent.parent.moduleSpecifier, shape: NAMESPACE };
|
|
33
|
+
if (!syntaxApi.isImportSpecifier(declaration)) return void 0;
|
|
34
|
+
const name = (declaration.propertyName ?? declaration.name).text;
|
|
35
|
+
return {
|
|
36
|
+
specifier: declaration.parent.parent.parent.moduleSpecifier,
|
|
37
|
+
shape: name === "default" ? WHOLE_MODULE : { kind: "named", name }
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
var builtInImportOf = ({
|
|
41
|
+
syntaxApi,
|
|
42
|
+
identifier,
|
|
43
|
+
declarationsOf,
|
|
44
|
+
builtIn
|
|
45
|
+
}) => declarationsOf(identifier).map((declaration) => boundImportOf({ syntaxApi, declaration, declarationsOf })).find(
|
|
46
|
+
(bound) => bound?.specifier !== void 0 && syntaxApi.isStringLiteral(bound.specifier) && (bound.specifier.text === builtIn || bound.specifier.text === `node:${builtIn}`)
|
|
47
|
+
)?.shape;
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
builtInImportOf
|
|
51
|
+
};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
sameClauseAddress
|
|
3
|
-
} from "./chunk-M6SOGWT7.js";
|
|
4
|
-
|
|
5
1
|
// src/infrastructure/engines/walker/runner/pieces/type-directives.ts
|
|
6
2
|
var TYPE_DIRECTIVES = ["@ts-expect-error", "@ts-ignore", "@ts-nocheck"];
|
|
7
3
|
var LINE_SUPPRESSIONS = [
|
|
@@ -63,11 +59,7 @@ var typeDirectiveReaderFor = (request) => {
|
|
|
63
59
|
placement: commentPlacementOf({ range, fileHeaderPositions, syntaxApi })
|
|
64
60
|
});
|
|
65
61
|
};
|
|
66
|
-
var escapesOf = (request) => request.escapes.filter(
|
|
67
|
-
(directiveEscape) => request.clauses.some(
|
|
68
|
-
(clause) => sameClauseAddress({ left: clause, right: directiveEscape.clause }) === "same"
|
|
69
|
-
)
|
|
70
|
-
);
|
|
62
|
+
var escapesOf = (request) => request.escapes.filter((directiveEscape) => request.checks.includes(directiveEscape.check));
|
|
71
63
|
var directiveEscapesIn = (request) => {
|
|
72
64
|
if (request.escapes.length === 0) return [];
|
|
73
65
|
const readDirective = typeDirectiveReaderFor(request);
|
|
@@ -78,11 +70,11 @@ var directiveEscapesIn = (request) => {
|
|
|
78
70
|
const text = request.sourceFile.text.slice(range.pos, range.end).trim();
|
|
79
71
|
return request.escapes.filter((directiveEscape) => directiveEscape.directives.includes(reading.directive)).map((directiveEscape) => ({
|
|
80
72
|
kind: "inline-disable",
|
|
81
|
-
|
|
73
|
+
check: directiveEscape.check,
|
|
82
74
|
file: request.file,
|
|
83
75
|
line,
|
|
84
76
|
text,
|
|
85
|
-
reach: "one-
|
|
77
|
+
reach: "one-check"
|
|
86
78
|
}));
|
|
87
79
|
});
|
|
88
80
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/domain/rule-set/identifiers.ts
|
|
2
|
+
var RULE_SET_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
3
|
+
var DISCIPLINE_ID_PATTERN = /^[A-Z]{2,4}-[0-9]+[a-z]?$/;
|
|
4
|
+
var CLAUSE_ID_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
5
|
+
var NOT_RUN = "not-run";
|
|
6
|
+
var NOT_ADOPTED = "not-adopted";
|
|
7
|
+
var isRuleSetName = (text) => RULE_SET_NAME_PATTERN.test(text);
|
|
8
|
+
var isDisciplineId = (text) => DISCIPLINE_ID_PATTERN.test(text);
|
|
9
|
+
var isClauseId = (text) => CLAUSE_ID_PATTERN.test(text);
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
NOT_RUN,
|
|
13
|
+
NOT_ADOPTED,
|
|
14
|
+
isRuleSetName,
|
|
15
|
+
isDisciplineId,
|
|
16
|
+
isClauseId
|
|
17
|
+
};
|