@hailstails/hone 2.0.0-pre.4 → 2.0.0-pre.6

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.
Files changed (135) hide show
  1. package/ADOPTING.md +10 -19
  2. package/CHANGELOG.md +46 -0
  3. package/MIGRATING.md +25 -14
  4. package/README.md +3 -4
  5. package/chunks/chunk-2U5EKYGS.js +14348 -0
  6. package/chunks/{chunk-FPIP7JEC.js → chunk-4AJQHZ7I.js} +1 -1
  7. package/chunks/chunk-4PHKVNM3.js +2377 -0
  8. package/chunks/{chunk-CXM5KBZX.js → chunk-6LTJRJOE.js} +1 -1
  9. package/chunks/{chunk-PVSC4SE3.js → chunk-BISP2JOL.js} +4 -6
  10. package/chunks/{chunk-BRANVR7K.js → chunk-FRE5IA3C.js} +1 -1
  11. package/chunks/{chunk-E4D5WDRX.js → chunk-GMLT3MHO.js} +252 -254
  12. package/chunks/chunk-M4VSJ27S.js +139 -0
  13. package/chunks/{chunk-YGMO5Z6U.js → chunk-P2VHWLK4.js} +182 -193
  14. package/chunks/{chunk-LD766VWU.js → chunk-U6W65ZOF.js} +31 -2
  15. package/chunks/{chunk-BKQ3K766.js → chunk-WPEOCLTP.js} +39 -33
  16. package/chunks/{chunk-A3RL4O5V.js → chunk-XNIXPQQ5.js} +35 -2
  17. package/docs/extending.md +2 -2
  18. package/methods/lenses/function-first.md +2 -2
  19. package/package.json +1 -1
  20. package/rules/README.md +5 -3
  21. package/rules/SPIRIT.md +1 -1
  22. package/rules/numbers.md +4 -4
  23. package/rules/principles/no-leak-across-a-boundary.md +1 -1
  24. package/rules/principles.md +1 -1
  25. package/rules/record-kinds/authorised-location.md +1 -1
  26. package/rules/records.md +11 -19
  27. package/rules/rules.md +5 -5
  28. package/rules/sources.md +6 -7
  29. package/rules/typescript/checks.md +55 -387
  30. package/rules/typescript/recipes/adapter-per-outside-party.md +10 -5
  31. package/rules/typescript/recipes/assert-to-narrow.md +114 -4
  32. package/rules/typescript/recipes/closure-factory.md +5 -5
  33. package/rules/typescript/recipes/companion-test-file.md +5 -3
  34. package/rules/typescript/recipes/composed-orchestrator.md +6 -4
  35. package/rules/typescript/recipes/composition-root.md +5 -3
  36. package/rules/typescript/recipes/{bounded-context-generic.md → constrained-context-generic.md} +6 -4
  37. package/rules/typescript/recipes/copy-never-write-in.md +6 -4
  38. package/rules/typescript/recipes/declared-not-bundled.md +5 -3
  39. package/rules/typescript/recipes/dependency-record.md +5 -3
  40. package/rules/typescript/recipes/domain-vocabulary-list.md +5 -3
  41. package/rules/typescript/recipes/entity-module.md +8 -5
  42. package/rules/typescript/recipes/exact-pins-and-a-lock-file.md +5 -3
  43. package/rules/typescript/recipes/extension-outside-the-vendored-code.md +5 -3
  44. package/rules/typescript/recipes/failure-asserted-as-a-value.md +44 -4
  45. package/rules/typescript/recipes/failure-mapping-at-the-adapter.md +8 -5
  46. package/rules/typescript/recipes/fix-the-declaration-not-the-value.md +5 -3
  47. package/rules/typescript/recipes/functional-iteration.md +8 -3
  48. package/rules/typescript/recipes/guard-clauses.md +5 -3
  49. package/rules/typescript/recipes/integration-test-owns-its-scratch.md +5 -3
  50. package/rules/typescript/recipes/integration-test-suffix.md +5 -3
  51. package/rules/typescript/recipes/it-each-over-typed-rows.md +117 -0
  52. package/rules/typescript/recipes/map-out-at-the-adapter.md +36 -4
  53. package/rules/typescript/recipes/meaning-in-names-not-comments.md +5 -5
  54. package/rules/typescript/recipes/named-exported-type.md +5 -3
  55. package/rules/typescript/recipes/narrow-ports.md +5 -3
  56. package/rules/typescript/recipes/one-argument-object.md +8 -3
  57. package/rules/typescript/recipes/{port-in-the-domain.md → port-in-a-module-of-its-own.md} +7 -5
  58. package/rules/typescript/recipes/ports-in-the-argument.md +5 -3
  59. package/rules/typescript/recipes/repo-scripts-only.md +5 -3
  60. package/rules/typescript/recipes/result-union.md +5 -5
  61. package/rules/typescript/recipes/screaming-folders.md +5 -5
  62. package/rules/typescript/recipes/shared-strict-base-config.md +5 -5
  63. package/rules/typescript/recipes/stub-with-vi-fn.md +130 -0
  64. package/rules/typescript/recipes/tagged-union-and-exhaustive-switch.md +5 -3
  65. package/rules/typescript/recipes/whole-words.md +5 -3
  66. package/rules/typescript/recipes/whole-written-out-expectation.md +284 -4
  67. package/rules/typescript/recipes/world-values-through-a-port.md +5 -3
  68. package/rules/typescript/recipes/zod-at-the-producers-adapter.md +8 -3
  69. package/rules/typescript/recipes.md +567 -21
  70. package/rules/typescript/symptoms/ambient-randomness.md +1 -1
  71. package/rules/typescript/symptoms/answer-set-in-a-hook.md +1 -1
  72. package/rules/typescript/symptoms/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site.md +1 -1
  73. package/rules/typescript/symptoms/{assertion-outside-a-test.md → assertion-outside-a-test-body.md} +1 -1
  74. package/rules/typescript/symptoms/branch-in-a-test/test-body.md +10 -184
  75. package/rules/typescript/symptoms/branch-in-a-test.md +11 -1
  76. package/rules/typescript/symptoms/claimed-type/non-null-assertions.md +1 -1
  77. package/rules/typescript/symptoms/{code-or-prose-read-as-text.md → code-or-prose-read-as-text-in-a-test.md} +2 -2
  78. package/rules/typescript/symptoms/computed-value-in-a-test/test-body.md +26 -117
  79. package/rules/typescript/symptoms/computed-value-in-a-test.md +1 -1
  80. package/rules/typescript/symptoms/date-used-directly.md +1 -1
  81. package/rules/typescript/symptoms/default-for-a-required-value.md +1 -1
  82. package/rules/typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md +1 -18
  83. package/rules/typescript/symptoms/double-with-a-body.md +1 -1
  84. package/rules/typescript/symptoms/{export-from-a-test-file.md → export-from-a-test.md} +1 -1
  85. package/rules/typescript/symptoms/failure-shaped-as-success.md +1 -1
  86. package/rules/typescript/symptoms/inherited-environment-in-a-subprocess/git-spawn-environment.md +1 -1
  87. package/rules/typescript/symptoms/inner-layer-imports-outer.md +1 -1
  88. package/rules/typescript/symptoms/library-class-built-in-place.md +1 -1
  89. package/rules/typescript/symptoms/loop-keyword/loop-statement.md +1 -1
  90. package/rules/typescript/symptoms/outside-import-past-a-boundary/import-or-require.md +1 -0
  91. package/rules/typescript/symptoms/outside-import-past-a-boundary.md +5 -4
  92. package/rules/typescript/symptoms/outside-type-in-a-signature.md +2 -2
  93. package/rules/typescript/symptoms/{port-outside-the-domain.md → port-beside-its-adapter.md} +2 -2
  94. package/rules/typescript/symptoms/port-named-for-a-mechanism.md +1 -1
  95. package/rules/typescript/symptoms/process-global-used-in-place.md +1 -1
  96. package/rules/typescript/symptoms/rebinding/test-body.md +1 -18
  97. package/rules/typescript/symptoms/rebinding.md +11 -1
  98. package/rules/typescript/symptoms/schema-past-its-adapter.md +2 -2
  99. package/rules/typescript/symptoms/text-past-its-reader/test-body.md +2 -17
  100. package/rules/typescript/symptoms/text-past-its-reader.md +1 -1
  101. package/rules/typescript/symptoms/throw-or-catch-in-a-test/try-block.md +1 -25
  102. package/rules/typescript/symptoms/type-declared-in-a-test/test-type-declaration.md +1 -1
  103. package/rules/typescript/symptoms/unasserted-call.md +1 -1
  104. package/rules/typescript/symptoms.md +35 -35
  105. package/src/application/conformance/conformance-testing-types.d.ts +2 -0
  106. package/src/domain/language-layer/authored-item-types.d.ts +21 -5
  107. package/src/domain/runner/runner-result-types.d.ts +1 -2
  108. package/src/eslint-plugin.js +40 -38
  109. package/src/hone.js +15 -13638
  110. package/src/infrastructure/disciplines-file/version-one-names.json +4 -5
  111. package/src/infrastructure/engines/eslint/runner/runner.js +56 -70
  112. package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/assertion-site.js +1 -1
  113. package/src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body-logic.js +39 -65
  114. package/src/infrastructure/engines/walker/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read/raw-read.js +1 -1
  115. package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/test-file-export.js +1 -1
  116. package/src/infrastructure/engines/walker/runner/runner.js +10 -10
  117. package/src/infrastructure/engines/walker/strictness-weakened/strict/compiler-overrides.js +3 -3
  118. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.examples.json +15 -3
  119. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.js +118 -4
  120. package/src/measure-engines.process.js +80 -0
  121. package/src/testing.d.ts +1 -0
  122. package/src/testing.js +111 -26
  123. package/chunks/chunk-7FVSZ2VL.js +0 -1304
  124. package/chunks/chunk-BIDD2YWP.js +0 -398
  125. package/rules/record-kinds/boundary-record.md +0 -9
  126. package/rules/typescript/recipes/iteach-over-typed-rows.md +0 -18
  127. package/rules/typescript/recipes/stub-with-vifn.md +0 -20
  128. /package/rules/typescript/symptoms/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read.md +0 -0
  129. /package/rules/typescript/symptoms/{export-from-a-test-file → export-from-a-test}/test-file-export.md +0 -0
  130. /package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/assertion-site.examples.json +0 -0
  131. /package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/piece.json +0 -0
  132. /package/src/infrastructure/engines/walker/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read/piece.json +0 -0
  133. /package/src/infrastructure/engines/walker/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read/raw-read.examples.json +0 -0
  134. /package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/piece.json +0 -0
  135. /package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/test-file-export.examples.json +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createDefaultPathPort,
3
3
  installRootAboveEntry
4
- } from "./chunk-BKQ3K766.js";
4
+ } from "./chunk-WPEOCLTP.js";
5
5
 
6
6
  // src/infrastructure/node/modules/package-location-port.ts
7
7
  var path = createDefaultPathPort({});
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  clauseAddressObjectSchema
3
- } from "./chunk-BRANVR7K.js";
3
+ } from "./chunk-FRE5IA3C.js";
4
4
  import {
5
5
  snippetSchema
6
6
  } from "./chunk-Z6JHBNDS.js";
@@ -11,7 +11,7 @@ import {
11
11
  isCheckAddressText,
12
12
  repoPathSchema,
13
13
  ruleSetIdentitySchema
14
- } from "./chunk-BKQ3K766.js";
14
+ } from "./chunk-WPEOCLTP.js";
15
15
 
16
16
  // src/infrastructure/engines/protocol/runner-module/runner-result-schema.ts
17
17
  import { z as z3 } from "zod";
@@ -62,12 +62,10 @@ var nativeExceptionKindSchema = z3.enum([
62
62
  "inline-rule-config",
63
63
  "command-line-option"
64
64
  ]);
65
- var PAGE_SECTION = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
66
- var PAGE_UNDER_ITS_FOLDER = /^(?:[A-Za-z0-9_-][A-Za-z0-9_.-]*\/)*[A-Za-z0-9_-][A-Za-z0-9_.-]*\.md$/;
65
+ var FORM_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
67
66
  var remedySchema = z3.object({
68
67
  fix: z3.string().min(1),
69
- page: z3.string().regex(PAGE_UNDER_ITS_FOLDER),
70
- section: z3.string().regex(PAGE_SECTION)
68
+ form: z3.string().regex(FORM_NAME)
71
69
  }).readonly();
72
70
  var hitSchema = z3.object({
73
71
  clause: clauseAddressObjectSchema,
@@ -4,7 +4,7 @@ import {
4
4
  clauseIdSchema,
5
5
  disciplineIdSchema,
6
6
  ruleSetNameSchema
7
- } from "./chunk-BKQ3K766.js";
7
+ } from "./chunk-WPEOCLTP.js";
8
8
 
9
9
  // src/infrastructure/discipline-exceptions-folder/clause-address.ts
10
10
  import { z } from "zod";
@@ -1,13 +1,13 @@
1
+ import {
2
+ createDefaultPackageLocationPort
3
+ } from "./chunk-6LTJRJOE.js";
1
4
  import {
2
5
  everyOk
3
- } from "./chunk-LD766VWU.js";
6
+ } from "./chunk-U6W65ZOF.js";
4
7
  import {
5
8
  namedPiecePathOf,
6
9
  readNamedPiece
7
- } from "./chunk-FPIP7JEC.js";
8
- import {
9
- createDefaultPackageLocationPort
10
- } from "./chunk-CXM5KBZX.js";
10
+ } from "./chunk-4AJQHZ7I.js";
11
11
  import {
12
12
  TOOL_IDENTITY,
13
13
  checkAddressTextOf,
@@ -18,7 +18,7 @@ import {
18
18
  isRepoPathText,
19
19
  loadedPeer,
20
20
  moduleFileForm
21
- } from "./chunk-BKQ3K766.js";
21
+ } from "./chunk-WPEOCLTP.js";
22
22
  import {
23
23
  gatheredOutcomes,
24
24
  listedOutcome
@@ -30,226 +30,11 @@ import {
30
30
  __glob
31
31
  } from "./chunk-DGOLOS5A.js";
32
32
 
33
- // src/infrastructure/engines/eslint/runner/hone-plugin/hone-plugin.ts
33
+ // src/infrastructure/engines/eslint/runner/toolchain/eslint-toolchain.ts
34
34
  import { z as z4 } from "zod";
35
35
 
36
- // src/infrastructure/engines/eslint/runner/pieces/eslint-piece-settings-schema.ts
37
- import { z } from "zod";
38
- var pieceModulePathSchema = z.string().superRefine((text, context) => {
39
- if (isRepoPathText({ text }) === "not-repo-path" || moduleFileForm({ text }) === "not-module-file") {
40
- context.addIssue({
41
- code: "custom",
42
- message: "not a path inside the piece folder ending in .ts, or .js in a built install"
43
- });
44
- }
45
- });
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();
49
- var eslintPieceSettingsSchema = z.strictObject({
50
- pluginNamespace: pluginNamespaceSchema,
51
- pluginModule: pieceModulePathSchema,
52
- rule: z.string(),
53
- options: ruleOptionsSchema.optional(),
54
- optionsByEdition: optionsByEditionSchema.optional()
55
- }).readonly();
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
- };
64
-
65
- // src/infrastructure/engines/eslint/runner/hone-plugin/check-rule-id.ts
66
- var CHECKS_PLUGIN_NAMESPACE = TOOL_IDENTITY.ownRuleSet;
67
- var ESLINT_MECHANISM = "eslint";
68
- var RULE_ID_PREFIX = `${CHECKS_PLUGIN_NAMESPACE}/`;
69
- var checkRuleNameOf = (request) => checkAddressTextOf(request);
70
- var checkRuleIdOf = (request) => `${RULE_ID_PREFIX}${checkRuleNameOf(request)}`;
71
- var runsOnEslint = (request) => request.check.engines.some((engine) => engine.name === ESLINT_MECHANISM) ? "eslint" : "elsewhere";
72
- var eslintRuleIdsOf = (request) => request.checks.filter((check) => runsOnEslint({ check }) === "eslint").map((check) => checkRuleIdOf({ check }));
73
-
74
- // src/infrastructure/engines/eslint/runner/hone-plugin/checks-plugin.ts
75
- import { z as z3 } from "zod";
76
-
77
- // src/infrastructure/engines/eslint/runner/pieces/eslint-plugin-schema.ts
78
- import { z as z2 } from "zod";
79
- var ruleVisitorSchema = z2.record(
80
- z2.string(),
81
- z2.function({ input: z2.array(z2.unknown()), output: z2.unknown() })
82
- );
83
- var ruleSchema = z2.looseObject({
84
- meta: z2.looseObject({
85
- type: z2.enum(["problem", "suggestion", "layout"]),
86
- messages: z2.record(z2.string(), z2.string()).optional()
87
- }),
88
- create: z2.function({ input: [z2.unknown()], output: ruleVisitorSchema })
89
- });
90
- var eslintPluginModuleSchema = z2.object({
91
- default: z2.looseObject({ rules: z2.record(z2.string(), ruleSchema) })
92
- });
93
- var inlineConfigNodesSchema = z2.array(
94
- z2.looseObject({ type: z2.enum(["Line", "Block"]), value: z2.string() })
95
- );
96
-
97
- // src/infrastructure/engines/eslint/runner/hone-plugin/checks-plugin.ts
98
- var PLUGIN_META = { name: `${TOOL_IDENTITY.packageName}/eslint-plugin`, version: "0.0.0-local" };
99
- var NUMBERED_LEAD = /^CD-\d+: /;
100
- var inSymptomWords = (request) => `${request.title}: ${request.message.replace(NUMBERED_LEAD, "")}`;
101
- var unnumbered = (request) => typeof request.text === "string" ? request.text.replace(NUMBERED_LEAD, "") : request.text;
102
- var reportInSymptomWords = (request) => {
103
- const reportData = request.boundary.reportDataOf({ descriptor: request.descriptor });
104
- return reportData === void 0 ? request.descriptor : {
105
- ...request.descriptor,
106
- data: Object.fromEntries(
107
- Object.entries(reportData).map(([key, text]) => [key, unnumbered({ text })])
108
- )
109
- };
110
- };
111
- var contextInSymptomWords = (request) => Object.create(request.context, {
112
- report: {
113
- value: (descriptor) => request.context.report(reportInSymptomWords({ descriptor, boundary: request.boundary }))
114
- }
115
- });
116
- var messagesInSymptomWords = (request) => request.messages === void 0 ? void 0 : Object.fromEntries(
117
- Object.entries(request.messages).map(([messageId, message]) => [
118
- messageId,
119
- inSymptomWords({ message, title: request.title })
120
- ])
121
- );
122
- var checkRuleOf = (request) => ({
123
- meta: {
124
- ...request.rule.meta,
125
- messages: messagesInSymptomWords({
126
- messages: request.rule.meta.messages,
127
- title: request.title
128
- })
129
- },
130
- create: (context) => request.rule.create(contextInSymptomWords({ context, boundary: request.boundary }))
131
- });
132
- var namedRuleOf = (request) => {
133
- const { check, pieceFile, pluginModule, ruleName } = request.source;
134
- const plugin = eslintPluginModuleSchema.safeParse({ default: request.source.plugin });
135
- if (!plugin.success) {
136
- return {
137
- outcome: "failed",
138
- error: {
139
- kind: "plugin-invalid",
140
- pieceFile,
141
- pluginModule,
142
- detail: z3.prettifyError(plugin.error)
143
- }
144
- };
145
- }
146
- const { rules } = plugin.data.default;
147
- const rule = Object.hasOwn(rules, ruleName) ? rules[ruleName] : void 0;
148
- return rule === void 0 ? { outcome: "failed", error: { kind: "piece-rule-missing", pieceFile, rule: ruleName } } : {
149
- outcome: "ok",
150
- value: [
151
- checkRuleNameOf({ check }),
152
- checkRuleOf({ rule, title: check.symptom.title, boundary: request.boundary })
153
- ]
154
- };
155
- };
156
- var checksPluginOf = (request) => {
157
- const rules = everyOk({
158
- entries: request.sources,
159
- resolve: (source) => namedRuleOf({ source, boundary: request.boundary })
160
- });
161
- return rules.outcome === "failed" ? rules : { outcome: "ok", value: { meta: PLUGIN_META, rules: Object.fromEntries(rules.value) } };
162
- };
163
-
164
- // src/infrastructure/engines/eslint/runner/hone-plugin/hone-plugin.ts
165
- var moduleExportsSchema = z4.looseObject({ default: z4.unknown() });
166
- var pieceSourceOf = async (request) => {
167
- const { check, installRoot } = request;
168
- const names = checkNamesOf({ text: checkRuleNameOf({ check }) });
169
- if (names === void 0) {
170
- return {
171
- outcome: "failed",
172
- error: { kind: "check-rule-missing", ruleId: checkRuleIdOf({ check }) }
173
- };
174
- }
175
- const location = { ...request, ...names, mechanism: ESLINT_MECHANISM, ruleSetRoot: installRoot };
176
- const pieceFile = namedPiecePathOf(location);
177
- const piece = readNamedPiece(location);
178
- if (piece.outcome === "failed") {
179
- const { error } = piece;
180
- return error.kind === "file-malformed" || error.kind === "file-unreadable" ? {
181
- outcome: "failed",
182
- error: {
183
- kind: error.kind === "file-malformed" ? "piece-source-invalid" : "piece-unreadable",
184
- pieceFile,
185
- detail: error.detail
186
- }
187
- } : {
188
- outcome: "failed",
189
- error: { kind: "check-rule-missing", ruleId: checkRuleIdOf({ check }) }
190
- };
191
- }
192
- const settings = eslintPieceSettingsSchema.safeParse(piece.value.settings);
193
- if (!settings.success) {
194
- return {
195
- outcome: "failed",
196
- error: { kind: "piece-source-invalid", pieceFile, detail: z4.prettifyError(settings.error) }
197
- };
198
- }
199
- const { pluginModule, rule: ruleName } = settings.data;
200
- const path = request.path.join({ segments: [piece.value.pieceRoot, pluginModule] });
201
- const loaded = await request.modules.load({ path });
202
- if (loaded.outcome === "failed") {
203
- return {
204
- outcome: "failed",
205
- error: { kind: "plugin-unloadable", path: loaded.error.path, detail: loaded.error.detail }
206
- };
207
- }
208
- const exported = moduleExportsSchema.safeParse(loaded.value);
209
- return exported.success ? {
210
- outcome: "ok",
211
- value: { check, pieceFile, pluginModule, ruleName, plugin: exported.data.default }
212
- } : {
213
- outcome: "failed",
214
- error: {
215
- kind: "plugin-invalid",
216
- pieceFile,
217
- pluginModule,
218
- detail: z4.prettifyError(exported.error)
219
- }
220
- };
221
- };
222
- var honePluginAt = async (request) => {
223
- const eslint = request.checks.filter((check) => runsOnEslint({ check }) === "eslint");
224
- const sources = gatheredOutcomes({
225
- outcomes: await Promise.all(
226
- eslint.map(
227
- async (check) => listedOutcome({ outcome: await pieceSourceOf({ ...request, check }) })
228
- )
229
- )
230
- });
231
- return sources.outcome === "failed" ? sources : checksPluginOf({ sources: sources.value, boundary: request.boundary });
232
- };
233
- var honePluginFailureText = (request) => {
234
- const failure = request.failure;
235
- switch (failure.kind) {
236
- case "piece-unreadable":
237
- return `the piece ${failure.pieceFile} cannot be read: ${failure.detail}`;
238
- case "piece-source-invalid":
239
- return `the piece ${failure.pieceFile} is not an ESLint piece: ${failure.detail}`;
240
- case "plugin-unloadable":
241
- return `the plugin module ${failure.path} cannot be loaded: ${failure.detail}`;
242
- case "plugin-invalid":
243
- return `the plugin module ${failure.pluginModule} of the piece ${failure.pieceFile} is not an ESLint plugin: ${failure.detail}`;
244
- case "piece-rule-missing":
245
- return `the piece ${failure.pieceFile} runs the rule ${failure.rule}, which its plugin module does not hold`;
246
- case "check-rule-missing":
247
- return `the check ${failure.ruleId} runs on ESLint, but no piece of this install holds its rule`;
248
- }
249
- };
250
-
251
36
  // src/infrastructure/engines/eslint/runner/toolchain/eslint-instance.ts
252
- import { z as z6 } from "zod";
37
+ import { z as z3 } from "zod";
253
38
 
254
39
  // src/infrastructure/engines/eslint/runner/native-exceptions/inline-config-parser.ts
255
40
  import { ConfigCommentParser } from "@eslint/plugin-kit";
@@ -292,19 +77,39 @@ var parseInlineConfigComment = (request) => {
292
77
  }
293
78
  };
294
79
 
80
+ // src/infrastructure/engines/eslint/runner/pieces/eslint-plugin-schema.ts
81
+ import { z } from "zod";
82
+ var ruleVisitorSchema = z.record(
83
+ z.string(),
84
+ z.function({ input: z.array(z.unknown()), output: z.unknown() })
85
+ );
86
+ var ruleSchema = z.looseObject({
87
+ meta: z.looseObject({
88
+ type: z.enum(["problem", "suggestion", "layout"]),
89
+ messages: z.record(z.string(), z.string()).optional()
90
+ }),
91
+ create: z.function({ input: [z.unknown()], output: ruleVisitorSchema })
92
+ });
93
+ var eslintPluginModuleSchema = z.object({
94
+ default: z.looseObject({ rules: z.record(z.string(), ruleSchema) })
95
+ });
96
+ var inlineConfigNodesSchema = z.array(
97
+ z.looseObject({ type: z.enum(["Line", "Block"]), value: z.string() })
98
+ );
99
+
295
100
  // src/infrastructure/engines/eslint/runner/toolchain/eslint-config-schema.ts
296
- import { z as z5 } from "zod";
297
- var resolvedConfigSchema = z5.union([
298
- z5.undefined(),
299
- z5.looseObject({
300
- rules: z5.record(
301
- z5.string(),
302
- z5.tuple([z5.union([z5.literal(0), z5.literal(1), z5.literal(2)])], z5.unknown())
101
+ import { z as z2 } from "zod";
102
+ var resolvedConfigSchema = z2.union([
103
+ z2.undefined(),
104
+ z2.looseObject({
105
+ rules: z2.record(
106
+ z2.string(),
107
+ z2.tuple([z2.union([z2.literal(0), z2.literal(1), z2.literal(2)])], z2.unknown())
303
108
  ).optional(),
304
- plugins: z5.record(z5.string(), z5.unknown()).optional(),
305
- language: z5.unknown().optional(),
306
- processor: z5.unknown().optional(),
307
- languageOptions: z5.looseObject({ parser: z5.unknown().optional() }).optional()
109
+ plugins: z2.record(z2.string(), z2.unknown()).optional(),
110
+ language: z2.unknown().optional(),
111
+ processor: z2.unknown().optional(),
112
+ languageOptions: z2.looseObject({ parser: z2.unknown().optional() }).optional()
308
113
  })
309
114
  ]);
310
115
  var ruleStateOf = (request) => {
@@ -470,7 +275,7 @@ var resolvedRuleState = (request) => {
470
275
  if (!parsed.success) {
471
276
  return {
472
277
  outcome: "failed",
473
- error: { kind: "runner-invalid-output", detail: z6.prettifyError(parsed.error) }
278
+ error: { kind: "runner-invalid-output", detail: z3.prettifyError(parsed.error) }
474
279
  };
475
280
  }
476
281
  return { outcome: "ok", value: ruleStateOf({ resolved: parsed.data, ruleId: request.ruleId }) };
@@ -660,9 +465,6 @@ var createEslintOn = (request) => (create) => {
660
465
  };
661
466
  };
662
467
 
663
- // src/infrastructure/engines/eslint/runner/toolchain/eslint-toolchain.ts
664
- import { z as z7 } from "zod";
665
-
666
468
  // import("./**/*/eslint-*-boundary.ts") in src/infrastructure/engines/eslint/runner/toolchain/eslint-toolchain.ts
667
469
  var globImport_eslint_boundary_ts = __glob({
668
470
  "./eslint-10/eslint-10-boundary.ts": () => import("./eslint-10-boundary-A4JIQ734.js"),
@@ -693,11 +495,11 @@ var defaultEslintToolchainModules = {
693
495
  typescriptParser: () => import("@typescript-eslint/parser"),
694
496
  typescriptEslintPlugin: () => import("@typescript-eslint/eslint-plugin")
695
497
  };
696
- var boundaryModuleSchema = z7.object({
697
- eslintBoundary: z7.object({
698
- nearestLookup: z7.object({ flags: z7.array(z7.string()) }),
699
- declarationText: z7.string(),
700
- reportDataOf: z7.custom(
498
+ var boundaryModuleSchema = z4.object({
499
+ eslintBoundary: z4.object({
500
+ nearestLookup: z4.object({ flags: z4.array(z4.string()) }),
501
+ declarationText: z4.string(),
502
+ reportDataOf: z4.custom(
701
503
  (candidate) => typeof candidate === "function"
702
504
  )
703
505
  })
@@ -713,7 +515,7 @@ var eslintBoundaryFor = async (request) => {
713
515
  const boundary = boundaryModuleSchema.safeParse(loaded);
714
516
  return boundary.success ? { outcome: "ok", value: boundary.data.eslintBoundary } : {
715
517
  outcome: "failed",
716
- error: `the ESLint ${major} boundary is malformed: ${z7.prettifyError(boundary.error)}`
518
+ error: `the ESLint ${major} boundary is malformed: ${z4.prettifyError(boundary.error)}`
717
519
  };
718
520
  };
719
521
  var installedEslintBoundary = () => defaultEslintToolchainModules.eslint().then((installed) => eslintBoundaryFor({ version: installed.ESLint.version }));
@@ -808,7 +610,212 @@ var loadEslintToolchain = (request) => {
808
610
  );
809
611
  };
810
612
 
613
+ // src/infrastructure/engines/eslint/runner/hone-plugin/hone-plugin.ts
614
+ import { z as z7 } from "zod";
615
+
616
+ // src/infrastructure/engines/eslint/runner/pieces/eslint-piece-settings-schema.ts
617
+ import { z as z5 } from "zod";
618
+ var pieceModulePathSchema = z5.string().superRefine((text, context) => {
619
+ if (isRepoPathText({ text }) === "not-repo-path" || moduleFileForm({ text }) === "not-module-file") {
620
+ context.addIssue({
621
+ code: "custom",
622
+ message: "not a path inside the piece folder ending in .ts, or .js in a built install"
623
+ });
624
+ }
625
+ });
626
+ var pluginNamespaceSchema = z5.string().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/);
627
+ var ruleOptionsSchema = z5.array(z5.json()).readonly();
628
+ var optionsByEditionSchema = z5.record(z5.string(), ruleOptionsSchema).transform((options) => new Map(Object.entries(options))).pipe(z5.map(editionSchema, ruleOptionsSchema)).readonly();
629
+ var eslintPieceSettingsSchema = z5.strictObject({
630
+ pluginNamespace: pluginNamespaceSchema,
631
+ pluginModule: pieceModulePathSchema,
632
+ rule: z5.string(),
633
+ options: ruleOptionsSchema.optional(),
634
+ optionsByEdition: optionsByEditionSchema.optional()
635
+ }).readonly();
636
+ var ruleOptionsOf = (request) => {
637
+ const { settings, edition } = request;
638
+ const reached = [...settings.optionsByEdition ?? []].filter(([introducedIn]) => editionReaches({ edition, introducedIn }) === "reached").reduce((latest, candidate) => {
639
+ if (latest === void 0) return candidate;
640
+ return editionReaches({ edition: candidate[0], introducedIn: latest[0] }) === "reached" ? candidate : latest;
641
+ }, void 0);
642
+ return reached?.[1] ?? settings.options ?? [];
643
+ };
644
+
645
+ // src/infrastructure/engines/eslint/runner/hone-plugin/check-rule-id.ts
646
+ var CHECKS_PLUGIN_NAMESPACE = TOOL_IDENTITY.ownRuleSet;
647
+ var ESLINT_MECHANISM = "eslint";
648
+ var RULE_ID_PREFIX = `${CHECKS_PLUGIN_NAMESPACE}/`;
649
+ var checkRuleNameOf = (request) => checkAddressTextOf(request);
650
+ var checkRuleIdOf = (request) => `${RULE_ID_PREFIX}${checkRuleNameOf(request)}`;
651
+ var runsOnEslint = (request) => request.check.engines.some((engine) => engine.name === ESLINT_MECHANISM) ? "eslint" : "elsewhere";
652
+ var eslintRuleIdsOf = (request) => request.checks.filter((check) => runsOnEslint({ check }) === "eslint").map((check) => checkRuleIdOf({ check }));
653
+
654
+ // src/infrastructure/engines/eslint/runner/hone-plugin/checks-plugin.ts
655
+ import { z as z6 } from "zod";
656
+ var PLUGIN_META = { name: `${TOOL_IDENTITY.packageName}/eslint-plugin`, version: "0.0.0-local" };
657
+ var NUMBERED_LEAD = /^CD-\d+: /;
658
+ var inSymptomWords = (request) => `${request.title}: ${request.message.replace(NUMBERED_LEAD, "")}`;
659
+ var unnumbered = (request) => typeof request.text === "string" ? request.text.replace(NUMBERED_LEAD, "") : request.text;
660
+ var reportInSymptomWords = (request) => {
661
+ const reportData = request.boundary.reportDataOf({ descriptor: request.descriptor });
662
+ return reportData === void 0 ? request.descriptor : {
663
+ ...request.descriptor,
664
+ data: Object.fromEntries(
665
+ Object.entries(reportData).map(([key, text]) => [key, unnumbered({ text })])
666
+ )
667
+ };
668
+ };
669
+ var contextInSymptomWords = (request) => Object.create(request.context, {
670
+ report: {
671
+ value: (descriptor) => request.context.report(reportInSymptomWords({ descriptor, boundary: request.boundary }))
672
+ }
673
+ });
674
+ var messagesInSymptomWords = (request) => request.messages === void 0 ? void 0 : Object.fromEntries(
675
+ Object.entries(request.messages).map(([messageId, message]) => [
676
+ messageId,
677
+ inSymptomWords({ message, title: request.title })
678
+ ])
679
+ );
680
+ var checkRuleOf = (request) => ({
681
+ meta: {
682
+ ...request.rule.meta,
683
+ messages: messagesInSymptomWords({
684
+ messages: request.rule.meta.messages,
685
+ title: request.title
686
+ })
687
+ },
688
+ create: (context) => request.rule.create(contextInSymptomWords({ context, boundary: request.boundary }))
689
+ });
690
+ var namedRuleOf = (request) => {
691
+ const { check, pieceFile, pluginModule, ruleName } = request.source;
692
+ const plugin = eslintPluginModuleSchema.safeParse({ default: request.source.plugin });
693
+ if (!plugin.success) {
694
+ return {
695
+ outcome: "failed",
696
+ error: {
697
+ kind: "plugin-invalid",
698
+ pieceFile,
699
+ pluginModule,
700
+ detail: z6.prettifyError(plugin.error)
701
+ }
702
+ };
703
+ }
704
+ const { rules } = plugin.data.default;
705
+ const rule = Object.hasOwn(rules, ruleName) ? rules[ruleName] : void 0;
706
+ return rule === void 0 ? { outcome: "failed", error: { kind: "piece-rule-missing", pieceFile, rule: ruleName } } : {
707
+ outcome: "ok",
708
+ value: [
709
+ checkRuleNameOf({ check }),
710
+ checkRuleOf({ rule, title: check.symptom.title, boundary: request.boundary })
711
+ ]
712
+ };
713
+ };
714
+ var checksPluginOf = (request) => {
715
+ const rules = everyOk({
716
+ entries: request.sources,
717
+ resolve: (source) => namedRuleOf({ source, boundary: request.boundary })
718
+ });
719
+ return rules.outcome === "failed" ? rules : { outcome: "ok", value: { meta: PLUGIN_META, rules: Object.fromEntries(rules.value) } };
720
+ };
721
+
722
+ // src/infrastructure/engines/eslint/runner/hone-plugin/hone-plugin.ts
723
+ var moduleExportsSchema = z7.looseObject({ default: z7.unknown() });
724
+ var pieceSourceOf = async (request) => {
725
+ const { check, installRoot } = request;
726
+ const names = checkNamesOf({ text: checkRuleNameOf({ check }) });
727
+ if (names === void 0) {
728
+ return {
729
+ outcome: "failed",
730
+ error: { kind: "check-rule-missing", ruleId: checkRuleIdOf({ check }) }
731
+ };
732
+ }
733
+ const location = { ...request, ...names, mechanism: ESLINT_MECHANISM, ruleSetRoot: installRoot };
734
+ const pieceFile = namedPiecePathOf(location);
735
+ const piece = readNamedPiece(location);
736
+ if (piece.outcome === "failed") {
737
+ const { error } = piece;
738
+ return error.kind === "file-malformed" || error.kind === "file-unreadable" ? {
739
+ outcome: "failed",
740
+ error: {
741
+ kind: error.kind === "file-malformed" ? "piece-source-invalid" : "piece-unreadable",
742
+ pieceFile,
743
+ detail: error.detail
744
+ }
745
+ } : {
746
+ outcome: "failed",
747
+ error: { kind: "check-rule-missing", ruleId: checkRuleIdOf({ check }) }
748
+ };
749
+ }
750
+ const settings = eslintPieceSettingsSchema.safeParse(piece.value.settings);
751
+ if (!settings.success) {
752
+ return {
753
+ outcome: "failed",
754
+ error: { kind: "piece-source-invalid", pieceFile, detail: z7.prettifyError(settings.error) }
755
+ };
756
+ }
757
+ const { pluginModule, rule: ruleName } = settings.data;
758
+ const path = request.path.join({ segments: [piece.value.pieceRoot, pluginModule] });
759
+ const loaded = await request.modules.load({ path });
760
+ if (loaded.outcome === "failed") {
761
+ return {
762
+ outcome: "failed",
763
+ error: { kind: "plugin-unloadable", path: loaded.error.path, detail: loaded.error.detail }
764
+ };
765
+ }
766
+ const exported = moduleExportsSchema.safeParse(loaded.value);
767
+ return exported.success ? {
768
+ outcome: "ok",
769
+ value: { check, pieceFile, pluginModule, ruleName, plugin: exported.data.default }
770
+ } : {
771
+ outcome: "failed",
772
+ error: {
773
+ kind: "plugin-invalid",
774
+ pieceFile,
775
+ pluginModule,
776
+ detail: z7.prettifyError(exported.error)
777
+ }
778
+ };
779
+ };
780
+ var honePluginAt = async (request) => {
781
+ const eslint = request.checks.filter((check) => runsOnEslint({ check }) === "eslint");
782
+ const sources = gatheredOutcomes({
783
+ outcomes: await Promise.all(
784
+ eslint.map(
785
+ async (check) => listedOutcome({ outcome: await pieceSourceOf({ ...request, check }) })
786
+ )
787
+ )
788
+ });
789
+ return sources.outcome === "failed" ? sources : checksPluginOf({ sources: sources.value, boundary: request.boundary });
790
+ };
791
+ var honePluginFailureText = (request) => {
792
+ const failure = request.failure;
793
+ switch (failure.kind) {
794
+ case "piece-unreadable":
795
+ return `the piece ${failure.pieceFile} cannot be read: ${failure.detail}`;
796
+ case "piece-source-invalid":
797
+ return `the piece ${failure.pieceFile} is not an ESLint piece: ${failure.detail}`;
798
+ case "plugin-unloadable":
799
+ return `the plugin module ${failure.path} cannot be loaded: ${failure.detail}`;
800
+ case "plugin-invalid":
801
+ return `the plugin module ${failure.pluginModule} of the piece ${failure.pieceFile} is not an ESLint plugin: ${failure.detail}`;
802
+ case "piece-rule-missing":
803
+ return `the piece ${failure.pieceFile} runs the rule ${failure.rule}, which its plugin module does not hold`;
804
+ case "check-rule-missing":
805
+ return `the check ${failure.ruleId} runs on ESLint, but no piece of this install holds its rule`;
806
+ }
807
+ };
808
+
811
809
  export {
810
+ parseInlineConfigComment,
811
+ eslintPluginModuleSchema,
812
+ reservedNamespace,
813
+ INLINE_CONFIG_RULE_ID,
814
+ enabledRuleEntry,
815
+ createEslintPort,
816
+ installedEslintBoundary,
817
+ defaultEslintToolchainPeers,
818
+ loadEslintToolchain,
812
819
  eslintPieceSettingsSchema,
813
820
  ruleOptionsOf,
814
821
  CHECKS_PLUGIN_NAMESPACE,
@@ -816,15 +823,6 @@ export {
816
823
  checkRuleIdOf,
817
824
  runsOnEslint,
818
825
  eslintRuleIdsOf,
819
- eslintPluginModuleSchema,
820
826
  honePluginAt,
821
- honePluginFailureText,
822
- parseInlineConfigComment,
823
- reservedNamespace,
824
- INLINE_CONFIG_RULE_ID,
825
- enabledRuleEntry,
826
- createEslintPort,
827
- installedEslintBoundary,
828
- defaultEslintToolchainPeers,
829
- loadEslintToolchain
827
+ honePluginFailureText
830
828
  };