@cplieger/deadset-ts 7.2.0-dev.4 → 8.0.0-dev.10

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 (288) hide show
  1. package/README.md +1 -1
  2. package/dist/bin/mapper-connection.js +2 -1
  3. package/dist/bin/node-host.js +24 -5
  4. package/dist/src/analysis.js +245 -309
  5. package/dist/src/augmentations.js +124 -18
  6. package/dist/src/automatic-types.js +170 -0
  7. package/dist/src/build-scripts.js +425 -0
  8. package/dist/src/component-layer.js +4 -2
  9. package/dist/src/components.js +9 -9
  10. package/dist/src/config.js +6 -81
  11. package/dist/src/configuration-files.js +78 -188
  12. package/dist/src/configured-declarations.js +15 -20
  13. package/dist/src/conformance-record.js +2 -2
  14. package/dist/src/consumers.js +3 -30
  15. package/dist/src/contextual-uses.js +56 -9
  16. package/dist/src/contract/config.generated.js +558 -0
  17. package/dist/src/contract/contract.generated.js +1244 -0
  18. package/dist/src/contract/report.generated.js +862 -0
  19. package/dist/src/convention-rows.js +146 -1
  20. package/dist/src/conventions.js +136 -70
  21. package/dist/src/decorator.js +21 -18
  22. package/dist/src/dependencies.js +280 -62
  23. package/dist/src/edges.js +38 -122
  24. package/dist/src/element-access.js +4 -6
  25. package/dist/src/entry-point-gaps.js +9 -18
  26. package/dist/src/entry-points.js +106 -21
  27. package/dist/src/enum-group.js +3 -10
  28. package/dist/src/erased-stores.js +4 -6
  29. package/dist/src/exempt-classes.js +1 -63
  30. package/dist/src/exempt.js +21 -40
  31. package/dist/src/failure.js +36 -0
  32. package/dist/src/file-facts.js +2 -25
  33. package/dist/src/findings/completion.js +225 -63
  34. package/dist/src/findings/dependencies-and-module-machinery.js +72 -27
  35. package/dist/src/findings/emitters.js +6 -6
  36. package/dist/src/findings/interfaces.js +4 -5
  37. package/dist/src/findings/intra-function.js +53 -19
  38. package/dist/src/findings/non-code-artifacts.js +71 -39
  39. package/dist/src/findings/reads-and-writes.js +16 -13
  40. package/dist/src/findings/self-check.js +10 -12
  41. package/dist/src/findings/unused-declarations.js +57 -28
  42. package/dist/src/findings/visibility-narrowing.js +40 -18
  43. package/dist/src/findings-pass.js +8 -15
  44. package/dist/src/framework-lifecycle.js +7 -7
  45. package/dist/src/fs/document.js +52 -0
  46. package/dist/src/fs/manifest.js +72 -0
  47. package/dist/src/fs/tree.js +88 -0
  48. package/dist/src/generated-file.js +18 -4
  49. package/dist/src/git-ignore.js +99 -0
  50. package/dist/src/graph.js +9 -4
  51. package/dist/src/html-entries.js +6 -33
  52. package/dist/src/import-bindings.js +97 -0
  53. package/dist/src/in-operands.js +2 -1
  54. package/dist/src/index.js +1 -1
  55. package/dist/src/indexed-access.js +130 -28
  56. package/dist/src/injection-container.js +1 -1
  57. package/dist/src/interface-satisfaction.js +30 -12
  58. package/dist/src/intra-function-parts.js +341 -69
  59. package/dist/src/inventory.js +54 -29
  60. package/dist/src/javascript-file.js +33 -0
  61. package/dist/src/json-document.js +198 -67
  62. package/dist/src/keyof-comparisons.js +4 -6
  63. package/dist/src/kinds.js +3 -366
  64. package/dist/src/load/classify.js +270 -0
  65. package/dist/src/load/diagnostics.js +80 -0
  66. package/dist/src/load/discover.js +277 -0
  67. package/dist/src/{emit-map.js → load/emit-map.js} +1 -1
  68. package/dist/src/load/expected-module.js +136 -0
  69. package/dist/src/load/load.js +27 -0
  70. package/dist/src/load/module-lookup.js +37 -0
  71. package/dist/src/load/plan.js +313 -0
  72. package/dist/src/load/specifiers.js +115 -0
  73. package/dist/src/load/synthesize.js +140 -0
  74. package/dist/src/load/test-globals.js +207 -0
  75. package/dist/src/load/test-joins.js +82 -0
  76. package/dist/src/{workspace-manifests.js → load/workspace-manifests.js} +4 -4
  77. package/dist/src/{workspace-programs.js → load/workspace-programs.js} +88 -61
  78. package/dist/src/{workspace-resolution.js → load/workspace-resolution.js} +60 -59
  79. package/dist/src/{workspace-run.js → load/workspace-run.js} +7 -7
  80. package/dist/src/{workspace.js → load/workspace.js} +62 -124
  81. package/dist/src/manifest.js +49 -54
  82. package/dist/src/matrix.js +94 -13
  83. package/dist/src/mdx-entries.js +174 -0
  84. package/dist/src/module-declarations.js +9 -13
  85. package/dist/src/outside-tests.js +1 -1
  86. package/dist/src/overrides.js +41 -10
  87. package/dist/src/partial.js +2 -1
  88. package/dist/src/paths.js +26 -15
  89. package/dist/src/position.js +2 -1
  90. package/dist/src/print.js +11 -78
  91. package/dist/src/product.js +13 -0
  92. package/dist/src/query.js +1 -0
  93. package/dist/src/ref.js +11 -0
  94. package/dist/src/references.js +52 -31
  95. package/dist/src/report-schema.js +51 -0
  96. package/dist/src/report.js +59 -41
  97. package/dist/src/reporters/annotations.js +15 -8
  98. package/dist/src/reporters/sarif.js +16 -10
  99. package/dist/src/reporters/template.js +4 -19
  100. package/dist/src/resolve.js +245 -727
  101. package/dist/src/roots.js +374 -116
  102. package/dist/src/run.js +66 -77
  103. package/dist/src/schema.js +320 -342
  104. package/dist/src/scope.js +38 -115
  105. package/dist/src/serialization-contract.js +649 -29
  106. package/dist/src/session.js +41 -29
  107. package/dist/src/source-files.js +40 -15
  108. package/dist/src/suppress-file.js +34 -29
  109. package/dist/src/suppress-inline.js +21 -4
  110. package/dist/src/suppress.js +40 -56
  111. package/dist/src/sweep.js +32 -17
  112. package/dist/src/symbol-keys.js +105 -6
  113. package/dist/src/template-field.js +9 -19
  114. package/dist/src/test-support.js +119 -18
  115. package/dist/src/text/compare.js +26 -0
  116. package/dist/src/text/glob.js +194 -0
  117. package/dist/src/text/named-files.js +54 -0
  118. package/dist/src/text/shell.js +159 -0
  119. package/dist/src/text/yaml.js +393 -0
  120. package/dist/src/type-errors.js +27 -221
  121. package/dist/src/type-parameter-reads.js +172 -0
  122. package/dist/src/unseen-loads.js +100 -0
  123. package/dist/src/unwrap.js +23 -0
  124. package/dist/src/usage.js +10 -0
  125. package/dist/src/verbs/analyze.js +181 -125
  126. package/dist/src/verbs/describe.js +9 -16
  127. package/dist/src/verbs/explain.js +14 -9
  128. package/dist/src/verbs/print-config.js +2 -1
  129. package/dist/src/verbs/print-projects.js +6 -4
  130. package/dist/src/verbs/print-retained.js +4 -2
  131. package/dist/src/verbs/print-roots.js +4 -2
  132. package/dist/src/verbs/verb.js +1 -5
  133. package/dist/src/verbs/version.js +14 -3
  134. package/dist/src/workflow-steps.js +128 -33
  135. package/jsr.json +1 -1
  136. package/package.json +5 -4
  137. package/src/analysis.ts +333 -457
  138. package/src/augmentations.ts +152 -23
  139. package/src/automatic-types.ts +228 -0
  140. package/src/build-scripts.ts +543 -0
  141. package/src/component-layer.ts +4 -2
  142. package/src/components.ts +9 -10
  143. package/src/config.ts +31 -299
  144. package/src/configuration-files.ts +100 -191
  145. package/src/configured-declarations.ts +18 -23
  146. package/src/conformance-record.ts +2 -2
  147. package/src/consumers.ts +6 -57
  148. package/src/contextual-uses.ts +64 -12
  149. package/src/contract/config.generated.ts +818 -0
  150. package/src/contract/contract.generated.ts +1308 -0
  151. package/src/contract/report.generated.ts +1237 -0
  152. package/src/convention-rows.ts +186 -1
  153. package/src/conventions.ts +166 -90
  154. package/src/decorator.ts +28 -18
  155. package/src/dependencies.ts +356 -78
  156. package/src/edges.ts +41 -140
  157. package/src/element-access.ts +4 -7
  158. package/src/entry-point-gaps.ts +11 -20
  159. package/src/entry-points.ts +124 -28
  160. package/src/enum-group.ts +2 -11
  161. package/src/erased-stores.ts +3 -7
  162. package/src/exempt-classes.ts +1 -75
  163. package/src/exempt.ts +36 -50
  164. package/src/failure.ts +63 -0
  165. package/src/file-facts.ts +9 -24
  166. package/src/finding.ts +24 -9
  167. package/src/findings/boundary.ts +2 -0
  168. package/src/findings/completion.ts +297 -77
  169. package/src/findings/dependencies-and-module-machinery.ts +90 -31
  170. package/src/findings/emitter.ts +8 -9
  171. package/src/findings/emitters.ts +8 -8
  172. package/src/findings/interfaces.ts +4 -6
  173. package/src/findings/intra-function.ts +64 -20
  174. package/src/findings/non-code-artifacts.ts +88 -50
  175. package/src/findings/reads-and-writes.ts +20 -16
  176. package/src/findings/self-check.ts +11 -17
  177. package/src/findings/unused-declarations.ts +65 -28
  178. package/src/findings/visibility-narrowing.ts +51 -19
  179. package/src/findings-pass.ts +10 -19
  180. package/src/framework-lifecycle.ts +7 -7
  181. package/src/fs/document.ts +70 -0
  182. package/src/fs/manifest.ts +92 -0
  183. package/src/fs/tree.ts +110 -0
  184. package/src/generated-file.ts +23 -4
  185. package/src/git-ignore.ts +122 -0
  186. package/src/graph.ts +11 -3
  187. package/src/host.ts +17 -14
  188. package/src/html-entries.ts +6 -33
  189. package/src/import-bindings.ts +128 -0
  190. package/src/in-operands.ts +2 -1
  191. package/src/index.ts +1 -1
  192. package/src/indexed-access.ts +152 -30
  193. package/src/injection-container.ts +1 -1
  194. package/src/interface-satisfaction.ts +33 -13
  195. package/src/intra-function-parts.ts +449 -85
  196. package/src/inventory.ts +73 -27
  197. package/src/javascript-file.ts +37 -0
  198. package/src/json-document.ts +241 -76
  199. package/src/keyof-comparisons.ts +3 -7
  200. package/src/kinds.ts +5 -413
  201. package/src/load/classify.ts +397 -0
  202. package/src/load/diagnostics.ts +144 -0
  203. package/src/load/discover.ts +455 -0
  204. package/src/{emit-map.ts → load/emit-map.ts} +1 -1
  205. package/src/load/expected-module.ts +188 -0
  206. package/src/load/load.ts +73 -0
  207. package/src/load/module-lookup.ts +50 -0
  208. package/src/load/plan.ts +504 -0
  209. package/src/load/specifiers.ts +168 -0
  210. package/src/load/synthesize.ts +211 -0
  211. package/src/load/test-globals.ts +251 -0
  212. package/src/load/test-joins.ts +98 -0
  213. package/src/{workspace-manifests.ts → load/workspace-manifests.ts} +5 -5
  214. package/src/{workspace-programs.ts → load/workspace-programs.ts} +127 -80
  215. package/src/{workspace-resolution.ts → load/workspace-resolution.ts} +73 -64
  216. package/src/{workspace-run.ts → load/workspace-run.ts} +18 -16
  217. package/src/{workspace.ts → load/workspace.ts} +90 -134
  218. package/src/manifest.ts +81 -75
  219. package/src/matrix.ts +154 -18
  220. package/src/mdx-entries.ts +218 -0
  221. package/src/module-declarations.ts +11 -13
  222. package/src/outside-tests.ts +1 -1
  223. package/src/overrides.ts +51 -12
  224. package/src/partial.ts +3 -2
  225. package/src/paths.ts +27 -15
  226. package/src/position.ts +2 -1
  227. package/src/print.ts +12 -91
  228. package/src/product.ts +18 -0
  229. package/src/query.ts +11 -0
  230. package/src/ref.ts +13 -0
  231. package/src/references.ts +62 -32
  232. package/src/report-schema.ts +68 -0
  233. package/src/report.ts +105 -215
  234. package/src/reporters/annotations.ts +22 -11
  235. package/src/reporters/json.ts +1 -1
  236. package/src/reporters/reporter.ts +2 -4
  237. package/src/reporters/reporters.ts +1 -1
  238. package/src/reporters/sarif.ts +29 -16
  239. package/src/reporters/template.ts +4 -20
  240. package/src/reporters/text.ts +3 -3
  241. package/src/resolve.ts +283 -1111
  242. package/src/roots.ts +490 -137
  243. package/src/run.ts +75 -91
  244. package/src/schema.ts +391 -387
  245. package/src/scope.ts +46 -138
  246. package/src/serialization-contract.ts +818 -26
  247. package/src/session.ts +77 -54
  248. package/src/source-files.ts +67 -17
  249. package/src/suppress-file.ts +36 -34
  250. package/src/suppress-inline.ts +20 -3
  251. package/src/suppress.ts +52 -63
  252. package/src/sweep.ts +53 -18
  253. package/src/symbol-keys.ts +131 -7
  254. package/src/template-field.ts +15 -25
  255. package/src/test-support.ts +155 -18
  256. package/src/text/compare.ts +27 -0
  257. package/src/text/glob.ts +210 -0
  258. package/src/text/named-files.inputs.json +1522 -0
  259. package/src/text/named-files.ts +68 -0
  260. package/src/text/shell.ts +161 -0
  261. package/src/text/yaml.ts +423 -0
  262. package/src/type-errors.ts +35 -273
  263. package/src/type-parameter-reads.ts +227 -0
  264. package/src/unseen-loads.ts +134 -0
  265. package/src/unwrap.ts +34 -0
  266. package/src/usage.ts +10 -0
  267. package/src/verbs/analyze.ts +245 -161
  268. package/src/verbs/describe.ts +14 -15
  269. package/src/verbs/explain.ts +15 -13
  270. package/src/verbs/print-config.ts +2 -1
  271. package/src/verbs/print-projects.ts +6 -4
  272. package/src/verbs/print-retained.ts +4 -2
  273. package/src/verbs/print-roots.ts +4 -2
  274. package/src/verbs/verb.ts +2 -8
  275. package/src/verbs/version.ts +15 -3
  276. package/src/workflow-steps.ts +149 -34
  277. package/dist/src/discover.js +0 -347
  278. package/dist/src/glob.js +0 -65
  279. package/dist/src/pnpm-workspace.js +0 -120
  280. package/dist/src/setup-failure.js +0 -23
  281. package/dist/src/test-joins.js +0 -101
  282. package/dist/src/version.js +0 -7
  283. package/src/discover.ts +0 -510
  284. package/src/glob.ts +0 -67
  285. package/src/pnpm-workspace.ts +0 -135
  286. package/src/setup-failure.ts +0 -39
  287. package/src/test-joins.ts +0 -120
  288. package/src/version.ts +0 -7
package/src/config.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { CONTRACT_VERSION } from "./version.ts";
1
+ import type { ResolvedConfig } from "./contract/config.generated.ts";
2
+ import { SEVERITIES, type Severity } from "./contract/contract.generated.ts";
3
+ import { LANGUAGE } from "./product.ts";
2
4
 
3
5
  /**
4
6
  * The name of the repository configuration at the target root, which is also the
@@ -7,263 +9,32 @@ import { CONTRACT_VERSION } from "./version.ts";
7
9
  */
8
10
  export const REPOSITORY_DOCUMENT = "deadset.json";
9
11
 
10
- /**
11
- * Whether the target is an application, whose every caller is in the analyzed
12
- * graph, or a library, whose published API has callers outside it.
13
- */
14
- export type TargetKind = "application" | "library";
12
+ export type { PartialConfig, ResolvedConfig } from "./contract/config.generated.ts";
15
13
 
16
- /** The target kind as a source writes it: one kind for every language, or one per language. */
17
- export type TargetKindSetting = TargetKind | { readonly go: TargetKind; readonly ts: TargetKind };
14
+ /** Whether the target is an application or a library. */
15
+ export type TargetKind = Extract<ResolvedConfig["target"]["kind"], string>;
16
+ export type DeclarationEntry = ResolvedConfig["ts"]["serializers"][number];
17
+ export type LifecycleContract = ResolvedConfig["ts"]["lifecycle_contracts"][number];
18
+ export type BuildConfiguration = ResolvedConfig["analysis"]["configurations"][number];
19
+ export type ProjectConfiguration = Extract<BuildConfiguration, { readonly project: string }>;
20
+ export type TemplateDelimiters = ResolvedConfig["analysis"]["template_delimiters"];
21
+ export type Sort = ResolvedConfig["reporters"]["sort"];
22
+ export type Cascade = ResolvedConfig["reporters"]["cascade"];
18
23
 
19
- /** The kind a target kind setting gives one language's declarations. */
20
- export function kindOf(setting: TargetKindSetting, language: Language): TargetKind {
21
- return typeof setting === "string" ? setting : setting[language];
24
+ /** The kind a target kind setting gives this analyzer's declarations. */
25
+ export function kindOf(kind: ResolvedConfig["target"]["kind"]): TargetKind {
26
+ return typeof kind === "string" ? kind : kind[LANGUAGE];
22
27
  }
23
28
 
24
- /** The lowest reachability class a finding must reach to be reported. */
25
- export type Confidence = "certain" | "probable" | "possible";
26
-
27
- /** Whether declarations in generated files are analyzed. */
28
- export type GeneratedFiles = "exclude" | "include";
29
-
30
- /** How a reference from a consumer's test file counts. */
31
- export type ConsumerTests = "test" | "production";
32
-
33
- /** One language an analysis covers. */
34
- export type Language = "go" | "ts";
35
-
36
- /** What a finding of one issue kind does to a run. */
37
- export type Severity = "allow" | "warn" | "deny";
38
-
39
- /** The severities ranked, the strongest highest. */
40
- const SEVERITY_RANK: Readonly<Record<Severity, number>> = { allow: 0, warn: 1, deny: 2 };
41
-
42
29
  /** Whether a finding at one severity fails a run under the failing severity. */
43
30
  export function fails(severity: Severity, failOn: Severity): boolean {
44
- return SEVERITY_RANK[severity] >= SEVERITY_RANK[failOn];
45
- }
46
-
47
- /** One rendering of the finding list. */
48
- export type Format = "text" | "json" | "github" | "sarif" | "template";
49
-
50
- /** The order findings are rendered in. */
51
- export type Sort = "position" | "size";
52
-
53
- /** How much of a dead component a rendering names. */
54
- export type Cascade = "roots" | "full";
55
-
56
- /**
57
- * A platform configuration: an operating system, an architecture and the build
58
- * tags in effect. It is the shape a language built under build constraints reads,
59
- * and this analyzer leaves it to that analysis.
60
- */
61
- interface PlatformConfiguration {
62
- readonly shape: "platform";
63
- readonly id: string;
64
- readonly os: string;
65
- readonly arch: string;
66
- readonly tags: readonly string[];
67
- }
68
-
69
- /**
70
- * A project configuration: one compiler configuration file, as a path below the
71
- * target root with `/` between segments.
72
- */
73
- export interface ProjectConfiguration {
74
- readonly shape: "project";
75
- readonly id: string;
76
- readonly project: string;
77
- }
78
-
79
- /**
80
- * One entry of the build matrix: a configuration the target builds under, in
81
- * exactly one of the two shapes the matrix admits.
82
- */
83
- export type BuildConfiguration = PlatformConfiguration | ProjectConfiguration;
84
-
85
- /**
86
- * The pair of action delimiters a template is parsed with. Both members are
87
- * required once a document names the object, so the pair is one setting rather
88
- * than two.
89
- */
90
- export interface TemplateDelimiters {
91
- readonly left: string;
92
- readonly right: string;
93
- }
94
-
95
- /** How the analysis is scoped and filtered. */
96
- export interface Analysis {
97
- readonly languages: readonly Language[];
98
- readonly minConfidence: Confidence;
99
- readonly generatedFiles: GeneratedFiles;
100
- readonly consumerTests: ConsumerTests;
101
- readonly configurations: readonly BuildConfiguration[];
102
- readonly matrixComplete: boolean;
103
- readonly templateDirs: readonly string[];
104
- readonly templateDelimiters: TemplateDelimiters;
105
- }
106
-
107
- /** How findings are rendered. */
108
- interface Reporters {
109
- readonly formats: readonly Format[];
110
- readonly sort: Sort;
111
- readonly cascade: Cascade;
112
- readonly maxFindings: number;
113
- readonly failOn: Severity;
114
- }
115
-
116
- /**
117
- * One declaration a configuration entry names, in exactly one of three shapes: a
118
- * declaration of the analyzed program by its stable symbol reference, a declaration a
119
- * module exports by the bare specifier an import writes for the module and the
120
- * declaration's path from its exports, or a declaration of the global scope by its
121
- * path from that scope. A path joins the name and each member with dots and spells a
122
- * static member with `:static` after it.
123
- */
124
- export type DeclarationEntry =
125
- | { readonly shape: "symbol"; readonly symbol: string }
126
- | { readonly shape: "module"; readonly module: string; readonly name: string }
127
- | { readonly shape: "global"; readonly global: string };
128
-
129
- /**
130
- * One framework's lifecycle contract: the declarations whose use makes a class one of
131
- * the framework's components, the classes whose subclasses are its components, and the
132
- * names of the members the framework calls on a component, each spelled as the last
133
- * component of a member's stable symbol reference.
134
- */
135
- export interface LifecycleContract {
136
- readonly components: readonly DeclarationEntry[];
137
- readonly bases: readonly DeclarationEntry[];
138
- readonly members: readonly string[];
139
- }
140
-
141
- /**
142
- * One analyzer the orchestrator may run, in exactly one of two shapes: an installed
143
- * analyzer, named by its command alone, or an acquirable one, which also names the
144
- * artifact acquisition fetches and verifies. This analyzer validates and prints the
145
- * list and runs nothing from it.
146
- */
147
- export type Provider =
148
- | {
149
- readonly shape: "installed";
150
- readonly name: string;
151
- readonly languages: readonly Language[];
152
- readonly command: string;
153
- }
154
- | {
155
- readonly shape: "acquirable";
156
- readonly name: string;
157
- readonly languages: readonly Language[];
158
- readonly command: string;
159
- readonly source: string;
160
- readonly version: string;
161
- readonly digest: string;
162
- };
163
-
164
- /** The analyzers the orchestrator runs. */
165
- interface Providers {
166
- readonly analyzers: readonly Provider[];
167
- }
168
-
169
- /** The section the TypeScript analyzer owns. */
170
- export interface TSSection {
171
- readonly testFiles: readonly string[];
172
- readonly entryFiles: readonly string[];
173
- readonly componentExtensions: readonly string[];
174
- readonly disabledConventions: readonly string[];
175
- readonly injectionRegistrations: readonly DeclarationEntry[];
176
- readonly lifecycleContracts: readonly LifecycleContract[];
177
- readonly serializers: readonly DeclarationEntry[];
178
- }
179
-
180
- /**
181
- * The resolved configuration: the closed key list of the Contract's
182
- * configuration schema, decoded, with every default applied.
183
- *
184
- * `targetKind` is empty exactly in the configuration every default states, which
185
- * is not a configuration a run may use: the field has no default and resolution
186
- * refuses a result that carries none.
187
- *
188
- * `severity` is a map rather than an object because its keys come from a
189
- * document, and an object keyed by document text answers for names it never
190
- * held. The order it is written in is the emitter's, not the map's.
191
- */
192
- export interface Config {
193
- readonly contractVersion: string;
194
- readonly targetKind: TargetKindSetting | "";
195
- readonly analysis: Analysis;
196
- readonly consumersComplete: boolean;
197
- readonly rootPatterns: readonly string[];
198
- readonly severity: ReadonlyMap<string, Severity>;
199
- readonly exemptionsDisabled: readonly string[];
200
- readonly reporters: Reporters;
201
- readonly providers: Providers;
202
- readonly ts: TSSection;
203
- }
204
-
205
- /**
206
- * The configuration every documented default states. `targetKind` is empty: the
207
- * field has no default and is never inferred.
208
- */
209
- export function defaultConfig(): Config {
210
- return {
211
- contractVersion: CONTRACT_VERSION,
212
- targetKind: "",
213
- analysis: {
214
- languages: [],
215
- minConfidence: "probable",
216
- generatedFiles: "exclude",
217
- consumerTests: "test",
218
- configurations: [],
219
- matrixComplete: false,
220
- templateDirs: [],
221
- templateDelimiters: { left: "{{", right: "}}" },
222
- },
223
- consumersComplete: false,
224
- rootPatterns: [],
225
- severity: new Map(),
226
- exemptionsDisabled: [],
227
- reporters: {
228
- formats: ["text"],
229
- sort: "position",
230
- cascade: "roots",
231
- maxFindings: 0,
232
- failOn: "deny",
233
- },
234
- providers: {
235
- analyzers: [
236
- { shape: "installed", name: "deadset-go", languages: ["go"], command: "deadset-go" },
237
- { shape: "installed", name: "deadset-ts", languages: ["ts"], command: "deadset-ts" },
238
- ],
239
- },
240
- ts: {
241
- testFiles: [
242
- "**/*.test.{ts,tsx,mts,cts}",
243
- "**/*.test-d.{ts,tsx,mts,cts}",
244
- "**/*.spec-d.{ts,tsx,mts,cts}",
245
- "**/*.spec.*",
246
- "**/__tests__/**",
247
- "**/__mocks__/**",
248
- "**/test-d/**",
249
- ],
250
- entryFiles: [],
251
- componentExtensions: [".vue", ".svelte", ".astro"],
252
- disabledConventions: [],
253
- injectionRegistrations: [],
254
- lifecycleContracts: [],
255
- serializers: [],
256
- },
257
- };
31
+ return SEVERITIES.indexOf(severity) >= SEVERITIES.indexOf(failOn);
258
32
  }
259
33
 
260
34
  /** Where a resolved setting came from, in the order the sources outrank each other. */
261
35
  export type Source = "flag" | "repository" | "central" | "default";
262
36
 
263
- /**
264
- * One setting's source together with the file or flag that supplied it. `label`
265
- * is empty exactly when `source` is `"default"`.
266
- */
37
+ /** One setting's source with the file or flag that supplied it, empty for a default. */
267
38
  export interface Origin {
268
39
  readonly source: Source;
269
40
  readonly label: string;
@@ -278,63 +49,24 @@ export function renderOrigin(origin: Origin): string {
278
49
  }
279
50
 
280
51
  /**
281
- * The origin of each resolved setting, keyed by the setting's dotted path. A
282
- * section holds no value of its own and has no entry; the severity object
283
- * carries one entry per code it names, or the entry `severity` alone when it is
284
- * empty.
52
+ * The origin of each resolved setting, keyed by the setting's dotted path. A section
53
+ * has no entry; a keyed section carries one entry per member it names, or one for
54
+ * itself when it is empty.
285
55
  */
286
56
  export type Provenance = ReadonlyMap<string, Origin>;
287
57
 
288
- /**
289
- * The configuration documents one invocation reads, each the document's text or
290
- * absent. `repositoryLabel` names the document `repository` holds and
291
- * `centralLabel` the one `central` holds; `flagLabels` names the flag that
292
- * supplied each setting `flags` names, keyed by dotted setting path.
293
- */
294
- export interface Inputs {
295
- readonly flags?: string;
296
- readonly repository?: string;
297
- readonly central?: string;
298
- readonly repositoryLabel?: string;
299
- readonly centralLabel?: string;
300
- readonly flagLabels?: ReadonlyMap<string, string>;
58
+ /** One configuration document: its text and the path it was read from. */
59
+ export interface Document {
60
+ readonly text: string;
61
+ readonly label: string;
301
62
  }
302
63
 
303
- /** Which refusal a {@link ConfigError} carries. */
304
- type ErrorKind =
305
- /**
306
- * A document that is not one JSON instance of the closed key list: a syntax
307
- * error, a value of the wrong type, a value outside the closed set a key
308
- * declares, or a member written twice at one level.
309
- */
310
- | "malformed"
311
- /**
312
- * A key the closed key list does not declare, or a severity key naming no live
313
- * kind or a kind whose severity the Contract fixes.
314
- */
315
- | "unimplemented-key"
316
- /** A resolved configuration no source supplied a target kind for. */
317
- | "missing-target-kind";
318
-
319
64
  /**
320
- * Every refusal configuration resolution makes. Each maps to the usage exit
321
- * code, and each is thrown rather than returned: a refusal ends the run, and the
322
- * one caller that turns it into an exit code is the command line.
65
+ * The configuration sources one invocation carries. `flags` holds the text each
66
+ * setting option was given, by the setting's dotted path.
323
67
  */
324
- export class ConfigError extends Error {
325
- /** Which refusal this is. */
326
- readonly kind: ErrorKind;
327
-
328
- /**
329
- * The key or field the message names, spelled as the document spells it. It is
330
- * empty when the refusal names none.
331
- */
332
- readonly key: string;
333
-
334
- constructor(kind: ErrorKind, key: string, message: string) {
335
- super(message);
336
- this.name = "ConfigError";
337
- this.kind = kind;
338
- this.key = key;
339
- }
68
+ export interface Inputs {
69
+ readonly flags?: ReadonlyMap<string, string>;
70
+ readonly repository?: Document;
71
+ readonly central?: Document;
340
72
  }