@shivaedev/quality 0.69.4 → 0.69.5
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 +13 -0
- package/README.md +6 -6
- package/dist/adapters/biome/pluginContract.d.ts +3 -0
- package/dist/adapters/biome/pluginContract.d.ts.map +1 -0
- package/dist/adapters/biome/pluginContract.js +35 -0
- package/dist/adapters/biome/pluginContract.js.map +1 -0
- package/dist/adapters/biome/toolContractDefaults.d.ts +18 -0
- package/dist/adapters/biome/toolContractDefaults.d.ts.map +1 -0
- package/dist/adapters/biome/toolContractDefaults.js +28 -0
- package/dist/adapters/biome/toolContractDefaults.js.map +1 -0
- package/dist/adapters/buildEntryPaths.d.ts +2 -1
- package/dist/adapters/buildEntryPaths.d.ts.map +1 -1
- package/dist/adapters/buildEntryPaths.js +6 -3
- package/dist/adapters/buildEntryPaths.js.map +1 -1
- package/dist/adapters/buildEntryValue.d.ts +2 -1
- package/dist/adapters/buildEntryValue.d.ts.map +1 -1
- package/dist/adapters/buildEntryValue.js +11 -5
- package/dist/adapters/buildEntryValue.js.map +1 -1
- package/dist/adapters/buildHelper.d.ts +7 -0
- package/dist/adapters/buildHelper.d.ts.map +1 -0
- package/dist/adapters/buildHelper.js +55 -0
- package/dist/adapters/buildHelper.js.map +1 -0
- package/dist/adapters/bundlerEntries.d.ts +2 -1
- package/dist/adapters/bundlerEntries.d.ts.map +1 -1
- package/dist/adapters/bundlerEntries.js +27 -13
- package/dist/adapters/bundlerEntries.js.map +1 -1
- package/dist/adapters/bundlerSources.d.ts +5 -0
- package/dist/adapters/bundlerSources.d.ts.map +1 -0
- package/dist/adapters/bundlerSources.js +55 -0
- package/dist/adapters/bundlerSources.js.map +1 -0
- package/dist/adapters/composedContext.d.ts +1 -1
- package/dist/adapters/composedContext.d.ts.map +1 -1
- package/dist/adapters/composedContext.js +37 -16
- package/dist/adapters/composedContext.js.map +1 -1
- package/dist/adapters/foreignResources.d.ts.map +1 -1
- package/dist/adapters/foreignResources.js +6 -0
- package/dist/adapters/foreignResources.js.map +1 -1
- package/dist/adapters/imports/resolve.d.ts.map +1 -1
- package/dist/adapters/imports/resolve.js +14 -1
- package/dist/adapters/imports/resolve.js.map +1 -1
- package/dist/adapters/knip/configuration.d.ts.map +1 -1
- package/dist/adapters/knip/configuration.js +3 -1
- package/dist/adapters/knip/configuration.js.map +1 -1
- package/dist/adapters/knip/entryPointFindings.js +1 -1
- package/dist/adapters/knip/entryPointFindings.js.map +1 -1
- package/dist/adapters/moduleResolver.d.ts +3 -0
- package/dist/adapters/moduleResolver.d.ts.map +1 -0
- package/dist/adapters/moduleResolver.js +22 -0
- package/dist/adapters/moduleResolver.js.map +1 -0
- package/dist/adapters/reachableBuildEntries.d.ts.map +1 -1
- package/dist/adapters/reachableBuildEntries.js +5 -4
- package/dist/adapters/reachableBuildEntries.js.map +1 -1
- package/dist/adapters/reactComponent.d.ts +4 -0
- package/dist/adapters/reactComponent.d.ts.map +1 -0
- package/dist/adapters/reactComponent.js +61 -0
- package/dist/adapters/reactComponent.js.map +1 -0
- package/dist/adapters/serviceStateProblems.d.ts.map +1 -1
- package/dist/adapters/serviceStateProblems.js +2 -1
- package/dist/adapters/serviceStateProblems.js.map +1 -1
- package/dist/adapters/vitestContractPaths.d.ts +2 -0
- package/dist/adapters/vitestContractPaths.d.ts.map +1 -0
- package/dist/adapters/vitestContractPaths.js +24 -0
- package/dist/adapters/vitestContractPaths.js.map +1 -0
- package/dist/biome/recognizeDiagnostics.d.ts +1 -1
- package/dist/biome/recognizeDiagnostics.d.ts.map +1 -1
- package/dist/biome/recognizeDiagnostics.js +19 -5
- package/dist/biome/recognizeDiagnostics.js.map +1 -1
- package/dist/biome/report.d.ts.map +1 -1
- package/dist/biome/report.js +2 -1
- package/dist/biome/report.js.map +1 -1
- package/dist/imports/extract.d.ts.map +1 -1
- package/dist/imports/extract.js +3 -15
- package/dist/imports/extract.js.map +1 -1
- package/dist/naming/developmentCode.d.ts +4 -0
- package/dist/naming/developmentCode.d.ts.map +1 -0
- package/dist/naming/developmentCode.js +16 -0
- package/dist/naming/developmentCode.js.map +1 -0
- package/dist/naming/testCode.d.ts.map +1 -1
- package/dist/naming/testCode.js +3 -1
- package/dist/naming/testCode.js.map +1 -1
- package/dist/rules/effect/serviceFindings.d.ts.map +1 -1
- package/dist/rules/effect/serviceFindings.js +4 -0
- package/dist/rules/effect/serviceFindings.js.map +1 -1
- package/dist/rules/effect/serviceParameters.js +1 -1
- package/dist/rules/effect/serviceParameters.js.map +1 -1
- package/dist/rules/effect/serviceTypes.d.ts.map +1 -1
- package/dist/rules/effect/serviceTypes.js +1 -0
- package/dist/rules/effect/serviceTypes.js.map +1 -1
- package/dist/rules/imports/manifest.d.ts.map +1 -1
- package/dist/rules/imports/manifest.js +6 -1
- package/dist/rules/imports/manifest.js.map +1 -1
- package/dist/rules/imports/noTestCode.d.ts.map +1 -1
- package/dist/rules/imports/noTestCode.js +4 -2
- package/dist/rules/imports/noTestCode.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/biome/pluginContract.ts +42 -0
- package/src/adapters/biome/toolContractDefaults.ts +31 -0
- package/src/adapters/buildEntryPaths.ts +13 -4
- package/src/adapters/buildEntryValue.ts +13 -5
- package/src/adapters/buildHelper.ts +61 -0
- package/src/adapters/bundlerEntries.ts +38 -14
- package/src/adapters/bundlerSources.ts +60 -0
- package/src/adapters/composedContext.ts +42 -18
- package/src/adapters/foreignResources.ts +6 -0
- package/src/adapters/imports/resolve.ts +13 -0
- package/src/adapters/knip/configuration.ts +3 -1
- package/src/adapters/knip/entryPointFindings.ts +1 -1
- package/src/adapters/moduleResolver.ts +23 -0
- package/src/adapters/reachableBuildEntries.ts +5 -4
- package/src/adapters/reactComponent.ts +72 -0
- package/src/adapters/serviceStateProblems.ts +2 -1
- package/src/adapters/vitestContractPaths.ts +25 -0
- package/src/biome/recognizeDiagnostics.ts +26 -5
- package/src/biome/report.ts +2 -1
- package/src/imports/extract.ts +3 -17
- package/src/naming/developmentCode.ts +21 -0
- package/src/naming/testCode.ts +3 -1
- package/src/rules/effect/serviceFindings.ts +4 -0
- package/src/rules/effect/serviceParameters.ts +1 -1
- package/src/rules/effect/serviceTypes.ts +1 -0
- package/src/rules/imports/manifest.ts +6 -1
- package/src/rules/imports/noTestCode.ts +5 -2
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
import { browserDiagnostic } from "#adapters/biome/browserDiagnostic.ts";
|
|
4
|
+
import { pluginContract } from "#adapters/biome/pluginContract.ts";
|
|
4
5
|
import { syntaxOf } from "#adapters/biome/syntaxOf.ts";
|
|
5
6
|
import { vitestEntry } from "#adapters/biome/vitestEntry.ts";
|
|
6
7
|
import { nativeEffectCall } from "./nativeEffectCall.ts";
|
|
7
8
|
import type { Diagnostic } from "./report.ts";
|
|
8
9
|
import { nodeAt, offsetOf, type Syntax } from "./syntax.ts";
|
|
9
10
|
|
|
10
|
-
const RECOGNIZED: ReadonlySet<string> = new Set([
|
|
11
|
+
const RECOGNIZED: ReadonlySet<string> = new Set([
|
|
12
|
+
"lint/correctness/noComponentHookFactories",
|
|
13
|
+
"lint/style/noDoneCallback",
|
|
14
|
+
"lint/style/noDefaultExport",
|
|
15
|
+
]);
|
|
11
16
|
|
|
12
17
|
function generatorParameter(node: ts.Node, syntax: Syntax): boolean {
|
|
13
18
|
const parameter = node.parent;
|
|
@@ -38,6 +43,9 @@ function tagHandler(node: ts.Node, syntax: Syntax): boolean {
|
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
function misclassified(diagnostic: Diagnostic, syntax: Syntax): boolean {
|
|
46
|
+
if (diagnostic.category === "lint/style/noDefaultExport") {
|
|
47
|
+
return pluginContract(syntax);
|
|
48
|
+
}
|
|
41
49
|
const { start, end } = diagnostic.location;
|
|
42
50
|
const from = start === undefined ? undefined : offsetOf(syntax.source, start);
|
|
43
51
|
const to = end === undefined ? undefined : offsetOf(syntax.source, end);
|
|
@@ -55,15 +63,28 @@ function misclassified(diagnostic: Diagnostic, syntax: Syntax): boolean {
|
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
65
|
|
|
58
|
-
export function recognizeDiagnostics(
|
|
66
|
+
export function recognizeDiagnostics(
|
|
67
|
+
root: string,
|
|
68
|
+
diagnostics: readonly Diagnostic[],
|
|
69
|
+
toolDefaults: ReadonlySet<string> = new Set(),
|
|
70
|
+
): readonly Diagnostic[] {
|
|
59
71
|
const sources = new Map<string, Syntax>();
|
|
60
|
-
|
|
72
|
+
const candidates = diagnostics.filter(
|
|
73
|
+
(diagnostic) =>
|
|
74
|
+
diagnostic.category !== "lint/style/noDefaultExport"
|
|
75
|
+
|| diagnostic.location.path === undefined
|
|
76
|
+
|| !toolDefaults.has(resolve(root, diagnostic.location.path)),
|
|
77
|
+
);
|
|
78
|
+
return candidates.flatMap((diagnostic) => {
|
|
61
79
|
const path = diagnostic.location.path;
|
|
62
|
-
if (
|
|
80
|
+
if (path === undefined) {
|
|
81
|
+
return [diagnostic];
|
|
82
|
+
}
|
|
83
|
+
if (diagnostic.category === "lint/suspicious/useBaseline") {
|
|
63
84
|
const recognized = browserDiagnostic(diagnostic, resolve(root, path));
|
|
64
85
|
return recognized === undefined ? [] : [recognized];
|
|
65
86
|
}
|
|
66
|
-
if (!RECOGNIZED.has(diagnostic.category ?? "")
|
|
87
|
+
if (!RECOGNIZED.has(diagnostic.category ?? "")) {
|
|
67
88
|
return [diagnostic];
|
|
68
89
|
}
|
|
69
90
|
const file = resolve(root, path);
|
package/src/biome/report.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
2
|
import { Effect, Path, Schema } from "effect";
|
|
3
3
|
import { type BiomeRun, runBiome } from "#adapters/biome/run.ts";
|
|
4
|
+
import { toolContractDefaults } from "#adapters/biome/toolContractDefaults.ts";
|
|
4
5
|
import type { ExceptionDeclaration } from "#exceptions/declaration.ts";
|
|
5
6
|
import { SetupFailure } from "#failure.ts";
|
|
6
7
|
import { ignoredTrackedPaths } from "#inventory/trackedPaths.ts";
|
|
@@ -81,7 +82,7 @@ export const biomeReport = Effect.fn("Biome.biomeReport")(function* (
|
|
|
81
82
|
const diagnostics = [...report.diagnostics, ...(extra?.diagnostics ?? [])];
|
|
82
83
|
const unique = [...new Map(diagnostics.map((diagnostic) => [JSON.stringify(diagnostic), diagnostic])).values()];
|
|
83
84
|
return {
|
|
84
|
-
diagnostics: recognizeDiagnostics(root, unique),
|
|
85
|
+
diagnostics: recognizeDiagnostics(root, unique, yield* toolContractDefaults(root, unique)),
|
|
85
86
|
summary: { changed: report.summary.changed + (extra?.summary.changed ?? 0) },
|
|
86
87
|
};
|
|
87
88
|
});
|
package/src/imports/extract.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
|
+
import { moduleResolver } from "#adapters/moduleResolver.ts";
|
|
2
3
|
|
|
3
4
|
export type ImportKind = "import" | "path-reference" | "resolve" | "type-reference";
|
|
4
5
|
|
|
@@ -16,7 +17,7 @@ interface Found {
|
|
|
16
17
|
readonly type: boolean;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
const MAY_CALL = /\b(?:import|require)\s*\(|\b(?:require|import\.meta)\.resolve\s*\(/u;
|
|
20
|
+
const MAY_CALL = /\b(?:import|require)\s*\(|\b(?:require|import\.meta)\.resolve\s*\(|\bcreateRequire\b/u;
|
|
20
21
|
|
|
21
22
|
const JSDOC_IMPORT = "@import";
|
|
22
23
|
|
|
@@ -55,21 +56,6 @@ function isRequire(call: ts.CallExpression): boolean {
|
|
|
55
56
|
return ts.isIdentifier(call.expression) && call.expression.text === "require";
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
function isImportMeta(node: ts.Expression): boolean {
|
|
59
|
-
return ts.isMetaProperty(node) && node.keywordToken === ts.SyntaxKind.ImportKeyword && node.name.text === "meta";
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function resolver(call: ts.CallExpression): "meta" | "require" | undefined {
|
|
63
|
-
const callee = call.expression;
|
|
64
|
-
if (!ts.isPropertyAccessExpression(callee) || callee.name.text !== "resolve") {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
if (ts.isIdentifier(callee.expression) && callee.expression.text === "require") {
|
|
68
|
-
return "require";
|
|
69
|
-
}
|
|
70
|
-
return isImportMeta(callee.expression) ? "meta" : undefined;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
59
|
// Node resolves a relative import.meta.resolve() by URL arithmetic alone, so the path need not exist.
|
|
74
60
|
function isRelative(node: ts.Node | undefined): boolean {
|
|
75
61
|
return node !== undefined && ts.isStringLiteralLike(node) && (node.text.startsWith(".") || node.text.startsWith("/"));
|
|
@@ -80,7 +66,7 @@ function called(call: ts.CallExpression): Found | undefined {
|
|
|
80
66
|
if (call.expression.kind === ts.SyntaxKind.ImportKeyword || isRequire(call)) {
|
|
81
67
|
return { kind: "import", node: argument, type: false };
|
|
82
68
|
}
|
|
83
|
-
const how =
|
|
69
|
+
const how = moduleResolver(call);
|
|
84
70
|
const checked = how === "require" || (how === "meta" && !isRelative(argument));
|
|
85
71
|
return checked ? { kind: "resolve", node: argument, type: false } : undefined;
|
|
86
72
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Effect, Path } from "effect";
|
|
2
|
+
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
3
|
+
import { scriptPaths } from "#adapters/scriptPaths.ts";
|
|
4
|
+
import { isTooling } from "#imports/isTooling.ts";
|
|
5
|
+
import { packageOf, workspacePackages } from "#imports/workspace.ts";
|
|
6
|
+
import type { RuleInputs } from "#rule.ts";
|
|
7
|
+
|
|
8
|
+
export const developmentCode = Effect.fn("Naming.developmentCode")(function* (inputs: RuleInputs) {
|
|
9
|
+
const posix = yield* Path.Path.pipe(Effect.provide(Path.layer));
|
|
10
|
+
const packages = yield* Effect.promise(() => workspacePackages(inputs));
|
|
11
|
+
const scripts = yield* Effect.forEach([".", ...packages.map((owner) => owner.directory)], (directory) =>
|
|
12
|
+
Effect.promise(() => readPackageManifest(inputs.readText, posix.join(directory, "package.json"))).pipe(
|
|
13
|
+
Effect.map((manifest) => scriptPaths(directory, manifest?.scripts ?? {})),
|
|
14
|
+
),
|
|
15
|
+
);
|
|
16
|
+
const scripted = new Set(scripts.flat());
|
|
17
|
+
return (path: string) => {
|
|
18
|
+
const directory = packageOf(packages, path)?.directory ?? ".";
|
|
19
|
+
return isTooling(directory, path) || (!posix.relative(directory, path).includes("/") && scripted.has(path));
|
|
20
|
+
};
|
|
21
|
+
});
|
package/src/naming/testCode.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { isTooling } from "#imports/isTooling.ts";
|
|
|
6
6
|
import { testComposition } from "#imports/testComposition.ts";
|
|
7
7
|
import { packageOf } from "#imports/workspace.ts";
|
|
8
8
|
import type { RuleInputs } from "#rule.ts";
|
|
9
|
+
import { developmentCode } from "./developmentCode.ts";
|
|
9
10
|
import { packageTests } from "./packageTests.ts";
|
|
10
11
|
import { isTestCode } from "./testName.ts";
|
|
11
12
|
|
|
@@ -34,6 +35,7 @@ export const testCode = Effect.fn("Tests.testCode")(function* (inputs: RuleInput
|
|
|
34
35
|
const graph = yield* importGraph(inputs);
|
|
35
36
|
const directories = new Set(policies.filter((policy) => policy.private).map((policy) => policy.owner.directory));
|
|
36
37
|
const scripted = new Set(policies.flatMap((policy) => policy.scripts));
|
|
38
|
+
const tooling = yield* developmentCode(inputs);
|
|
37
39
|
for (const path of graph.modules) {
|
|
38
40
|
const owner = packageOf(graph.packages, path);
|
|
39
41
|
if (owner === undefined) {
|
|
@@ -53,7 +55,7 @@ export const testCode = Effect.fn("Tests.testCode")(function* (inputs: RuleInput
|
|
|
53
55
|
const composition = testComposition(
|
|
54
56
|
graph,
|
|
55
57
|
graph.packages.filter((owner) => directories.has(owner.directory)),
|
|
56
|
-
testFile,
|
|
58
|
+
(path) => testFile(path) || tooling(path),
|
|
57
59
|
);
|
|
58
60
|
return (path: string) => {
|
|
59
61
|
const owner = packageOf(graph.packages, path);
|
|
@@ -3,6 +3,7 @@ import ts from "typescript";
|
|
|
3
3
|
import { foreignResources } from "#adapters/foreignResources.ts";
|
|
4
4
|
import { frameworkCallback, parameterSite } from "#adapters/frameworkCallback.ts";
|
|
5
5
|
import { localFunctions } from "#adapters/localFunctions.ts";
|
|
6
|
+
import { reactComponent, reactPropParameters } from "#adapters/reactComponent.ts";
|
|
6
7
|
import type { Finding } from "#rule.ts";
|
|
7
8
|
import { layerConstructor } from "#rules/effect/layerConstructor.ts";
|
|
8
9
|
import { publicFunctions } from "#rules/effect/publicFunctions.ts";
|
|
@@ -29,6 +30,7 @@ export function serviceFindings(
|
|
|
29
30
|
services: ReturnType<typeof serviceTypes>,
|
|
30
31
|
): readonly Finding[] {
|
|
31
32
|
const resource = foreignResources(checker, sources);
|
|
33
|
+
const props = reactPropParameters(checker, sources);
|
|
32
34
|
const findings = new Map<ts.ParameterDeclaration, Finding>();
|
|
33
35
|
const visited = new Set<ts.Type>();
|
|
34
36
|
const activeSignatures = new Set<NonNullable<ts.Signature["declaration"]>>();
|
|
@@ -43,6 +45,8 @@ export function serviceFindings(
|
|
|
43
45
|
|| implementationParameter(checker, parameter, services)
|
|
44
46
|
|| resource(parameter)
|
|
45
47
|
|| frameworkCallback(checker, parameter.parent, local)
|
|
48
|
+
|| reactComponent(checker, parameter.parent)
|
|
49
|
+
|| props.has(parameter)
|
|
46
50
|
|| (signature !== undefined
|
|
47
51
|
&& (checker.getTypePredicateOfSignature(signature) !== undefined
|
|
48
52
|
|| (signature.declaration !== undefined && layerConstructor(checker, signature.declaration))
|
|
@@ -34,7 +34,7 @@ export const serviceParameters = defineRule({
|
|
|
34
34
|
});
|
|
35
35
|
}),
|
|
36
36
|
description:
|
|
37
|
-
"Exported and local functions and public methods take services from Effect's environment, including aliases, constraints, inferred/destructured parameters and factory returns. Service keys/classes, non-empty Contexts and implementation shapes are services; Effect/Stream requirements are computations. Service implementation methods, framework callbacks, owned foreign adapter resources and Layer constructors are accepted. Within Effect code, test-support/ folders are exempt. The fixed adapters/ convention bridges outside libraries to Effect values; adapters still follow this rule and ambient runtime bans. No config exceptions or inline suppressions; baseline existing debt.",
|
|
37
|
+
"Exported and local functions and public methods take services from Effect's environment, including aliases, constraints, inferred/destructured parameters and factory returns. Service keys/classes, non-empty Contexts and implementation shapes are services; Effect/Stream requirements are computations. Service implementation methods, framework callbacks, module-level React components and their props, owned foreign adapter resources and Layer constructors are accepted. Within Effect code, test-support/ folders are exempt. The fixed adapters/ convention bridges outside libraries to Effect values; adapters still follow this rule and ambient runtime bans. No config exceptions or inline suppressions; baseline existing debt.",
|
|
38
38
|
id: "effect/service-parameters",
|
|
39
39
|
registrable: false,
|
|
40
40
|
});
|
|
@@ -57,6 +57,7 @@ export function serviceTypes(checker: ts.TypeChecker, initializerState = false)
|
|
|
57
57
|
const symbol = type.getSymbol();
|
|
58
58
|
return (
|
|
59
59
|
handle
|
|
60
|
+
|| (initializerState && type.getProperty("~effect/Scope") !== undefined)
|
|
60
61
|
|| (symbol?.name === "AtomContext"
|
|
61
62
|
&& (symbol.declarations ?? []).some((declaration) =>
|
|
62
63
|
/\/effect\/(?:src|dist)\/reactivity\/Atom\.(?:d\.)?ts$/u.test(declaration.getSourceFile().fileName.replaceAll("\\", "/")),
|
|
@@ -6,6 +6,7 @@ import { isTooling } from "#imports/isTooling.ts";
|
|
|
6
6
|
import { builtinName } from "#imports/packageName.ts";
|
|
7
7
|
import { packageOf, type WorkspacePackage } from "#imports/workspace.ts";
|
|
8
8
|
import { dependencyNames, type EntryPoint, entryPointsOf, isApplication, provider, SHIPPED_FIELDS } from "#manifests/entryPoints.ts";
|
|
9
|
+
import { developmentCode } from "#naming/developmentCode.ts";
|
|
9
10
|
import { testCode } from "#naming/testCode.ts";
|
|
10
11
|
import { defineRule, type RuleInputs } from "#rule.ts";
|
|
11
12
|
import { bundleInputs } from "./bundleInputs.ts";
|
|
@@ -95,7 +96,11 @@ function undeclared(owner: WorkspacePackage, policy: ManifestDependencies | unde
|
|
|
95
96
|
export const importsManifest = defineRule({
|
|
96
97
|
check: Effect.fn("Imports.check")(function* (inputs) {
|
|
97
98
|
const graph = yield* importGraph(inputs);
|
|
98
|
-
const
|
|
99
|
+
const testFile = yield* testCode(inputs);
|
|
100
|
+
const tooling = yield* developmentCode(inputs);
|
|
101
|
+
function isTestCode(path: string) {
|
|
102
|
+
return testFile(path) || tooling(path);
|
|
103
|
+
}
|
|
99
104
|
const root: WorkspacePackage | undefined =
|
|
100
105
|
(yield* Effect.promise(() => readPackageManifest(inputs.readText, "package.json"))) === undefined ? undefined : { directory: ".", name: "." };
|
|
101
106
|
const owners = [...graph.packages, ...(root === undefined ? [] : [root])];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { importGraph } from "#imports/graph.ts";
|
|
3
|
+
import { developmentCode } from "#naming/developmentCode.ts";
|
|
3
4
|
import { testCode } from "#naming/testCode.ts";
|
|
4
5
|
import { defineRule } from "#rule.ts";
|
|
5
6
|
|
|
@@ -7,8 +8,9 @@ export const noTestCode = defineRule({
|
|
|
7
8
|
check: Effect.fn("Imports.check")(function* (inputs) {
|
|
8
9
|
const graph = yield* importGraph(inputs);
|
|
9
10
|
const isTestCode = yield* testCode(inputs);
|
|
11
|
+
const tooling = yield* developmentCode(inputs);
|
|
10
12
|
return graph.edges
|
|
11
|
-
.filter((edge) => !isTestCode(edge.from) && edge.to.kind === "file" && isTestCode(edge.to.path))
|
|
13
|
+
.filter((edge) => !(isTestCode(edge.from) || tooling(edge.from)) && edge.to.kind === "file" && isTestCode(edge.to.path))
|
|
12
14
|
.map((edge) => ({
|
|
13
15
|
file: edge.from,
|
|
14
16
|
line: edge.line,
|
|
@@ -16,7 +18,8 @@ export const noTestCode = defineRule({
|
|
|
16
18
|
subject: edge.specifier,
|
|
17
19
|
}));
|
|
18
20
|
}),
|
|
19
|
-
description:
|
|
21
|
+
description:
|
|
22
|
+
"Production modules import production code. Private test-composition packages may be consumed by tests, test support and package development scripts. Move shared production code out of test files and test-support/ into a production module.",
|
|
20
23
|
id: "imports/no-test-code",
|
|
21
24
|
registrable: false,
|
|
22
25
|
});
|