@shivaedev/quality 0.62.1 → 0.65.0
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/CHANGELOG.md +34 -0
- package/README.md +20 -4
- package/biome/plugins/ambient-runtime.grit +3 -3
- package/dist/adapters/biome/run.d.ts.map +1 -1
- package/dist/adapters/biome/run.js +6 -2
- package/dist/adapters/biome/run.js.map +1 -1
- package/dist/adapters/databaseUrlFindings.d.ts +11 -0
- package/dist/adapters/databaseUrlFindings.d.ts.map +1 -0
- package/dist/adapters/databaseUrlFindings.js +20 -0
- package/dist/adapters/databaseUrlFindings.js.map +1 -0
- package/dist/adapters/databaseUrlReads.d.ts +3 -0
- package/dist/adapters/databaseUrlReads.d.ts.map +1 -0
- package/dist/adapters/databaseUrlReads.js +107 -0
- package/dist/adapters/databaseUrlReads.js.map +1 -0
- package/dist/adapters/imports/resolve.js +1 -1
- package/dist/adapters/imports/resolve.js.map +1 -1
- package/dist/adapters/knip/report.d.ts +3 -0
- package/dist/adapters/knip/report.d.ts.map +1 -0
- package/dist/adapters/knip/report.js +22 -0
- package/dist/adapters/knip/report.js.map +1 -0
- package/dist/adapters/knip/run.d.ts +1 -1
- package/dist/adapters/knip/run.d.ts.map +1 -1
- package/dist/adapters/knip/run.js +3 -5
- package/dist/adapters/knip/run.js.map +1 -1
- package/dist/adapters/outsideImportFindings.d.ts.map +1 -1
- package/dist/adapters/outsideImportFindings.js +15 -31
- package/dist/adapters/outsideImportFindings.js.map +1 -1
- package/dist/adapters/units/runtime.d.ts +6 -0
- package/dist/adapters/units/runtime.d.ts.map +1 -0
- package/dist/adapters/units/runtime.js +46 -0
- package/dist/adapters/units/runtime.js.map +1 -0
- package/dist/adapters/units/runtimeImports.d.ts +10 -0
- package/dist/adapters/units/runtimeImports.d.ts.map +1 -0
- package/dist/adapters/units/runtimeImports.js +51 -0
- package/dist/adapters/units/runtimeImports.js.map +1 -0
- package/dist/adapters/units/runtimeOrigins.d.ts +4 -0
- package/dist/adapters/units/runtimeOrigins.d.ts.map +1 -0
- package/dist/adapters/units/runtimeOrigins.js +85 -0
- package/dist/adapters/units/runtimeOrigins.js.map +1 -0
- package/dist/adapters/units/runtimeUse.d.ts +8 -0
- package/dist/adapters/units/runtimeUse.d.ts.map +1 -0
- package/dist/adapters/units/runtimeUse.js +60 -0
- package/dist/adapters/units/runtimeUse.js.map +1 -0
- package/dist/cli/lint.js +1 -1
- package/dist/cli/lint.js.map +1 -1
- package/dist/imports/extract.d.ts.map +1 -1
- package/dist/imports/extract.js +13 -2
- package/dist/imports/extract.js.map +1 -1
- package/dist/inventory/collect.d.ts.map +1 -1
- package/dist/inventory/collect.js +3 -0
- package/dist/inventory/collect.js.map +1 -1
- package/dist/inventory/skillCopies.d.ts +7 -0
- package/dist/inventory/skillCopies.d.ts.map +1 -0
- package/dist/inventory/skillCopies.js +25 -0
- package/dist/inventory/skillCopies.js.map +1 -0
- package/dist/manifests/sorted.d.ts +1 -1
- package/dist/manifests/sorted.d.ts.map +1 -1
- package/dist/manifests/sorted.js +7 -4
- package/dist/manifests/sorted.js.map +1 -1
- package/dist/rules/builtIn.d.ts +2 -2
- package/dist/rules/builtIn.d.ts.map +1 -1
- package/dist/rules/builtIn.js +4 -0
- package/dist/rules/builtIn.js.map +1 -1
- package/dist/rules/effect/adapterImports.js +1 -1
- package/dist/rules/effect/adapterImports.js.map +1 -1
- package/dist/rules/files/folderNames.d.ts.map +1 -1
- package/dist/rules/files/folderNames.js +4 -1
- package/dist/rules/files/folderNames.js.map +1 -1
- package/dist/rules/manifestsNoTestKits.d.ts +2 -0
- package/dist/rules/manifestsNoTestKits.d.ts.map +1 -0
- package/dist/rules/manifestsNoTestKits.js +59 -0
- package/dist/rules/manifestsNoTestKits.js.map +1 -0
- package/dist/rules/stories/adapters/failureDeadline.d.ts +5 -0
- package/dist/rules/stories/adapters/failureDeadline.d.ts.map +1 -0
- package/dist/rules/stories/adapters/failureDeadline.js +66 -0
- package/dist/rules/stories/adapters/failureDeadline.js.map +1 -0
- package/dist/rules/stories/adapters/realTime.d.ts +4 -0
- package/dist/rules/stories/adapters/realTime.d.ts.map +1 -0
- package/dist/rules/stories/adapters/realTime.js +65 -0
- package/dist/rules/stories/adapters/realTime.js.map +1 -0
- package/dist/rules/stories/databaseUrl.d.ts +2 -0
- package/dist/rules/stories/databaseUrl.d.ts.map +1 -0
- package/dist/rules/stories/databaseUrl.js +8 -0
- package/dist/rules/stories/databaseUrl.js.map +1 -0
- package/dist/rules/stories/engineOf.d.ts.map +1 -1
- package/dist/rules/stories/engineOf.js +1 -0
- package/dist/rules/stories/engineOf.js.map +1 -1
- package/dist/rules/stories/specs.d.ts.map +1 -1
- package/dist/rules/stories/specs.js +2 -1
- package/dist/rules/stories/specs.js.map +1 -1
- package/dist/rules/stories/unitTests.d.ts +2 -2
- package/dist/rules/stories/unitTests.d.ts.map +1 -1
- package/dist/rules/stories/unitTests.js +6 -2
- package/dist/rules/stories/unitTests.js.map +1 -1
- package/dist/rules/stories/waitOnEvents.d.ts.map +1 -1
- package/dist/rules/stories/waitOnEvents.js +13 -70
- package/dist/rules/stories/waitOnEvents.js.map +1 -1
- package/package.json +15 -15
- package/src/adapters/biome/run.ts +6 -2
- package/src/adapters/databaseUrlFindings.ts +23 -0
- package/src/adapters/databaseUrlReads.ts +119 -0
- package/src/adapters/imports/resolve.ts +1 -1
- package/src/adapters/knip/report.ts +22 -0
- package/src/adapters/knip/run.ts +3 -7
- package/src/adapters/outsideImportFindings.ts +15 -34
- package/src/adapters/units/runtime.ts +53 -0
- package/src/adapters/units/runtimeImports.ts +60 -0
- package/src/adapters/units/runtimeOrigins.ts +96 -0
- package/src/adapters/units/runtimeUse.ts +72 -0
- package/src/cli/lint.ts +1 -1
- package/src/imports/extract.ts +16 -2
- package/src/inventory/collect.ts +3 -0
- package/src/inventory/skillCopies.ts +30 -0
- package/src/manifests/sorted.ts +9 -8
- package/src/rules/builtIn.ts +4 -0
- package/src/rules/effect/adapterImports.ts +1 -1
- package/src/rules/files/folderNames.ts +4 -1
- package/src/rules/manifestsNoTestKits.ts +73 -0
- package/src/rules/stories/adapters/failureDeadline.ts +78 -0
- package/src/rules/stories/adapters/realTime.ts +76 -0
- package/src/rules/stories/databaseUrl.ts +8 -0
- package/src/rules/stories/engineOf.ts +1 -0
- package/src/rules/stories/specs.ts +2 -1
- package/src/rules/stories/unitTests.ts +10 -2
- package/src/rules/stories/waitOnEvents.ts +12 -82
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { memberName } from "#rules/stories/syntax.ts";
|
|
3
|
+
import { exportedRuntime, importedRuntime, type RuntimeName, runtimeImport } from "./runtimeImports.ts";
|
|
4
|
+
|
|
5
|
+
function member(receiver: RuntimeName | undefined, name: string): RuntimeName | undefined {
|
|
6
|
+
return receiver === undefined ? undefined : { ...receiver, path: [...receiver.path, name] };
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function loadedModule(node: ts.CallExpression): RuntimeName | undefined {
|
|
10
|
+
if (!(node.expression.kind === ts.SyntaxKind.ImportKeyword || (ts.isIdentifier(node.expression) && node.expression.text === "require"))) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const [argument] = node.arguments;
|
|
14
|
+
return argument !== undefined && ts.isStringLiteralLike(argument) ? runtimeImport(argument.text, []) : undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function runtimeOrigins(checker: ts.TypeChecker): (node: ts.Node) => RuntimeName | undefined {
|
|
18
|
+
const known = new Map<ts.Node, RuntimeName | undefined>();
|
|
19
|
+
const visiting = new Set<ts.Node>();
|
|
20
|
+
|
|
21
|
+
function symbol(value: ts.Symbol | undefined): RuntimeName | undefined {
|
|
22
|
+
const direct = value?.declarations?.map(visit).find((name) => name !== undefined);
|
|
23
|
+
return direct ?? (value !== undefined && value.flags & ts.SymbolFlags.Alias ? symbol(checker.getAliasedSymbol(value)) : undefined);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function binding(node: ts.BindingElement): RuntimeName | undefined {
|
|
27
|
+
if (!ts.isObjectBindingPattern(node.parent)) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const name = node.propertyName ?? node.name;
|
|
31
|
+
return ts.isIdentifier(name) || ts.isStringLiteralLike(name) ? member(visit(node.parent.parent), name.text) : undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function declaration(node: ts.Node): RuntimeName | undefined {
|
|
35
|
+
if (ts.isExportSpecifier(node)) {
|
|
36
|
+
return exportedRuntime(node);
|
|
37
|
+
}
|
|
38
|
+
if (ts.isNamespaceExport(node)) {
|
|
39
|
+
return exportedRuntime(node);
|
|
40
|
+
}
|
|
41
|
+
if (ts.isVariableDeclaration(node)) {
|
|
42
|
+
return node.initializer === undefined ? undefined : visit(node.initializer);
|
|
43
|
+
}
|
|
44
|
+
return ts.isBindingElement(node) ? binding(node) : importedRuntime(node);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function nameOf(node: ts.PropertyAccessExpression | ts.ElementAccessExpression): string {
|
|
48
|
+
const name = memberName(node);
|
|
49
|
+
if (name !== undefined || ts.isPropertyAccessExpression(node)) {
|
|
50
|
+
return name ?? "";
|
|
51
|
+
}
|
|
52
|
+
const key = checker.getTypeAtLocation(node.argumentExpression);
|
|
53
|
+
return key.isStringLiteral() ? key.value : "";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function property(node: ts.PropertyAccessExpression | ts.ElementAccessExpression): RuntimeName | undefined {
|
|
57
|
+
const direct = member(visit(node.expression), nameOf(node));
|
|
58
|
+
if (direct !== undefined) {
|
|
59
|
+
return direct;
|
|
60
|
+
}
|
|
61
|
+
const receiver = ts.isIdentifier(node.expression) ? checker.getSymbolAtLocation(node.expression) : undefined;
|
|
62
|
+
const namespace = receiver?.declarations?.some(ts.isNamespaceImport) === true;
|
|
63
|
+
return namespace ? symbol(checker.getSymbolAtLocation(ts.isPropertyAccessExpression(node) ? node.name : node.argumentExpression)) : undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function origin(node: ts.Node): RuntimeName | undefined {
|
|
67
|
+
if (ts.isIdentifier(node)) {
|
|
68
|
+
return symbol(checker.getSymbolAtLocation(node));
|
|
69
|
+
}
|
|
70
|
+
if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {
|
|
71
|
+
return property(node);
|
|
72
|
+
}
|
|
73
|
+
if (
|
|
74
|
+
ts.isParenthesizedExpression(node)
|
|
75
|
+
|| ts.isAsExpression(node)
|
|
76
|
+
|| ts.isSatisfiesExpression(node)
|
|
77
|
+
|| ts.isNonNullExpression(node)
|
|
78
|
+
|| ts.isAwaitExpression(node)
|
|
79
|
+
) {
|
|
80
|
+
return visit(node.expression);
|
|
81
|
+
}
|
|
82
|
+
return ts.isCallExpression(node) ? loadedModule(node) : declaration(node);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function visit(node: ts.Node): RuntimeName | undefined {
|
|
86
|
+
if (known.has(node) || visiting.has(node)) {
|
|
87
|
+
return known.get(node);
|
|
88
|
+
}
|
|
89
|
+
visiting.add(node);
|
|
90
|
+
const name = origin(node);
|
|
91
|
+
visiting.delete(node);
|
|
92
|
+
known.set(node, name);
|
|
93
|
+
return name;
|
|
94
|
+
}
|
|
95
|
+
return visit;
|
|
96
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { type RuntimeName, runtimeImport, runtimeOf } from "./runtimeImports.ts";
|
|
3
|
+
|
|
4
|
+
function moduleRuntime(node: ts.Node): string | undefined {
|
|
5
|
+
if (ts.isImportDeclaration(node) && node.importClause === undefined && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
6
|
+
return runtimeOf(runtimeImport(node.moduleSpecifier.text, []));
|
|
7
|
+
}
|
|
8
|
+
if (
|
|
9
|
+
!(
|
|
10
|
+
ts.isExportDeclaration(node)
|
|
11
|
+
&& node.exportClause === undefined
|
|
12
|
+
&& node.moduleSpecifier !== undefined
|
|
13
|
+
&& ts.isStringLiteral(node.moduleSpecifier)
|
|
14
|
+
)
|
|
15
|
+
) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const module = node.moduleSpecifier.text;
|
|
19
|
+
if (module === "effect" || module === "effect/Effect") {
|
|
20
|
+
return module === "effect" ? "Clock" : "Effect.run*";
|
|
21
|
+
}
|
|
22
|
+
return runtimeOf(runtimeImport(module, []));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function runtimeAt(node: ts.Node, origin: (node: ts.Node) => RuntimeName | undefined): string | undefined {
|
|
26
|
+
const fromModule = moduleRuntime(node);
|
|
27
|
+
if (fromModule !== undefined) {
|
|
28
|
+
return fromModule;
|
|
29
|
+
}
|
|
30
|
+
if (ts.isCallExpression(node)) {
|
|
31
|
+
return runtimeOf(origin(node.expression)) ?? runtimeOf(origin(node));
|
|
32
|
+
}
|
|
33
|
+
return runtimeOf(origin(node));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface RuntimeUse {
|
|
37
|
+
readonly line: number;
|
|
38
|
+
readonly what: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function typeOnly(node: ts.Node): boolean {
|
|
42
|
+
if (ts.isTypeNode(node)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return ts.isImportClause(node)
|
|
46
|
+
|| ts.isExportDeclaration(node)
|
|
47
|
+
|| ts.isImportEqualsDeclaration(node)
|
|
48
|
+
|| ts.isImportSpecifier(node)
|
|
49
|
+
|| ts.isExportSpecifier(node)
|
|
50
|
+
? node.isTypeOnly
|
|
51
|
+
: false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function firstRuntimeUse(source: ts.SourceFile, origin: (node: ts.Node) => RuntimeName | undefined): RuntimeUse | undefined {
|
|
55
|
+
let first: RuntimeUse | undefined;
|
|
56
|
+
function visit(node: ts.Node): void {
|
|
57
|
+
if (first !== undefined || typeOnly(node) || (ts.isIdentifier(node) && ts.isImportClause(node.parent))) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const what = runtimeAt(node, origin);
|
|
61
|
+
if (what !== undefined) {
|
|
62
|
+
first = { line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1, what };
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (ts.isImportSpecifier(node) || ts.isNamespaceImport(node) || ts.isImportEqualsDeclaration(node) || ts.isExportSpecifier(node)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
ts.forEachChild(node, visit);
|
|
69
|
+
}
|
|
70
|
+
visit(source);
|
|
71
|
+
return first;
|
|
72
|
+
}
|
package/src/cli/lint.ts
CHANGED
|
@@ -40,7 +40,7 @@ export const lint = Effect.fn("Cli.lint")(
|
|
|
40
40
|
(effect) =>
|
|
41
41
|
withHeavyLock(effect, { command: "quality lint" }).pipe(
|
|
42
42
|
Effect.catchTag("HeavyLockError", (cause) => new SetupFailure({ cause, message: cause.message })),
|
|
43
|
-
Effect.provide(NodeCrypto.
|
|
43
|
+
Effect.provide(NodeCrypto.layerSecureRandom),
|
|
44
44
|
Effect.provide(NodePath.layer),
|
|
45
45
|
),
|
|
46
46
|
);
|
package/src/imports/extract.ts
CHANGED
|
@@ -24,12 +24,26 @@ function lineAt(source: ts.SourceFile, position: number): number {
|
|
|
24
24
|
return source.getLineAndCharacterOfPosition(position).line + 1;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
function typeBindings(bindings: ts.NamedImportBindings | ts.NamedExportBindings | undefined, defaultName?: ts.Identifier): boolean {
|
|
28
|
+
return (
|
|
29
|
+
defaultName === undefined
|
|
30
|
+
&& bindings !== undefined
|
|
31
|
+
&& (ts.isNamedImports(bindings) || ts.isNamedExports(bindings))
|
|
32
|
+
&& bindings.elements.length > 0
|
|
33
|
+
&& bindings.elements.every((element) => element.isTypeOnly)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
27
37
|
function declared(statement: ts.Statement): Found | undefined {
|
|
28
38
|
if (ts.isImportDeclaration(statement)) {
|
|
29
|
-
return {
|
|
39
|
+
return {
|
|
40
|
+
kind: "import",
|
|
41
|
+
node: statement.moduleSpecifier,
|
|
42
|
+
type: statement.importClause?.isTypeOnly === true || typeBindings(statement.importClause?.namedBindings, statement.importClause?.name),
|
|
43
|
+
};
|
|
30
44
|
}
|
|
31
45
|
if (ts.isExportDeclaration(statement)) {
|
|
32
|
-
return { kind: "import", node: statement.moduleSpecifier, type: statement.isTypeOnly };
|
|
46
|
+
return { kind: "import", node: statement.moduleSpecifier, type: statement.isTypeOnly || typeBindings(statement.exportClause) };
|
|
33
47
|
}
|
|
34
48
|
if (ts.isImportEqualsDeclaration(statement) && ts.isExternalModuleReference(statement.moduleReference)) {
|
|
35
49
|
return { kind: "import", node: statement.moduleReference.expression, type: statement.isTypeOnly };
|
package/src/inventory/collect.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { FilesystemFailure, orWhenAbsent, readRequiredText } from "./filesystem.
|
|
|
8
8
|
import { posix } from "./ignoreScope.ts";
|
|
9
9
|
import { linesOf } from "./linesOf.ts";
|
|
10
10
|
import { shadcnFiles } from "./shadcnFiles.ts";
|
|
11
|
+
import { skillCopies } from "./skillCopies.ts";
|
|
11
12
|
import { scopeAbove, walk } from "./walk.ts";
|
|
12
13
|
|
|
13
14
|
export interface InventoryScope {
|
|
@@ -50,11 +51,13 @@ export const collectInventory = Effect.fn("Inventory.collectInventory")(function
|
|
|
50
51
|
): Effect.fn.Return<Inventory, FilesystemFailure | SetupFailure, RuleServices> {
|
|
51
52
|
const excluded = ignorePatterns([...scope.exclude]);
|
|
52
53
|
const toolOwned = new Set(yield* shadcnFiles(root));
|
|
54
|
+
const copies = yield* skillCopies(root);
|
|
53
55
|
const zones = yield* Effect.forEach(scope.sources, (zone) => zoneFiles(root, zone), { concurrency: READ_CONCURRENCY });
|
|
54
56
|
const relativePaths = zones.flat().map((absolute) => posix(relative(root, absolute)));
|
|
55
57
|
const files = [...new Set(relativePaths)]
|
|
56
58
|
.filter((path) => !excluded.ignores(path))
|
|
57
59
|
.filter((path) => !toolOwned.has(path))
|
|
60
|
+
.filter((path) => !copies.owns(join(root, path)))
|
|
58
61
|
.sort((left, right) => {
|
|
59
62
|
if (left === right) {
|
|
60
63
|
return 0;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Effect, Option, Path } from "effect";
|
|
3
|
+
import { AGENTS_SKILLS, CLAUDE_SKILLS, MANIFEST } from "@shivaedev/skills/layout.ts";
|
|
4
|
+
import { readManifest } from "@shivaedev/skills/manifest.ts";
|
|
5
|
+
import { FilesystemFailure } from "#inventory/filesystem.ts";
|
|
6
|
+
import { posix } from "#inventory/ignoreScope.ts";
|
|
7
|
+
import { walk } from "#inventory/walk.ts";
|
|
8
|
+
|
|
9
|
+
export const skillCopies = Effect.fn("Inventory.skillCopies")(function* (root: string) {
|
|
10
|
+
const { dirname, join, sep } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
11
|
+
const paths = yield* walk(root);
|
|
12
|
+
const manifests = paths.filter((path) => posix(path).endsWith(`/${MANIFEST}`));
|
|
13
|
+
const owned = yield* Effect.forEach(manifests, (file) =>
|
|
14
|
+
Effect.gen(function* () {
|
|
15
|
+
const repo = dirname(dirname(dirname(file)));
|
|
16
|
+
const manifest = yield* readManifest(repo).pipe(
|
|
17
|
+
Effect.provide(NodePath.layer),
|
|
18
|
+
Effect.mapError((cause) => new FilesystemFailure({ message: cause.message, path: file })),
|
|
19
|
+
);
|
|
20
|
+
return Option.isNone(manifest)
|
|
21
|
+
? []
|
|
22
|
+
: [file, ...Object.keys(manifest.value.skills).flatMap((name) => [join(repo, AGENTS_SKILLS, name), join(repo, CLAUDE_SKILLS, name)])];
|
|
23
|
+
}),
|
|
24
|
+
);
|
|
25
|
+
const prefixes = owned.flat();
|
|
26
|
+
return {
|
|
27
|
+
owns: (path: string) => prefixes.some((prefix) => path === prefix || path.startsWith(`${prefix}${sep}`)),
|
|
28
|
+
paths: prefixes,
|
|
29
|
+
};
|
|
30
|
+
});
|
package/src/manifests/sorted.ts
CHANGED
|
@@ -6,19 +6,20 @@ import { manifestReader } from "#adapters/manifestReader.ts";
|
|
|
6
6
|
import type { SetupFailure } from "#failure.ts";
|
|
7
7
|
import { FilesystemFailure } from "#inventory/filesystem.ts";
|
|
8
8
|
import { posix } from "#inventory/ignoreScope.ts";
|
|
9
|
+
import { skillCopies } from "#inventory/skillCopies.ts";
|
|
9
10
|
import { walk } from "#inventory/walk.ts";
|
|
10
11
|
import type { RuleServices } from "#rule.ts";
|
|
11
12
|
|
|
12
13
|
export type Sorting = { readonly _tag: "Sorted" } | { readonly _tag: "Unsorted"; readonly sorted: string };
|
|
13
14
|
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
15
|
+
export const manifestsIn = Effect.fn("Manifests.manifestsIn")(function* (root: string) {
|
|
16
|
+
const copies = yield* skillCopies(root);
|
|
17
|
+
return (yield* walk(root))
|
|
18
|
+
.filter((path) => basename(path) === "package.json")
|
|
19
|
+
.filter((path) => !copies.owns(path))
|
|
20
|
+
.map((path) => posix(relative(root, path)))
|
|
21
|
+
.sort();
|
|
22
|
+
});
|
|
22
23
|
|
|
23
24
|
export function sortingOf(text: string): Sorting {
|
|
24
25
|
const sorted = sortPackageJson(text);
|
package/src/rules/builtIn.ts
CHANGED
|
@@ -35,6 +35,7 @@ import { importsRuntime } from "#rules/imports/runtime.ts";
|
|
|
35
35
|
import { jsxConditionals } from "#rules/react/jsxConditionals.ts";
|
|
36
36
|
import { adapterOnlyFakes } from "#rules/stories/adapterOnlyFakes.ts";
|
|
37
37
|
import { authSql } from "#rules/stories/authSql.ts";
|
|
38
|
+
import { databaseUrl } from "#rules/stories/databaseUrl.ts";
|
|
38
39
|
import { domainOutcomes } from "#rules/stories/domainOutcomes.ts";
|
|
39
40
|
import { storyEngine } from "#rules/stories/engine.ts";
|
|
40
41
|
import { globalRetries } from "#rules/stories/globalRetries.ts";
|
|
@@ -62,6 +63,7 @@ import { biome } from "./biome.ts";
|
|
|
62
63
|
import { manifestsApplication } from "./manifestsApplication.ts";
|
|
63
64
|
import { manifestsDependencyPins } from "./manifestsDependencyPins.ts";
|
|
64
65
|
import { manifestsExportsShape } from "./manifestsExportsShape.ts";
|
|
66
|
+
import { manifestsNoTestKits } from "./manifestsNoTestKits.ts";
|
|
65
67
|
import { manifestsSorted } from "./manifestsSorted.ts";
|
|
66
68
|
import { manifestsSourceFirst } from "./manifestsSourceFirst.ts";
|
|
67
69
|
import { manifestsValid } from "./manifestsValid.ts";
|
|
@@ -117,6 +119,7 @@ export const builtInRules = [
|
|
|
117
119
|
manifestsSorted,
|
|
118
120
|
manifestsSourceFirst,
|
|
119
121
|
manifestsExportsShape,
|
|
122
|
+
manifestsNoTestKits,
|
|
120
123
|
manifestsApplication,
|
|
121
124
|
namedAfterExport,
|
|
122
125
|
folderNames,
|
|
@@ -128,6 +131,7 @@ export const builtInRules = [
|
|
|
128
131
|
storySpecs,
|
|
129
132
|
adapterOnlyFakes,
|
|
130
133
|
globalRetries,
|
|
134
|
+
databaseUrl,
|
|
131
135
|
storyEngine,
|
|
132
136
|
queueSql,
|
|
133
137
|
queueReadouts,
|
|
@@ -4,7 +4,7 @@ import { defineRule } from "#rule.ts";
|
|
|
4
4
|
export const adapterImports = defineRule({
|
|
5
5
|
check: outsideImportFindings,
|
|
6
6
|
description:
|
|
7
|
-
"Keep value imports of non-Effect runtime dependencies, peers, optional dependencies and Node builtins in adapters/. Type-only imports, workspace modules, test-support/ kits, Effect and @shivaedev packages and
|
|
7
|
+
"Keep value imports of non-Effect runtime dependencies, peers, optional dependencies and Node builtins in adapters/. Type-only imports, workspace modules, test-support/ kits, Effect and @shivaedev packages, supported UI, routing and styling libraries in client/ folders and Vitest in unit tests are accepted. Libraries that perform I/O or manage external state still need adapters/. Move integrations into adapters/ and expose Effect values. No config exceptions or inline suppressions; baseline existing debt.",
|
|
8
8
|
id: "effect/adapter-imports",
|
|
9
9
|
registrable: false,
|
|
10
10
|
});
|
|
@@ -63,6 +63,9 @@ interface Context {
|
|
|
63
63
|
|
|
64
64
|
function messageFor(folder: string, context: Context): string | undefined {
|
|
65
65
|
const name = posix.basename(folder);
|
|
66
|
+
if (name === "internal") {
|
|
67
|
+
return 'A folder named "internal" implies privacy that export maps do not enforce. Move its files into the parent folder or a folder named after their job.';
|
|
68
|
+
}
|
|
66
69
|
if (context.owned.has(folder) || context.toolOwned.ignores(`${folder}/`) || isModule(folder, context.stems)) {
|
|
67
70
|
return undefined;
|
|
68
71
|
}
|
|
@@ -94,7 +97,7 @@ export const folderNames = defineRule({
|
|
|
94
97
|
});
|
|
95
98
|
}),
|
|
96
99
|
description:
|
|
97
|
-
"A package folder's final name or its path below the workspace package root joined with hyphens matches its unscoped package name. A module folder is named after its main file, a content folder in snake_case and every other folder in kebab-case. TanStack Router configuration owns route folder names.",
|
|
100
|
+
"Folders cannot be named internal. A package folder's final name or its path below the workspace package root joined with hyphens matches its unscoped package name. A module folder is named after its main file, a content folder in snake_case and every other folder in kebab-case. TanStack Router configuration owns route folder names.",
|
|
98
101
|
id: "files/folder-names",
|
|
99
102
|
options: Schema.toStandardSchemaV1(FolderNamesOptions, { parseOptions: { errors: "all", onExcessProperty: "error" } }),
|
|
100
103
|
validate: validateGlobs,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { manifestFiles, readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
3
|
+
import { exportedModule, exportTargets } from "#imports/packageExports.ts";
|
|
4
|
+
import { SHIPPED_FIELDS } from "#manifests/entryPoints.ts";
|
|
5
|
+
import { isTestCode } from "#naming/testName.ts";
|
|
6
|
+
import type { PackageManifest } from "#PackageManifest.ts";
|
|
7
|
+
import { defineRule, type Finding, type RuleInputs } from "#rule.ts";
|
|
8
|
+
|
|
9
|
+
const TEST_PACKAGES = new Set(["@shivaedev/test", "@shivaedev/test-story", "@shivaedev/test-sql", "@shivaedev/test-kits", "vitest"]);
|
|
10
|
+
|
|
11
|
+
const TEST_TOOLING = new Set([...TEST_PACKAGES, "@shivaedev/quality", "@shivaedev/vitest-rerun"]);
|
|
12
|
+
|
|
13
|
+
function testingModule(path: string): boolean {
|
|
14
|
+
return isTestCode(path) || /(?:^|\/)(?:testing|test-support)(?:\/|\.|$)/u.test(path);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function testingExports(exports: unknown): readonly string[] {
|
|
18
|
+
if (typeof exports !== "object" || exports === null || Array.isArray(exports)) {
|
|
19
|
+
return exportTargets(exports).filter(testingModule);
|
|
20
|
+
}
|
|
21
|
+
return Object.entries(exports).flatMap(([key, value]) => {
|
|
22
|
+
const targets = exportTargets(value);
|
|
23
|
+
if (targets.length === 0) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
return testingModule(key) ? [key] : targets.filter(testingModule);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function findingsIn(inputs: RuleInputs, path: string, manifest: PackageManifest): readonly Finding[] {
|
|
31
|
+
if (manifest.private === true || TEST_TOOLING.has(manifest.name ?? "")) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
const directory = path.slice(0, -"package.json".length);
|
|
35
|
+
const modules = inputs.files
|
|
36
|
+
.filter((file) => file.startsWith(directory))
|
|
37
|
+
.map((file) => file.slice(directory.length))
|
|
38
|
+
.filter((file) => /(?:^|\/)testing(?:\/|\.|$)/u.test(file) && exportedModule(manifest.exports, file));
|
|
39
|
+
const main = manifest.main !== undefined && testingModule(manifest.main) ? [manifest.main] : [];
|
|
40
|
+
const exports = [...new Set([...testingExports(manifest.exports), ...main, ...modules])];
|
|
41
|
+
const name = manifest.name ?? path;
|
|
42
|
+
const repair = "Move the helper into @shivaedev/test-kits and keep test dependencies in devDependencies.";
|
|
43
|
+
return [
|
|
44
|
+
...(exports.length === 0
|
|
45
|
+
? []
|
|
46
|
+
: [{ file: path, message: `Runtime package "${name}" publishes testing modules: ${exports.join(", ")}. ${repair}`, subject: "exports" }]),
|
|
47
|
+
...SHIPPED_FIELDS.flatMap((field) =>
|
|
48
|
+
Object.keys(manifest[field] ?? {})
|
|
49
|
+
.filter((dependency) => TEST_PACKAGES.has(dependency))
|
|
50
|
+
.map((dependency) => ({
|
|
51
|
+
file: path,
|
|
52
|
+
message: `Runtime package "${name}" declares test package "${dependency}" in ${field}. ${repair}`,
|
|
53
|
+
subject: `${field}.${dependency}`,
|
|
54
|
+
})),
|
|
55
|
+
),
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const manifestsNoTestKits = defineRule({
|
|
60
|
+
check: (inputs) =>
|
|
61
|
+
Effect.gen(function* () {
|
|
62
|
+
const findings = yield* Effect.forEach(manifestFiles(inputs), (path) =>
|
|
63
|
+
Effect.map(
|
|
64
|
+
Effect.promise(() => readPackageManifest(inputs.readText, path)),
|
|
65
|
+
(manifest) => (manifest === undefined ? [] : findingsIn(inputs, path, manifest)),
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
return findings.flat();
|
|
69
|
+
}),
|
|
70
|
+
description: "Runtime packages publish no testing modules and ship no test-package dependencies or peers. Move reusable helpers into test-kits.",
|
|
71
|
+
id: "manifests/no-test-kits",
|
|
72
|
+
registrable: false,
|
|
73
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { bindsModule, type ImportBinding } from "#rules/stories/importBindings.ts";
|
|
3
|
+
import { memberName, unwrapped } from "#rules/stories/syntax.ts";
|
|
4
|
+
|
|
5
|
+
function terminal(body: ts.ConciseBody): ts.Expression | undefined {
|
|
6
|
+
if (!ts.isBlock(body)) {
|
|
7
|
+
return unwrapped(body);
|
|
8
|
+
}
|
|
9
|
+
const last = body.statements.at(-1);
|
|
10
|
+
return last !== undefined && (ts.isReturnStatement(last) || ts.isExpressionStatement(last)) ? last.expression : undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function fails(expression: ts.Expression, bindings: ReadonlyMap<string, ImportBinding>): boolean {
|
|
14
|
+
const value = unwrapped(expression);
|
|
15
|
+
if (ts.isArrowFunction(value) || ts.isFunctionExpression(value)) {
|
|
16
|
+
const result = terminal(value.body);
|
|
17
|
+
return result !== undefined && fails(result, bindings);
|
|
18
|
+
}
|
|
19
|
+
if (!(ts.isCallExpression(value) && ts.isPropertyAccessExpression(value.expression))) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const receiver = value.expression.expression;
|
|
23
|
+
return (
|
|
24
|
+
ts.isIdentifier(receiver)
|
|
25
|
+
&& bindsModule(bindings.get(receiver.text), "Effect", ["effect"])
|
|
26
|
+
&& ["die", "fail"].includes(value.expression.name.text)
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function failingSleep(call: ts.CallExpression, bindings: ReadonlyMap<string, ImportBinding>): boolean {
|
|
31
|
+
const access = call.parent;
|
|
32
|
+
const pipe = access.parent;
|
|
33
|
+
if (!(ts.isPropertyAccessExpression(access) && access.name.text === "pipe" && ts.isCallExpression(pipe) && pipe.arguments.length === 1)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const step = pipe.arguments[0];
|
|
37
|
+
if (step === undefined || !ts.isCallExpression(step) || memberName(step.expression) !== "andThen") {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const receiver = ts.isPropertyAccessExpression(step.expression) ? step.expression.expression : undefined;
|
|
41
|
+
return (
|
|
42
|
+
receiver !== undefined
|
|
43
|
+
&& ts.isIdentifier(receiver)
|
|
44
|
+
&& bindsModule(bindings.get(receiver.text), "Effect", ["effect"])
|
|
45
|
+
&& step.arguments.length === 1
|
|
46
|
+
&& step.arguments[0] !== undefined
|
|
47
|
+
&& fails(step.arguments[0], bindings)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function rejectionName(call: ts.CallExpression): string | undefined {
|
|
52
|
+
for (let node: ts.Node | undefined = call.parent; node !== undefined; node = node.parent) {
|
|
53
|
+
if (
|
|
54
|
+
(ts.isArrowFunction(node) || ts.isFunctionExpression(node))
|
|
55
|
+
&& ts.isNewExpression(node.parent)
|
|
56
|
+
&& ts.isIdentifier(node.parent.expression)
|
|
57
|
+
&& node.parent.expression.text === "Promise"
|
|
58
|
+
) {
|
|
59
|
+
const name = node.parameters[1]?.name;
|
|
60
|
+
return name !== undefined && ts.isIdentifier(name) ? name.text : undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function rejectingTimer(call: ts.CallExpression): boolean {
|
|
67
|
+
const reject = rejectionName(call);
|
|
68
|
+
const callback = call.arguments[0];
|
|
69
|
+
if (reject === undefined || callback === undefined) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const body = ts.isArrowFunction(callback) || ts.isFunctionExpression(callback) ? terminal(callback.body) : callback;
|
|
73
|
+
return (
|
|
74
|
+
body !== undefined
|
|
75
|
+
&& ((ts.isIdentifier(body) && body.text === reject)
|
|
76
|
+
|| (ts.isCallExpression(body) && ts.isIdentifier(body.expression) && body.expression.text === reject))
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import type { ImportBinding } from "#rules/stories/importBindings.ts";
|
|
3
|
+
import { memberName, unwrapped } from "#rules/stories/syntax.ts";
|
|
4
|
+
import { rejectingTimer } from "./failureDeadline.ts";
|
|
5
|
+
|
|
6
|
+
const TIMERS = new Set(["setTimeout", "setInterval", "requestAnimationFrame"]);
|
|
7
|
+
const TIMER_MODULES = new Set(["node:timers", "timers", "node:timers/promises", "timers/promises"]);
|
|
8
|
+
|
|
9
|
+
function globalName(expression: ts.Expression): string | undefined {
|
|
10
|
+
const value = unwrapped(expression);
|
|
11
|
+
if (ts.isIdentifier(value)) {
|
|
12
|
+
return value.text;
|
|
13
|
+
}
|
|
14
|
+
if (ts.isPropertyAccessExpression(value) || ts.isElementAccessExpression(value)) {
|
|
15
|
+
const receiver = globalName(value.expression);
|
|
16
|
+
return receiver === "globalThis" || receiver === "window" || receiver === "global" ? memberName(value) : undefined;
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function realTime(call: ts.CallExpression | ts.NewExpression, bindings: ReadonlyMap<string, ImportBinding>): boolean {
|
|
22
|
+
const callee = unwrapped(call.expression);
|
|
23
|
+
const name = globalName(callee);
|
|
24
|
+
if (name === "Date") {
|
|
25
|
+
return !ts.isNewExpression(call) || (call.arguments?.length ?? 0) === 0;
|
|
26
|
+
}
|
|
27
|
+
if (ts.isNewExpression(call)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (name !== undefined && TIMERS.has(name)) {
|
|
31
|
+
return name !== "setTimeout" || !rejectingTimer(call);
|
|
32
|
+
}
|
|
33
|
+
if (ts.isIdentifier(callee)) {
|
|
34
|
+
const binding = bindings.get(callee.text);
|
|
35
|
+
return binding !== undefined && TIMER_MODULES.has(binding.module) && TIMERS.has(binding.imported) && !rejectingTimer(call);
|
|
36
|
+
}
|
|
37
|
+
if (!(ts.isPropertyAccessExpression(callee) || ts.isElementAccessExpression(callee))) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return timedMember(call, callee, bindings);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function bindingOf(expression: ts.Expression, bindings: ReadonlyMap<string, ImportBinding>): ImportBinding | undefined {
|
|
44
|
+
const value = unwrapped(expression);
|
|
45
|
+
if (ts.isIdentifier(value)) {
|
|
46
|
+
return bindings.get(value.text);
|
|
47
|
+
}
|
|
48
|
+
return ts.isPropertyAccessExpression(value) || ts.isElementAccessExpression(value) ? bindingOf(value.expression, bindings) : undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function timedMember(
|
|
52
|
+
call: ts.CallExpression,
|
|
53
|
+
callee: ts.PropertyAccessExpression | ts.ElementAccessExpression,
|
|
54
|
+
bindings: ReadonlyMap<string, ImportBinding>,
|
|
55
|
+
): boolean {
|
|
56
|
+
const receiver = unwrapped(callee.expression);
|
|
57
|
+
const member = memberName(callee);
|
|
58
|
+
const owner = globalName(receiver);
|
|
59
|
+
if ((owner === "Date" || owner === "performance") && member === "now") {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
const binding = bindingOf(receiver, bindings);
|
|
63
|
+
if (binding !== undefined && TIMER_MODULES.has(binding.module)) {
|
|
64
|
+
return (
|
|
65
|
+
(TIMERS.has(member ?? "") && !rejectingTimer(call))
|
|
66
|
+
|| ((binding.imported === "scheduler" || memberName(receiver) === "scheduler") && member === "wait")
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (binding?.module === "node:perf_hooks" || binding?.module === "perf_hooks") {
|
|
70
|
+
return member === "now";
|
|
71
|
+
}
|
|
72
|
+
if (owner === "process" || binding?.module === "node:process") {
|
|
73
|
+
return member === "hrtime";
|
|
74
|
+
}
|
|
75
|
+
return member === "bigint" && memberName(receiver) === "hrtime";
|
|
76
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { databaseUrlFindings } from "#adapters/databaseUrlFindings.ts";
|
|
2
|
+
import { defineRule } from "#rule.ts";
|
|
3
|
+
|
|
4
|
+
export const databaseUrl = defineRule({
|
|
5
|
+
check: databaseUrlFindings,
|
|
6
|
+
description: "Test-support reads PostgreSQL test URLs through postgresTestUrl so CI cannot silently skip PostgreSQL coverage.",
|
|
7
|
+
id: "tests/database-url",
|
|
8
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Endpoint } from "#imports/Endpoint.ts";
|
|
2
2
|
|
|
3
3
|
const ENGINES: ReadonlyArray<readonly [string, readonly string[]]> = [
|
|
4
|
+
["an Effect test runner", ["@shivaedev/test/adapters/it.ts", "@shivaedev/test/adapters/makeEffectIt.ts"]],
|
|
4
5
|
["the file system", ["node:fs"]],
|
|
5
6
|
[
|
|
6
7
|
"the network",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
+
import { runtime } from "#adapters/units/runtime.ts";
|
|
3
4
|
import { importGraph } from "#imports/graph.ts";
|
|
4
5
|
import { packageOf } from "#imports/workspace.ts";
|
|
5
6
|
import { testName } from "#naming/testName.ts";
|
|
@@ -62,7 +63,7 @@ export const storySpecs = defineRule({
|
|
|
62
63
|
const graph = yield* importGraph(inputs);
|
|
63
64
|
const exempt = yield* Effect.promise(() => storyPrerequisites(inputs, graph.packages));
|
|
64
65
|
const origins = storyOrigins(inputs, graph);
|
|
65
|
-
const unit = unitTests(graph, inputs.sources);
|
|
66
|
+
const unit = unitTests(graph, inputs.sources, runtime(origins.checker, origins.source));
|
|
66
67
|
return inputs.sources.flatMap((file) => {
|
|
67
68
|
const name = testName(file.path);
|
|
68
69
|
if (name?.modifiers.includes("unit") === true) {
|
|
@@ -43,7 +43,7 @@ function reachFinding(file: string, reached: Reached<string>): Finding {
|
|
|
43
43
|
function standMessage(stand: Stand): string {
|
|
44
44
|
return stand.why === "mocks"
|
|
45
45
|
? `mocks with ${stand.what}. A unit test calls real code with real values and stands nothing in for a collaborator.`
|
|
46
|
-
: `provides services with ${stand.what}. A unit test
|
|
46
|
+
: `provides services with ${stand.what}. A unit test uses plain Vitest it and pure APIs without an Effect runner or clock.`;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function where(file: string, module: string, trail: Trail): string {
|
|
@@ -75,10 +75,18 @@ function syntaxFindings(file: string, module: string, trail: Trail, source: Sour
|
|
|
75
75
|
return [...stands, ...dom];
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
export function unitTests(
|
|
78
|
+
export function unitTests(
|
|
79
|
+
graph: ImportGraph,
|
|
80
|
+
sources: readonly SourceFile[],
|
|
81
|
+
runtime: (file: string, edgesFrom: ReadonlyMap<string, readonly ImportEdge[]>) => Finding | undefined,
|
|
82
|
+
): (file: string) => readonly Finding[] {
|
|
79
83
|
const byPath = new Map(sources.map((source) => [source.path, source]));
|
|
80
84
|
const edgesFrom = runtimeEdges(graph, byPath);
|
|
81
85
|
return (file) => {
|
|
86
|
+
const reachedRuntime = runtime(file, edgesFrom);
|
|
87
|
+
if (reachedRuntime !== undefined) {
|
|
88
|
+
return [reachedRuntime];
|
|
89
|
+
}
|
|
82
90
|
const walked = walkFrom(file, edgesFrom, engineOf);
|
|
83
91
|
const checked = [...walked.visited].filter(([module]) => module === file || isTestSupport(module));
|
|
84
92
|
return [
|