@cplieger/deadset-ts 8.0.0-dev.1 → 8.0.0-dev.11
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/README.md +1 -1
- package/dist/bin/mapper-connection.js +2 -1
- package/dist/bin/node-host.js +24 -5
- package/dist/src/analysis.js +181 -341
- package/dist/src/augmentations.js +106 -13
- package/dist/src/automatic-types.js +10 -29
- package/dist/src/build-scripts.js +425 -0
- package/dist/src/component-layer.js +4 -2
- package/dist/src/components.js +2 -3
- package/dist/src/config.js +6 -82
- package/dist/src/configuration-files.js +28 -176
- package/dist/src/configured-declarations.js +15 -20
- package/dist/src/conformance-record.js +1 -1
- package/dist/src/consumers.js +3 -30
- package/dist/src/contextual-uses.js +56 -9
- package/dist/src/contract/config.generated.js +558 -0
- package/dist/src/contract/contract.generated.js +1244 -0
- package/dist/src/contract/report.generated.js +862 -0
- package/dist/src/convention-rows.js +73 -3
- package/dist/src/conventions.js +36 -66
- package/dist/src/dependencies.js +103 -40
- package/dist/src/edges.js +38 -122
- package/dist/src/element-access.js +4 -6
- package/dist/src/entry-point-gaps.js +2 -8
- package/dist/src/entry-points.js +11 -27
- package/dist/src/enum-group.js +3 -10
- package/dist/src/erased-stores.js +4 -6
- package/dist/src/exempt-classes.js +1 -63
- package/dist/src/exempt.js +21 -40
- package/dist/src/failure.js +36 -0
- package/dist/src/file-facts.js +2 -25
- package/dist/src/findings/completion.js +139 -72
- package/dist/src/findings/dependencies-and-module-machinery.js +4 -5
- package/dist/src/findings/emitters.js +5 -5
- package/dist/src/findings/interfaces.js +4 -5
- package/dist/src/findings/intra-function.js +13 -10
- package/dist/src/findings/non-code-artifacts.js +7 -8
- package/dist/src/findings/reads-and-writes.js +16 -13
- package/dist/src/findings/self-check.js +10 -12
- package/dist/src/findings/unused-declarations.js +41 -32
- package/dist/src/findings/visibility-narrowing.js +19 -16
- package/dist/src/findings-pass.js +8 -15
- package/dist/src/framework-lifecycle.js +7 -7
- package/dist/src/fs/document.js +52 -0
- package/dist/src/fs/manifest.js +72 -0
- package/dist/src/fs/tree.js +88 -0
- package/dist/src/generated-file.js +7 -4
- package/dist/src/git-ignore.js +39 -26
- package/dist/src/graph.js +5 -3
- package/dist/src/html-entries.js +6 -33
- package/dist/src/in-operands.js +2 -1
- package/dist/src/index.js +1 -1
- package/dist/src/injection-container.js +1 -1
- package/dist/src/intra-function-parts.js +63 -43
- package/dist/src/inventory.js +2 -21
- package/dist/src/javascript-file.js +33 -0
- package/dist/src/json-document.js +198 -67
- package/dist/src/keyof-comparisons.js +4 -6
- package/dist/src/kinds.js +3 -366
- package/dist/src/load/classify.js +270 -0
- package/dist/src/load/diagnostics.js +80 -0
- package/dist/src/load/discover.js +277 -0
- package/dist/src/{emit-map.js → load/emit-map.js} +1 -1
- package/dist/src/load/expected-module.js +136 -0
- package/dist/src/load/load.js +27 -0
- package/dist/src/load/module-lookup.js +37 -0
- package/dist/src/load/plan.js +313 -0
- package/dist/src/load/specifiers.js +115 -0
- package/dist/src/load/synthesize.js +140 -0
- package/dist/src/load/test-globals.js +207 -0
- package/dist/src/load/test-joins.js +82 -0
- package/dist/src/{workspace-manifests.js → load/workspace-manifests.js} +4 -4
- package/dist/src/{workspace-programs.js → load/workspace-programs.js} +89 -66
- package/dist/src/{workspace-resolution.js → load/workspace-resolution.js} +23 -65
- package/dist/src/{workspace-run.js → load/workspace-run.js} +7 -7
- package/dist/src/{workspace.js → load/workspace.js} +62 -124
- package/dist/src/manifest.js +49 -54
- package/dist/src/matrix.js +76 -4
- package/dist/src/mdx-entries.js +3 -26
- package/dist/src/outside-tests.js +1 -1
- package/dist/src/partial.js +2 -1
- package/dist/src/paths.js +26 -15
- package/dist/src/position.js +2 -1
- package/dist/src/print.js +11 -79
- package/dist/src/product.js +13 -0
- package/dist/src/query.js +1 -0
- package/dist/src/ref.js +1 -0
- package/dist/src/references.js +48 -30
- package/dist/src/report-schema.js +51 -0
- package/dist/src/report.js +57 -41
- package/dist/src/reporters/annotations.js +15 -8
- package/dist/src/reporters/sarif.js +16 -10
- package/dist/src/reporters/template.js +4 -19
- package/dist/src/resolve.js +245 -729
- package/dist/src/roots.js +273 -87
- package/dist/src/run.js +66 -77
- package/dist/src/schema.js +320 -343
- package/dist/src/scope.js +38 -115
- package/dist/src/serialization-contract.js +595 -21
- package/dist/src/session.js +34 -29
- package/dist/src/source-files.js +1 -1
- package/dist/src/suppress-file.js +25 -28
- package/dist/src/suppress-inline.js +3 -2
- package/dist/src/suppress.js +33 -51
- package/dist/src/sweep.js +7 -9
- package/dist/src/symbol-keys.js +3 -5
- package/dist/src/template-field.js +9 -19
- package/dist/src/test-support.js +8 -11
- package/dist/src/text/compare.js +26 -0
- package/dist/src/text/glob.js +194 -0
- package/dist/src/text/named-files.js +54 -0
- package/dist/src/text/shell.js +159 -0
- package/dist/src/text/yaml.js +393 -0
- package/dist/src/type-errors.js +11 -232
- package/dist/src/unseen-loads.js +100 -0
- package/dist/src/unwrap.js +23 -0
- package/dist/src/usage.js +10 -0
- package/dist/src/verbs/analyze.js +166 -126
- package/dist/src/verbs/describe.js +9 -16
- package/dist/src/verbs/explain.js +10 -7
- package/dist/src/verbs/print-config.js +2 -1
- package/dist/src/verbs/print-projects.js +6 -4
- package/dist/src/verbs/print-retained.js +4 -2
- package/dist/src/verbs/print-roots.js +4 -2
- package/dist/src/verbs/verb.js +1 -5
- package/dist/src/verbs/version.js +14 -3
- package/dist/src/workflow-steps.js +62 -64
- package/jsr.json +1 -1
- package/package.json +5 -4
- package/src/analysis.ts +245 -502
- package/src/augmentations.ts +135 -17
- package/src/automatic-types.ts +11 -29
- package/src/build-scripts.ts +543 -0
- package/src/component-layer.ts +4 -2
- package/src/components.ts +2 -4
- package/src/config.ts +31 -302
- package/src/configuration-files.ts +34 -179
- package/src/configured-declarations.ts +18 -23
- package/src/conformance-record.ts +1 -1
- package/src/consumers.ts +6 -57
- package/src/contextual-uses.ts +64 -12
- package/src/contract/config.generated.ts +818 -0
- package/src/contract/contract.generated.ts +1308 -0
- package/src/contract/report.generated.ts +1237 -0
- package/src/convention-rows.ts +85 -3
- package/src/conventions.ts +46 -84
- package/src/dependencies.ts +118 -46
- package/src/edges.ts +41 -140
- package/src/element-access.ts +4 -7
- package/src/entry-point-gaps.ts +3 -9
- package/src/entry-points.ts +12 -38
- package/src/enum-group.ts +2 -11
- package/src/erased-stores.ts +3 -7
- package/src/exempt-classes.ts +1 -75
- package/src/exempt.ts +36 -50
- package/src/failure.ts +63 -0
- package/src/file-facts.ts +9 -24
- package/src/finding.ts +14 -9
- package/src/findings/boundary.ts +2 -0
- package/src/findings/completion.ts +181 -84
- package/src/findings/dependencies-and-module-machinery.ts +4 -7
- package/src/findings/emitter.ts +8 -9
- package/src/findings/emitters.ts +7 -7
- package/src/findings/interfaces.ts +4 -6
- package/src/findings/intra-function.ts +13 -11
- package/src/findings/non-code-artifacts.ts +9 -11
- package/src/findings/reads-and-writes.ts +20 -16
- package/src/findings/self-check.ts +11 -17
- package/src/findings/unused-declarations.ts +45 -32
- package/src/findings/visibility-narrowing.ts +20 -17
- package/src/findings-pass.ts +10 -19
- package/src/framework-lifecycle.ts +7 -7
- package/src/fs/document.ts +70 -0
- package/src/fs/manifest.ts +92 -0
- package/src/fs/tree.ts +110 -0
- package/src/generated-file.ts +7 -4
- package/src/git-ignore.ts +50 -26
- package/src/graph.ts +5 -3
- package/src/host.ts +12 -5
- package/src/html-entries.ts +6 -33
- package/src/in-operands.ts +2 -1
- package/src/index.ts +1 -1
- package/src/injection-container.ts +1 -1
- package/src/intra-function-parts.ts +73 -44
- package/src/inventory.ts +2 -20
- package/src/javascript-file.ts +37 -0
- package/src/json-document.ts +241 -76
- package/src/keyof-comparisons.ts +3 -7
- package/src/kinds.ts +5 -413
- package/src/load/classify.ts +397 -0
- package/src/load/diagnostics.ts +144 -0
- package/src/load/discover.ts +455 -0
- package/src/{emit-map.ts → load/emit-map.ts} +1 -1
- package/src/load/expected-module.ts +188 -0
- package/src/load/load.ts +73 -0
- package/src/load/module-lookup.ts +50 -0
- package/src/load/plan.ts +504 -0
- package/src/load/specifiers.ts +168 -0
- package/src/load/synthesize.ts +211 -0
- package/src/load/test-globals.ts +251 -0
- package/src/load/test-joins.ts +98 -0
- package/src/{workspace-manifests.ts → load/workspace-manifests.ts} +5 -5
- package/src/{workspace-programs.ts → load/workspace-programs.ts} +128 -85
- package/src/{workspace-resolution.ts → load/workspace-resolution.ts} +33 -76
- package/src/{workspace-run.ts → load/workspace-run.ts} +18 -16
- package/src/{workspace.ts → load/workspace.ts} +90 -134
- package/src/manifest.ts +81 -75
- package/src/matrix.ts +122 -4
- package/src/mdx-entries.ts +3 -26
- package/src/outside-tests.ts +1 -1
- package/src/partial.ts +3 -2
- package/src/paths.ts +27 -15
- package/src/position.ts +2 -1
- package/src/print.ts +12 -92
- package/src/product.ts +18 -0
- package/src/query.ts +11 -0
- package/src/ref.ts +1 -0
- package/src/references.ts +52 -31
- package/src/report-schema.ts +68 -0
- package/src/report.ts +101 -224
- package/src/reporters/annotations.ts +22 -11
- package/src/reporters/json.ts +1 -1
- package/src/reporters/reporter.ts +2 -4
- package/src/reporters/reporters.ts +1 -1
- package/src/reporters/sarif.ts +29 -16
- package/src/reporters/template.ts +4 -20
- package/src/reporters/text.ts +3 -3
- package/src/resolve.ts +283 -1114
- package/src/roots.ts +339 -104
- package/src/run.ts +75 -91
- package/src/schema.ts +391 -388
- package/src/scope.ts +46 -138
- package/src/serialization-contract.ts +763 -22
- package/src/session.ts +70 -54
- package/src/source-files.ts +1 -1
- package/src/suppress-file.ts +24 -33
- package/src/suppress-inline.ts +2 -2
- package/src/suppress.ts +43 -58
- package/src/sweep.ts +23 -9
- package/src/symbol-keys.ts +2 -5
- package/src/template-field.ts +15 -25
- package/src/test-support.ts +17 -13
- package/src/text/compare.ts +27 -0
- package/src/text/glob.ts +210 -0
- package/src/text/named-files.inputs.json +1522 -0
- package/src/text/named-files.ts +68 -0
- package/src/text/shell.ts +161 -0
- package/src/text/yaml.ts +423 -0
- package/src/type-errors.ts +18 -288
- package/src/unseen-loads.ts +134 -0
- package/src/unwrap.ts +34 -0
- package/src/usage.ts +10 -0
- package/src/verbs/analyze.ts +224 -162
- package/src/verbs/describe.ts +14 -15
- package/src/verbs/explain.ts +10 -11
- package/src/verbs/print-config.ts +2 -1
- package/src/verbs/print-projects.ts +6 -4
- package/src/verbs/print-retained.ts +4 -2
- package/src/verbs/print-roots.ts +4 -2
- package/src/verbs/verb.ts +2 -8
- package/src/verbs/version.ts +15 -3
- package/src/workflow-steps.ts +74 -64
- package/dist/src/base-url.js +0 -18
- package/dist/src/discover.js +0 -468
- package/dist/src/glob.js +0 -65
- package/dist/src/pnpm-workspace.js +0 -120
- package/dist/src/setup-failure.js +0 -23
- package/dist/src/test-joins.js +0 -101
- package/dist/src/version.js +0 -7
- package/src/base-url.ts +0 -24
- package/src/discover.ts +0 -653
- package/src/glob.ts +0 -67
- package/src/pnpm-workspace.ts +0 -135
- package/src/setup-failure.ts +0 -39
- package/src/test-joins.ts +0 -120
- package/src/version.ts +0 -7
package/src/convention-rows.ts
CHANGED
|
@@ -140,14 +140,16 @@ export interface ConventionRow {
|
|
|
140
140
|
readonly manifestEntries?: readonly ManifestEntryKey[];
|
|
141
141
|
/** The settings that make the tool's output import a runtime helper package. */
|
|
142
142
|
readonly helpers?: readonly HelperReading[];
|
|
143
|
+
/** Whether the tool bundles the package's modules, so it resolves them as a bundler does. */
|
|
144
|
+
readonly bundles?: true;
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
const SCRIPT = "{js,jsx,ts,tsx}";
|
|
146
148
|
const MODULE = "{js,mjs,ts,mts}";
|
|
147
149
|
const ANY_MODULE = "{js,mjs,cjs,ts,mts,cts}";
|
|
148
150
|
const VITE_CONFIG = `vite.config.${ANY_MODULE}`;
|
|
149
|
-
/** The legacy configuration files of ESLint
|
|
150
|
-
const ESLINTRC = [".eslintrc", ".eslintrc.json", ".eslintrc.{js,cjs}"];
|
|
151
|
+
/** The legacy configuration files of ESLint: JSON, YAML or a CommonJS module. */
|
|
152
|
+
const ESLINTRC = [".eslintrc", ".eslintrc.json", ".eslintrc.{yml,yaml}", ".eslintrc.{js,cjs}"];
|
|
151
153
|
|
|
152
154
|
const SVELTEKIT_ROUTE_FILES = "+{page,layout,server,page.server,layout.server,error}";
|
|
153
155
|
|
|
@@ -209,6 +211,60 @@ const ANGULAR_PACKAGE_KEYS: readonly PackageKey[] = [
|
|
|
209
211
|
"scripts",
|
|
210
212
|
].map((key) => ({ key, files: ["angular.json"] }));
|
|
211
213
|
|
|
214
|
+
/**
|
|
215
|
+
* The row of a code generator that writes its output below one directory its
|
|
216
|
+
* configuration's `property` sets, `fallback` where no configuration file sets it, so
|
|
217
|
+
* every file there is a generated file.
|
|
218
|
+
*/
|
|
219
|
+
function outputDirectoryRow(row: {
|
|
220
|
+
readonly name: string;
|
|
221
|
+
readonly package: string;
|
|
222
|
+
readonly range: string;
|
|
223
|
+
readonly files: readonly string[];
|
|
224
|
+
readonly property: string;
|
|
225
|
+
readonly fallback: string;
|
|
226
|
+
}): ConventionRow {
|
|
227
|
+
return {
|
|
228
|
+
name: row.name,
|
|
229
|
+
package: row.package,
|
|
230
|
+
range: row.range,
|
|
231
|
+
entries: [],
|
|
232
|
+
generated: ["<output>"],
|
|
233
|
+
moves: [
|
|
234
|
+
{
|
|
235
|
+
id: "output",
|
|
236
|
+
defaults: [row.fallback],
|
|
237
|
+
readings: [{ property: row.property, files: row.files }],
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* The test runners and the assertion, mock and runner libraries whose import is test
|
|
245
|
+
* evidence beside each runner a row reads test files for. Each applies whether or not a
|
|
246
|
+
* manifest declares it, so none is a row.
|
|
247
|
+
*/
|
|
248
|
+
export const TEST_LIBRARIES: readonly string[] = [
|
|
249
|
+
"@jest/globals",
|
|
250
|
+
"@playwright/test",
|
|
251
|
+
"ava",
|
|
252
|
+
"chai",
|
|
253
|
+
"expect",
|
|
254
|
+
"jasmine",
|
|
255
|
+
"jest",
|
|
256
|
+
"mocha",
|
|
257
|
+
"msw",
|
|
258
|
+
"nock",
|
|
259
|
+
"node:test",
|
|
260
|
+
"sinon",
|
|
261
|
+
"tap",
|
|
262
|
+
"uvu",
|
|
263
|
+
];
|
|
264
|
+
|
|
265
|
+
/** The scopes every package of which is a test library. */
|
|
266
|
+
export const TEST_LIBRARY_SCOPES: readonly string[] = ["@testing-library/"];
|
|
267
|
+
|
|
212
268
|
/** Every row, ordered by name and then by range. */
|
|
213
269
|
export const CONVENTION_ROWS: readonly ConventionRow[] = [
|
|
214
270
|
{
|
|
@@ -229,6 +285,7 @@ export const CONVENTION_ROWS: readonly ConventionRow[] = [
|
|
|
229
285
|
},
|
|
230
286
|
{
|
|
231
287
|
name: "astro",
|
|
288
|
+
bundles: true,
|
|
232
289
|
package: "astro",
|
|
233
290
|
range: ">=5.0.0 <8.0.0",
|
|
234
291
|
entries: [
|
|
@@ -274,6 +331,7 @@ export const CONVENTION_ROWS: readonly ConventionRow[] = [
|
|
|
274
331
|
range: ">=4.0.0 <10.0.0",
|
|
275
332
|
entries: [],
|
|
276
333
|
moves: [],
|
|
334
|
+
packageKeys: [{ key: "parser", files: ESLINTRC }],
|
|
277
335
|
prefixedNames: [
|
|
278
336
|
{ property: "plugins", files: ESLINTRC, prefix: "eslint-plugin" },
|
|
279
337
|
{ property: "extends", files: ESLINTRC, prefix: "eslint-plugin", marker: "plugin:" },
|
|
@@ -297,12 +355,13 @@ export const CONVENTION_ROWS: readonly ConventionRow[] = [
|
|
|
297
355
|
{
|
|
298
356
|
name: "expo-router",
|
|
299
357
|
package: "expo-router",
|
|
300
|
-
range: ">=3.0.0 <
|
|
358
|
+
range: ">=3.0.0 <59.0.0",
|
|
301
359
|
entries: [`{,src/}app/**/*.${SCRIPT}`],
|
|
302
360
|
moves: [],
|
|
303
361
|
},
|
|
304
362
|
{
|
|
305
363
|
name: "next",
|
|
364
|
+
bundles: true,
|
|
306
365
|
package: "next",
|
|
307
366
|
range: ">=13.4.0 <17.0.0",
|
|
308
367
|
generated: [".next"],
|
|
@@ -320,6 +379,7 @@ export const CONVENTION_ROWS: readonly ConventionRow[] = [
|
|
|
320
379
|
},
|
|
321
380
|
{
|
|
322
381
|
name: "nuxt",
|
|
382
|
+
bundles: true,
|
|
323
383
|
package: "nuxt",
|
|
324
384
|
range: ">=3.0.0 <5.0.0",
|
|
325
385
|
generated: [".nuxt"],
|
|
@@ -389,8 +449,17 @@ export const CONVENTION_ROWS: readonly ConventionRow[] = [
|
|
|
389
449
|
{ key: "oclif.hooks", directory: false },
|
|
390
450
|
],
|
|
391
451
|
},
|
|
452
|
+
outputDirectoryRow({
|
|
453
|
+
name: "panda",
|
|
454
|
+
package: "@pandacss/dev",
|
|
455
|
+
range: ">=0.1.0 <2.0.0",
|
|
456
|
+
files: [`panda.config.${ANY_MODULE}`],
|
|
457
|
+
property: "outdir",
|
|
458
|
+
fallback: "styled-system",
|
|
459
|
+
}),
|
|
392
460
|
{
|
|
393
461
|
name: "parcel",
|
|
462
|
+
bundles: true,
|
|
394
463
|
package: "parcel",
|
|
395
464
|
range: ">=2.0.0 <3.0.0",
|
|
396
465
|
entries: [],
|
|
@@ -456,6 +525,13 @@ export const CONVENTION_ROWS: readonly ConventionRow[] = [
|
|
|
456
525
|
},
|
|
457
526
|
],
|
|
458
527
|
},
|
|
528
|
+
{
|
|
529
|
+
name: "react-scripts",
|
|
530
|
+
package: "react-scripts",
|
|
531
|
+
range: ">=1.0.0 <6.0.0",
|
|
532
|
+
entries: [`src/index.${SCRIPT}`, "src/setupProxy.js", `src/setupTests.${SCRIPT}`],
|
|
533
|
+
moves: [],
|
|
534
|
+
},
|
|
459
535
|
{
|
|
460
536
|
name: "remix",
|
|
461
537
|
package: "@remix-run/dev",
|
|
@@ -483,6 +559,7 @@ export const CONVENTION_ROWS: readonly ConventionRow[] = [
|
|
|
483
559
|
},
|
|
484
560
|
{
|
|
485
561
|
name: "rolldown",
|
|
562
|
+
bundles: true,
|
|
486
563
|
package: "rolldown",
|
|
487
564
|
range: ">=1.0.0 <2.0.0",
|
|
488
565
|
entries: [],
|
|
@@ -528,6 +605,7 @@ export const CONVENTION_ROWS: readonly ConventionRow[] = [
|
|
|
528
605
|
},
|
|
529
606
|
{
|
|
530
607
|
name: "storybook",
|
|
608
|
+
bundles: true,
|
|
531
609
|
package: "storybook",
|
|
532
610
|
range: ">=7.0.0 <11.0.0",
|
|
533
611
|
entries: [
|
|
@@ -561,6 +639,7 @@ export const CONVENTION_ROWS: readonly ConventionRow[] = [
|
|
|
561
639
|
},
|
|
562
640
|
{
|
|
563
641
|
name: "sveltekit",
|
|
642
|
+
bundles: true,
|
|
564
643
|
package: "@sveltejs/kit",
|
|
565
644
|
range: ">=2.0.0 <3.0.0",
|
|
566
645
|
entries: [...SVELTEKIT_ENTRIES, "<params>/*.{js,ts}"],
|
|
@@ -626,6 +705,7 @@ export const CONVENTION_ROWS: readonly ConventionRow[] = [
|
|
|
626
705
|
},
|
|
627
706
|
{
|
|
628
707
|
name: "sveltekit",
|
|
708
|
+
bundles: true,
|
|
629
709
|
package: "@sveltejs/kit",
|
|
630
710
|
range: ">=3.0.0 <4.0.0",
|
|
631
711
|
entries: [...SVELTEKIT_ENTRIES, "<params>.{js,ts}"],
|
|
@@ -718,6 +798,7 @@ export const CONVENTION_ROWS: readonly ConventionRow[] = [
|
|
|
718
798
|
},
|
|
719
799
|
{
|
|
720
800
|
name: "vite",
|
|
801
|
+
bundles: true,
|
|
721
802
|
package: "vite",
|
|
722
803
|
range: ">=8.0.0 <9.0.0",
|
|
723
804
|
entries: [],
|
|
@@ -733,6 +814,7 @@ export const CONVENTION_ROWS: readonly ConventionRow[] = [
|
|
|
733
814
|
},
|
|
734
815
|
{
|
|
735
816
|
name: "vitepress",
|
|
817
|
+
bundles: true,
|
|
736
818
|
package: "vitepress",
|
|
737
819
|
range: ">=1.0.0 <2.0.0-0 || >=2.0.0-alpha.0 <3.0.0",
|
|
738
820
|
entries: [
|
package/src/conventions.ts
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
isArrayLiteralExpression,
|
|
11
|
-
isAsExpression,
|
|
12
11
|
isBinaryExpression,
|
|
13
12
|
isCallExpression,
|
|
14
13
|
isClassDeclaration,
|
|
@@ -22,27 +21,20 @@ import {
|
|
|
22
21
|
isNamedExports,
|
|
23
22
|
isNamespaceImport,
|
|
24
23
|
isNoSubstitutionTemplateLiteral,
|
|
25
|
-
isNonNullExpression,
|
|
26
24
|
isNumericLiteral,
|
|
27
25
|
isObjectBindingPattern,
|
|
28
26
|
isObjectLiteralExpression,
|
|
29
|
-
isParenthesizedExpression,
|
|
30
27
|
isPropertyAccessExpression,
|
|
31
28
|
isPropertyAssignment,
|
|
32
|
-
isSatisfiesExpression,
|
|
33
29
|
isShorthandPropertyAssignment,
|
|
34
30
|
isSpreadAssignment,
|
|
35
31
|
isStringLiteral,
|
|
36
32
|
isVariableStatement,
|
|
37
33
|
SyntaxKind,
|
|
38
|
-
type AsExpression,
|
|
39
34
|
type Identifier,
|
|
40
35
|
type Node,
|
|
41
36
|
type ObjectBindingPattern,
|
|
42
|
-
type NonNullExpression,
|
|
43
37
|
type ObjectLiteralExpression,
|
|
44
|
-
type ParenthesizedExpression,
|
|
45
|
-
type SatisfiesExpression,
|
|
46
38
|
type SourceFile,
|
|
47
39
|
} from "@typescript/native/ast";
|
|
48
40
|
import { lineOf } from "./component-files.ts";
|
|
@@ -60,12 +52,25 @@ import {
|
|
|
60
52
|
type TestFileReading,
|
|
61
53
|
} from "./convention-rows.ts";
|
|
62
54
|
import { documentStrings } from "./configuration-files.ts";
|
|
63
|
-
import { globExpression } from "./glob.ts";
|
|
64
55
|
import type { Host } from "./host.ts";
|
|
65
|
-
import {
|
|
66
|
-
|
|
56
|
+
import {
|
|
57
|
+
ancestors,
|
|
58
|
+
dirnamePath,
|
|
59
|
+
joinPath,
|
|
60
|
+
normalizePath,
|
|
61
|
+
relativePath,
|
|
62
|
+
resolvePath,
|
|
63
|
+
} from "./paths.ts";
|
|
64
|
+
import type { Failure } from "./failure.ts";
|
|
67
65
|
import type { SourceFiles } from "./source-files.ts";
|
|
68
66
|
import { satisfies } from "./version-range.ts";
|
|
67
|
+
import { bytewise } from "./text/compare.ts";
|
|
68
|
+
import { isRecord } from "./json-document.ts";
|
|
69
|
+
import { unwrapped } from "./unwrap.ts";
|
|
70
|
+
import { filesIn } from "./fs/tree.ts";
|
|
71
|
+
import { DEPENDENCY_SECTIONS, INSTALLED_PACKAGES, MANIFEST, readJSON } from "./fs/manifest.ts";
|
|
72
|
+
import { globExpression } from "./text/glob.ts";
|
|
73
|
+
import { yamlDocument } from "./text/yaml.ts";
|
|
69
74
|
|
|
70
75
|
/** One manifest the analysis reads. */
|
|
71
76
|
export interface ConventionManifest {
|
|
@@ -110,7 +115,7 @@ interface GeneratedDirectory {
|
|
|
110
115
|
/** A setup failure a row met, at the directory of the manifest that declared it. */
|
|
111
116
|
interface ConventionFailure {
|
|
112
117
|
readonly dir: string;
|
|
113
|
-
readonly failure:
|
|
118
|
+
readonly failure: Failure;
|
|
114
119
|
}
|
|
115
120
|
|
|
116
121
|
/** What the rows decided for one run. */
|
|
@@ -151,30 +156,19 @@ type ParseSource = (fileName: string, text: string) => SourceFile;
|
|
|
151
156
|
|
|
152
157
|
const JSON_EXTENSION = ".json";
|
|
153
158
|
|
|
159
|
+
/**
|
|
160
|
+
* A configuration file its tool reads as a YAML document, read as the JSON document it
|
|
161
|
+
* denotes. Its nodes' offsets are that JSON text's, so no move may read one: a failure's
|
|
162
|
+
* line would name the wrong line.
|
|
163
|
+
*/
|
|
164
|
+
const YAML_NAME = /\.ya?ml$/u;
|
|
165
|
+
|
|
154
166
|
/** A configuration file with no extension that its tool reads as a JSON document. */
|
|
155
167
|
const JSON_RC = /^\.[\w-]+rc$/u;
|
|
156
168
|
|
|
157
169
|
/** The sections an installed package is required by, so its absence fails the run. */
|
|
158
170
|
const REQUIRED_SECTIONS = ["dependencies", "devDependencies"] as const;
|
|
159
171
|
|
|
160
|
-
const DEPENDENCY_SECTIONS = [
|
|
161
|
-
...REQUIRED_SECTIONS,
|
|
162
|
-
"peerDependencies",
|
|
163
|
-
"optionalDependencies",
|
|
164
|
-
] as const;
|
|
165
|
-
|
|
166
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
167
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function readJSON(host: Host, path: string): unknown {
|
|
171
|
-
try {
|
|
172
|
-
return JSON.parse(host.readFile(path));
|
|
173
|
-
} catch {
|
|
174
|
-
return undefined;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
172
|
function declares(
|
|
179
173
|
manifest: unknown,
|
|
180
174
|
name: string,
|
|
@@ -195,38 +189,15 @@ function declares(
|
|
|
195
189
|
* none, or `undefined` where no `node_modules` holds it.
|
|
196
190
|
*/
|
|
197
191
|
function installedVersion(host: Host, dir: string, name: string): string | undefined {
|
|
198
|
-
for (
|
|
199
|
-
const path = joinPath(at,
|
|
192
|
+
for (const at of ancestors(dir)) {
|
|
193
|
+
const path = joinPath(at, INSTALLED_PACKAGES, name, MANIFEST);
|
|
200
194
|
if (host.kindOf(path) === "file") {
|
|
201
195
|
const manifest = readJSON(host, path);
|
|
202
196
|
const version = isRecord(manifest) ? manifest["version"] : undefined;
|
|
203
197
|
return typeof version === "string" ? version : "";
|
|
204
198
|
}
|
|
205
|
-
if (dirnamePath(at) === at) {
|
|
206
|
-
return undefined;
|
|
207
|
-
}
|
|
208
199
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
/** Whether one node wraps an expression without changing its value. */
|
|
212
|
-
function isWrapper(
|
|
213
|
-
node: Node,
|
|
214
|
-
): node is ParenthesizedExpression | AsExpression | SatisfiesExpression | NonNullExpression {
|
|
215
|
-
return (
|
|
216
|
-
isParenthesizedExpression(node) ||
|
|
217
|
-
isAsExpression(node) ||
|
|
218
|
-
isSatisfiesExpression(node) ||
|
|
219
|
-
isNonNullExpression(node)
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/** The expression a wrapper that changes no value holds. */
|
|
224
|
-
function unwrapped(node: Node): Node {
|
|
225
|
-
let at = node;
|
|
226
|
-
while (isWrapper(at)) {
|
|
227
|
-
at = at.expression;
|
|
228
|
-
}
|
|
229
|
-
return at;
|
|
200
|
+
return undefined;
|
|
230
201
|
}
|
|
231
202
|
|
|
232
203
|
/** The key one property is written with, where it is written as a name or as literal text. */
|
|
@@ -815,16 +786,7 @@ function expand(
|
|
|
815
786
|
/** The configuration files in one directory that one glob names, by name. */
|
|
816
787
|
function configurationFiles(host: Host, dir: string, glob: string): readonly string[] {
|
|
817
788
|
const expression = globExpression(glob);
|
|
818
|
-
|
|
819
|
-
try {
|
|
820
|
-
entries = host.readDirectory(dir);
|
|
821
|
-
} catch {
|
|
822
|
-
return [];
|
|
823
|
-
}
|
|
824
|
-
return entries
|
|
825
|
-
.filter((entry) => !entry.directory && expression.test(entry.name))
|
|
826
|
-
.map((entry) => entry.name)
|
|
827
|
-
.sort();
|
|
789
|
+
return filesIn(host, dir, (name) => expression.test(name));
|
|
828
790
|
}
|
|
829
791
|
|
|
830
792
|
/** What one move resolved to: its directories, or the failure its property met. */
|
|
@@ -883,6 +845,14 @@ function readingFiles(
|
|
|
883
845
|
} catch {
|
|
884
846
|
continue;
|
|
885
847
|
}
|
|
848
|
+
if (YAML_NAME.test(name)) {
|
|
849
|
+
const value = yamlDocument(text);
|
|
850
|
+
if (value !== undefined) {
|
|
851
|
+
const json = JSON.stringify(value);
|
|
852
|
+
found.push({ name, text: json, file: parse(`${path}${JSON_EXTENSION}`, json) });
|
|
853
|
+
}
|
|
854
|
+
continue;
|
|
855
|
+
}
|
|
886
856
|
found.push({
|
|
887
857
|
name,
|
|
888
858
|
text,
|
|
@@ -932,7 +902,7 @@ function shortNameUses(
|
|
|
932
902
|
}
|
|
933
903
|
}
|
|
934
904
|
}
|
|
935
|
-
return [...used].filter((name) => declared.has(name)).sort(
|
|
905
|
+
return [...used].filter((name) => declared.has(name)).sort(bytewise);
|
|
936
906
|
}
|
|
937
907
|
|
|
938
908
|
/**
|
|
@@ -992,7 +962,7 @@ function prefixedNameUses(
|
|
|
992
962
|
}
|
|
993
963
|
}
|
|
994
964
|
}
|
|
995
|
-
return [...used].sort(
|
|
965
|
+
return [...used].sort(bytewise);
|
|
996
966
|
}
|
|
997
967
|
|
|
998
968
|
/** The declared dependencies an applied row's helper settings use. */
|
|
@@ -1076,14 +1046,6 @@ function packageKeyUses(
|
|
|
1076
1046
|
);
|
|
1077
1047
|
}
|
|
1078
1048
|
|
|
1079
|
-
/** Two strings ordered bytewise. */
|
|
1080
|
-
function compare(a: string, b: string): number {
|
|
1081
|
-
if (a === b) {
|
|
1082
|
-
return 0;
|
|
1083
|
-
}
|
|
1084
|
-
return a < b ? -1 : 1;
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
1049
|
/**
|
|
1088
1050
|
* What the rows decide over the manifests the analysis reads. A row `disabled` names
|
|
1089
1051
|
* is skipped before anything is read for it.
|
|
@@ -1103,7 +1065,7 @@ export function readConventions(
|
|
|
1103
1065
|
const selected = new Map<string, { starts: Set<number>; texts: string[] }>();
|
|
1104
1066
|
const testFiles = new Set<string>();
|
|
1105
1067
|
for (const manifest of manifests) {
|
|
1106
|
-
const declared = readJSON(host, joinPath(manifest.dir,
|
|
1068
|
+
const declared = readJSON(host, joinPath(manifest.dir, MANIFEST));
|
|
1107
1069
|
const versions = new Map<string, string | undefined>();
|
|
1108
1070
|
const missing = new Set<string>();
|
|
1109
1071
|
for (const row of rows) {
|
|
@@ -1126,7 +1088,7 @@ export function readConventions(
|
|
|
1126
1088
|
failures.push({
|
|
1127
1089
|
dir: manifest.dir,
|
|
1128
1090
|
failure: {
|
|
1129
|
-
|
|
1091
|
+
failureClass: "missing-module",
|
|
1130
1092
|
detail:
|
|
1131
1093
|
`${manifest.path} declares ${row.package}, which no node_modules at or ` +
|
|
1132
1094
|
`above its directory holds: run the package manager's install`,
|
|
@@ -1152,7 +1114,7 @@ export function readConventions(
|
|
|
1152
1114
|
failures.push({
|
|
1153
1115
|
dir: manifest.dir,
|
|
1154
1116
|
failure: {
|
|
1155
|
-
|
|
1117
|
+
failureClass: "convention-not-literal",
|
|
1156
1118
|
detail: where === "." ? failed : `${where}/${failed}`,
|
|
1157
1119
|
},
|
|
1158
1120
|
});
|
|
@@ -1206,16 +1168,16 @@ export function readConventions(
|
|
|
1206
1168
|
const unique = [...new Map(applied.map((one) => [JSON.stringify(one), one])).values()];
|
|
1207
1169
|
unique.sort(
|
|
1208
1170
|
(a, b) =>
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1171
|
+
bytewise(a.name, b.name) ||
|
|
1172
|
+
bytewise(a.manifest, b.manifest) ||
|
|
1173
|
+
bytewise(JSON.stringify(a), JSON.stringify(b)),
|
|
1212
1174
|
);
|
|
1213
1175
|
return {
|
|
1214
1176
|
applied: unique,
|
|
1215
1177
|
globs,
|
|
1216
1178
|
generated,
|
|
1217
1179
|
failures,
|
|
1218
|
-
uses: [...uses].sort(
|
|
1180
|
+
uses: [...uses].sort(bytewise),
|
|
1219
1181
|
selected,
|
|
1220
1182
|
testFiles,
|
|
1221
1183
|
};
|
|
@@ -1273,7 +1235,7 @@ export function conventionFailuresFor(
|
|
|
1273
1235
|
conventions: Conventions,
|
|
1274
1236
|
configFile: string,
|
|
1275
1237
|
ownFiles: readonly string[],
|
|
1276
|
-
): readonly
|
|
1238
|
+
): readonly Failure[] {
|
|
1277
1239
|
return conventions.failures
|
|
1278
1240
|
.filter(
|
|
1279
1241
|
({ dir }) =>
|