@shivaedev/quality 0.54.0 → 0.56.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 +33 -0
- package/README.md +19 -17
- package/dist/adapters/ImportCompiler.d.ts +21 -0
- package/dist/adapters/ImportCompiler.d.ts.map +1 -0
- package/dist/adapters/ImportCompiler.js +22 -0
- package/dist/adapters/ImportCompiler.js.map +1 -0
- package/dist/adapters/compileCache.config.d.ts +2 -0
- package/dist/adapters/compileCache.config.d.ts.map +1 -0
- package/dist/adapters/compileCache.config.js +3 -0
- package/dist/adapters/compileCache.config.js.map +1 -0
- package/dist/adapters/imports/browserChecker.d.ts +3 -0
- package/dist/adapters/imports/browserChecker.d.ts.map +1 -0
- package/dist/adapters/imports/browserChecker.js +8 -0
- package/dist/adapters/imports/browserChecker.js.map +1 -0
- package/dist/adapters/imports/departures.d.ts +5 -0
- package/dist/adapters/imports/departures.d.ts.map +1 -0
- package/dist/adapters/imports/departures.js +61 -0
- package/dist/adapters/imports/departures.js.map +1 -0
- package/dist/adapters/imports/graph.d.ts +4 -0
- package/dist/adapters/imports/graph.d.ts.map +1 -0
- package/dist/adapters/imports/graph.js +44 -0
- package/dist/adapters/imports/graph.js.map +1 -0
- package/dist/{imports → adapters/imports}/projects.d.ts +4 -1
- package/dist/adapters/imports/projects.d.ts.map +1 -0
- package/dist/{imports → adapters/imports}/projects.js +42 -17
- package/dist/adapters/imports/projects.js.map +1 -0
- package/dist/{imports → adapters/imports}/resolve.d.ts +3 -10
- package/dist/adapters/imports/resolve.d.ts.map +1 -0
- package/dist/{imports → adapters/imports}/resolve.js +6 -4
- package/dist/adapters/imports/resolve.js.map +1 -0
- package/dist/adapters/knip/entryPointFindings.d.ts +2 -1
- package/dist/adapters/knip/entryPointFindings.d.ts.map +1 -1
- package/dist/adapters/knip/entryPointFindings.js +7 -6
- package/dist/adapters/knip/entryPointFindings.js.map +1 -1
- 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 +1 -1
- package/dist/adapters/knip/run.js.map +1 -1
- package/dist/adapters/manifestInventory.d.ts.map +1 -1
- package/dist/adapters/manifestInventory.js +3 -1
- package/dist/adapters/manifestInventory.js.map +1 -1
- package/dist/adapters/manifestReader.d.ts +2 -2
- package/dist/adapters/manifestReader.d.ts.map +1 -1
- package/dist/adapters/manifestReader.js +2 -1
- package/dist/adapters/manifestReader.js.map +1 -1
- package/dist/adapters/rule.d.ts +9 -0
- package/dist/adapters/rule.d.ts.map +1 -0
- package/dist/adapters/rule.js +35 -0
- package/dist/adapters/rule.js.map +1 -0
- package/dist/adapters/standardSchema.d.ts.map +1 -0
- package/dist/adapters/standardSchema.js.map +1 -0
- package/dist/adapters/testProjects.d.ts.map +1 -1
- package/dist/adapters/testProjects.js +1 -0
- package/dist/adapters/testProjects.js.map +1 -1
- package/dist/biome/report.d.ts +2 -1
- package/dist/biome/report.d.ts.map +1 -1
- package/dist/biome/report.js +11 -5
- package/dist/biome/report.js.map +1 -1
- package/dist/cli/lint.d.ts.map +1 -1
- package/dist/cli/lint.js +3 -1
- package/dist/cli/lint.js.map +1 -1
- package/dist/config/decode.d.ts +2 -2
- package/dist/config/decode.d.ts.map +1 -1
- package/dist/config/decode.js +3 -2
- package/dist/config/decode.js.map +1 -1
- package/dist/config/resolve.d.ts +2 -2
- package/dist/config/resolve.d.ts.map +1 -1
- package/dist/config/resolve.js +2 -1
- package/dist/config/resolve.js.map +1 -1
- package/dist/config.d.ts +5 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/decoded.d.ts.map +1 -1
- package/dist/decoded.js +1 -1
- package/dist/decoded.js.map +1 -1
- package/dist/engine/runRules.d.ts.map +1 -1
- package/dist/engine/runRules.js +29 -6
- package/dist/engine/runRules.js.map +1 -1
- package/dist/engine/session.d.ts +3 -2
- package/dist/engine/session.d.ts.map +1 -1
- package/dist/engine/session.js +9 -6
- package/dist/engine/session.js.map +1 -1
- package/dist/exceptions/biomeFindings.d.ts +3 -0
- package/dist/exceptions/biomeFindings.d.ts.map +1 -1
- package/dist/exceptions/biomeFindings.js +21 -0
- package/dist/exceptions/biomeFindings.js.map +1 -1
- package/dist/hooks/preCommit.js +1 -1
- package/dist/hooks/preCommit.js.map +1 -1
- package/dist/imports/Endpoint.d.ts +9 -0
- package/dist/imports/Endpoint.d.ts.map +1 -0
- package/dist/imports/Endpoint.js +2 -0
- package/dist/imports/Endpoint.js.map +1 -0
- package/dist/imports/browserGlobals.d.ts +2 -1
- package/dist/imports/browserGlobals.d.ts.map +1 -1
- package/dist/imports/browserGlobals.js +6 -9
- package/dist/imports/browserGlobals.js.map +1 -1
- package/dist/imports/departures.d.ts +3 -2
- package/dist/imports/departures.d.ts.map +1 -1
- package/dist/imports/departures.js +8 -61
- package/dist/imports/departures.js.map +1 -1
- package/dist/imports/extract.d.ts +2 -1
- package/dist/imports/extract.d.ts.map +1 -1
- package/dist/imports/extract.js +11 -10
- package/dist/imports/extract.js.map +1 -1
- package/dist/imports/fences/check.d.ts +3 -2
- package/dist/imports/fences/check.d.ts.map +1 -1
- package/dist/imports/fences/check.js +5 -4
- package/dist/imports/fences/check.js.map +1 -1
- package/dist/imports/fences/compilePolicy.js.map +1 -1
- package/dist/imports/fences/match.d.ts +1 -1
- package/dist/imports/fences/match.d.ts.map +1 -1
- package/dist/imports/fences/match.js.map +1 -1
- package/dist/imports/fences/reach.d.ts +1 -1
- package/dist/imports/fences/reach.d.ts.map +1 -1
- package/dist/imports/fences/vocabulary.d.ts +1 -1
- package/dist/imports/fences/vocabulary.d.ts.map +1 -1
- package/dist/imports/graph.d.ts +6 -4
- package/dist/imports/graph.d.ts.map +1 -1
- package/dist/imports/graph.js +17 -53
- package/dist/imports/graph.js.map +1 -1
- package/dist/manifests/sorted.d.ts.map +1 -1
- package/dist/manifests/sorted.js +1 -1
- package/dist/manifests/sorted.js.map +1 -1
- package/dist/rule.d.ts +12 -8
- package/dist/rule.d.ts.map +1 -1
- package/dist/rule.js +8 -31
- package/dist/rule.js.map +1 -1
- package/dist/rules/builtIn.d.ts +1 -1
- package/dist/rules/builtIn.d.ts.map +1 -1
- package/dist/rules/builtIn.js +2 -0
- package/dist/rules/builtIn.js.map +1 -1
- package/dist/rules/effect/program.js +1 -1
- package/dist/rules/effect/program.js.map +1 -1
- package/dist/rules/imports/adminPaths.js +1 -1
- package/dist/rules/imports/adminPaths.js.map +1 -1
- package/dist/rules/imports/aliased.d.ts.map +1 -1
- package/dist/rules/imports/aliased.js +3 -2
- package/dist/rules/imports/aliased.js.map +1 -1
- package/dist/rules/imports/cycles.d.ts.map +1 -1
- package/dist/rules/imports/cycles.js +4 -3
- package/dist/rules/imports/cycles.js.map +1 -1
- package/dist/rules/imports/manifest.d.ts.map +1 -1
- package/dist/rules/imports/manifest.js +6 -5
- 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 +3 -2
- package/dist/rules/imports/noTestCode.js.map +1 -1
- package/dist/rules/imports/resolvable.d.ts.map +1 -1
- package/dist/rules/imports/resolvable.js +10 -7
- package/dist/rules/imports/resolvable.js.map +1 -1
- package/dist/rules/imports/runtime.d.ts.map +1 -1
- package/dist/rules/imports/runtime.js +3 -2
- package/dist/rules/imports/runtime.js.map +1 -1
- package/dist/rules/stories/collectionOrigins.d.ts +1 -1
- package/dist/rules/stories/collectionOrigins.d.ts.map +1 -1
- package/dist/rules/stories/collectionOrigins.js.map +1 -1
- package/dist/rules/stories/engine.d.ts.map +1 -1
- package/dist/rules/stories/engine.js +5 -4
- package/dist/rules/stories/engine.js.map +1 -1
- package/dist/rules/stories/engineOf.d.ts +1 -1
- package/dist/rules/stories/engineOf.d.ts.map +1 -1
- package/dist/rules/stories/globalRetries.d.ts +2 -0
- package/dist/rules/stories/globalRetries.d.ts.map +1 -0
- package/dist/rules/stories/globalRetries.js +45 -0
- package/dist/rules/stories/globalRetries.js.map +1 -0
- package/dist/rules/stories/importOrigin.d.ts +3 -1
- package/dist/rules/stories/importOrigin.d.ts.map +1 -1
- package/dist/rules/stories/importOrigin.js +15 -0
- package/dist/rules/stories/importOrigin.js.map +1 -1
- package/dist/rules/stories/noExpect.d.ts.map +1 -1
- package/dist/rules/stories/noExpect.js +4 -3
- package/dist/rules/stories/noExpect.js.map +1 -1
- package/dist/rules/stories/origins.d.ts.map +1 -1
- package/dist/rules/stories/origins.js +14 -12
- package/dist/rules/stories/origins.js.map +1 -1
- package/dist/rules/stories/retryOption.d.ts +3 -0
- package/dist/rules/stories/retryOption.d.ts.map +1 -0
- package/dist/rules/stories/retryOption.js +37 -0
- package/dist/rules/stories/retryOption.js.map +1 -0
- package/dist/rules/stories/sources.d.ts +1 -1
- package/dist/rules/stories/sources.d.ts.map +1 -1
- package/dist/rules/stories/sources.js +1 -1
- package/dist/rules/stories/sources.js.map +1 -1
- package/dist/rules/stories/specs.d.ts.map +1 -1
- package/dist/rules/stories/specs.js +5 -4
- package/dist/rules/stories/specs.js.map +1 -1
- package/package.json +5 -5
- package/src/adapters/ImportCompiler.ts +30 -0
- package/src/adapters/compileCache.config.ts +3 -0
- package/src/adapters/imports/browserChecker.ts +8 -0
- package/src/adapters/imports/departures.ts +82 -0
- package/src/adapters/imports/graph.ts +48 -0
- package/src/{imports → adapters/imports}/projects.ts +61 -27
- package/src/{imports → adapters/imports}/resolve.ts +9 -10
- package/src/adapters/knip/entryPointFindings.ts +12 -9
- package/src/adapters/knip/run.ts +1 -1
- package/src/adapters/manifestInventory.ts +3 -1
- package/src/adapters/manifestReader.ts +4 -3
- package/src/adapters/rule.ts +53 -0
- package/src/adapters/testProjects.ts +1 -0
- package/src/biome/report.ts +11 -5
- package/src/cli/lint.ts +3 -0
- package/src/config/decode.ts +5 -4
- package/src/config/resolve.ts +7 -6
- package/src/config.ts +7 -5
- package/src/decoded.ts +1 -1
- package/src/engine/runRules.ts +31 -11
- package/src/engine/session.ts +14 -13
- package/src/exceptions/biomeFindings.ts +29 -0
- package/src/hooks/preCommit.ts +1 -1
- package/src/imports/Endpoint.ts +3 -0
- package/src/imports/browserGlobals.ts +6 -10
- package/src/imports/departures.ts +9 -80
- package/src/imports/extract.ts +12 -10
- package/src/imports/fences/check.ts +6 -5
- package/src/imports/fences/compilePolicy.ts +1 -1
- package/src/imports/fences/match.ts +1 -1
- package/src/imports/fences/reach.ts +1 -1
- package/src/imports/fences/vocabulary.ts +1 -1
- package/src/imports/graph.ts +27 -60
- package/src/manifests/sorted.ts +3 -3
- package/src/rule.ts +20 -52
- package/src/rules/builtIn.ts +2 -0
- package/src/rules/effect/program.ts +1 -1
- package/src/rules/imports/adminPaths.ts +1 -1
- package/src/rules/imports/aliased.ts +10 -7
- package/src/rules/imports/cycles.ts +4 -3
- package/src/rules/imports/manifest.ts +8 -5
- package/src/rules/imports/noTestCode.ts +12 -9
- package/src/rules/imports/resolvable.ts +10 -7
- package/src/rules/imports/runtime.ts +3 -2
- package/src/rules/stories/collectionOrigins.ts +13 -1
- package/src/rules/stories/engine.ts +5 -4
- package/src/rules/stories/engineOf.ts +1 -1
- package/src/rules/stories/globalRetries.ts +50 -0
- package/src/rules/stories/importOrigin.ts +17 -0
- package/src/rules/stories/noExpect.ts +4 -3
- package/src/rules/stories/origins.ts +14 -13
- package/src/rules/stories/retryOption.ts +41 -0
- package/src/rules/stories/sources.ts +1 -1
- package/src/rules/stories/specs.ts +5 -4
- package/dist/imports/projects.d.ts.map +0 -1
- package/dist/imports/projects.js.map +0 -1
- package/dist/imports/resolve.d.ts.map +0 -1
- package/dist/imports/resolve.js.map +0 -1
- package/dist/standardSchema.d.ts.map +0 -1
- package/dist/standardSchema.js.map +0 -1
- /package/dist/{standardSchema.d.ts → adapters/standardSchema.d.ts} +0 -0
- /package/dist/{standardSchema.js → adapters/standardSchema.js} +0 -0
- /package/src/{standardSchema.ts → adapters/standardSchema.ts} +0 -0
package/src/cli/lint.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { relative } from "node:path";
|
|
2
|
+
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
|
|
2
3
|
import * as NodePath from "@effect/platform-node/NodePath";
|
|
3
4
|
import { Console, Effect } from "effect";
|
|
4
5
|
import { withHeavyLock } from "@shivaedev/heavy-lock/withHeavyLock.ts";
|
|
@@ -20,6 +21,7 @@ export const lint = Effect.fn("Cli.lint")(
|
|
|
20
21
|
...evaluated,
|
|
21
22
|
looseBaseline: evaluated.looseBaseline.filter(({ entry }) => !rejected.has(keyOf(entry.rule, entry.file))),
|
|
22
23
|
staleBaseline: [...evaluated.staleBaseline, ...loose],
|
|
24
|
+
staleRegistry: [...evaluated.staleRegistry, ...session.staleRegistry],
|
|
23
25
|
};
|
|
24
26
|
yield* Console.log(
|
|
25
27
|
render(outcome, {
|
|
@@ -37,6 +39,7 @@ export const lint = Effect.fn("Cli.lint")(
|
|
|
37
39
|
(effect) =>
|
|
38
40
|
withHeavyLock(effect, { command: "quality lint" }).pipe(
|
|
39
41
|
Effect.catchTag("HeavyLockError", (cause) => new SetupFailure({ cause, message: cause.message })),
|
|
42
|
+
Effect.provide(NodeCrypto.layer),
|
|
40
43
|
Effect.provide(NodePath.layer),
|
|
41
44
|
),
|
|
42
45
|
);
|
package/src/config/decode.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
+
import { ruleConfiguration } from "#adapters/rule.ts";
|
|
2
3
|
import { type Decoded, decodeWith } from "#decoded.ts";
|
|
3
4
|
import { ExceptionDeclaration } from "#exceptions/declaration.ts";
|
|
4
|
-
import type {
|
|
5
|
+
import type { RegisteredRule } from "#rule.ts";
|
|
5
6
|
|
|
6
|
-
function isRule(value: unknown): value is
|
|
7
|
+
function isRule(value: unknown): value is RegisteredRule {
|
|
7
8
|
return (
|
|
8
9
|
typeof value === "object"
|
|
9
10
|
&& value !== null
|
|
@@ -11,8 +12,8 @@ function isRule(value: unknown): value is Rule {
|
|
|
11
12
|
&& typeof value.id === "string"
|
|
12
13
|
&& "description" in value
|
|
13
14
|
&& typeof value.description === "string"
|
|
14
|
-
&&
|
|
15
|
-
&& typeof value
|
|
15
|
+
&& ruleConfiguration in value
|
|
16
|
+
&& typeof value[ruleConfiguration] === "function"
|
|
16
17
|
);
|
|
17
18
|
}
|
|
18
19
|
|
package/src/config/resolve.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
+
import { configureRegistered } from "#adapters/rule.ts";
|
|
2
3
|
import type { Decoded } from "#decoded.ts";
|
|
3
4
|
import type { ActiveRule } from "#engine/runRules.ts";
|
|
4
5
|
import type { RuleIndex } from "#engine/violation.ts";
|
|
5
|
-
import type {
|
|
6
|
+
import type { RegisteredRule } from "#rule.ts";
|
|
6
7
|
import { builtInRules } from "#rules/builtIn.ts";
|
|
7
8
|
import type { ConfigInput } from "./decode.ts";
|
|
8
9
|
|
|
@@ -20,13 +21,13 @@ function optionsOf(setting: Setting | undefined): unknown {
|
|
|
20
21
|
return typeof setting === "object" ? setting.options : undefined;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
function duplicateIssues(rules: readonly
|
|
24
|
+
function duplicateIssues(rules: readonly RegisteredRule[]): readonly string[] {
|
|
24
25
|
return rules.flatMap((rule, index) =>
|
|
25
26
|
rules.findIndex((other) => other.id === rule.id) === index ? [] : [`local: rule id "${rule.id}" is already defined`],
|
|
26
27
|
);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
function activeRule(rule:
|
|
30
|
+
function activeRule(rule: RegisteredRule, check: ActiveRule["check"]): ActiveRule {
|
|
30
31
|
return {
|
|
31
32
|
check,
|
|
32
33
|
description: rule.description,
|
|
@@ -37,8 +38,8 @@ function activeRule(rule: Rule, check: ActiveRule["check"]): ActiveRule {
|
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
function activate(rule:
|
|
41
|
-
return Effect.tryPromise({ catch: messageOf, try: () => rule
|
|
41
|
+
function activate(rule: RegisteredRule, setting: Setting | undefined): Effect.Effect<Decoded<ActiveRule>> {
|
|
42
|
+
return Effect.tryPromise({ catch: messageOf, try: () => configureRegistered(rule, optionsOf(setting)) }).pipe(
|
|
42
43
|
Effect.match({
|
|
43
44
|
onFailure: (failure): Decoded<ActiveRule> => ({ _tag: "Invalid", issues: [`rules.${rule.id}.options: validation threw: ${failure}`] }),
|
|
44
45
|
onSuccess: (configured): Decoded<ActiveRule> =>
|
|
@@ -53,7 +54,7 @@ function activate(rule: Rule, setting: Setting | undefined): Effect.Effect<Decod
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
export const resolveRules = Effect.fn("Config.resolveRules")(function* (config: ConfigInput): Effect.fn.Return<Decoded<ResolvedRules>> {
|
|
56
|
-
const rules: readonly
|
|
57
|
+
const rules: readonly RegisteredRule[] = [...builtInRules, ...(config.local ?? [])];
|
|
57
58
|
const settings = config.rules ?? {};
|
|
58
59
|
const known = new Set(rules.map((rule) => rule.id));
|
|
59
60
|
const families = new Set(rules.filter((rule) => rule.family === true).map((rule) => rule.id));
|
package/src/config.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { ExceptionDeclaration } from "#exceptions/declaration.ts";
|
|
2
|
+
import type { RegisteredRule, Rule } from "#rule.ts";
|
|
2
3
|
import type { builtInRules } from "#rules/builtIn.ts";
|
|
3
|
-
import type { Rule } from "./rule.ts";
|
|
4
4
|
|
|
5
5
|
export type Level = "error";
|
|
6
6
|
|
|
7
7
|
export type RuleSetting<TInput> = "error" | { readonly level?: "error"; readonly options?: TInput };
|
|
8
8
|
|
|
9
|
-
type InputOf<TCandidate> = TCandidate extends Rule<string, infer TInput> ? TInput :
|
|
9
|
+
type InputOf<TCandidate> = TCandidate extends Rule<string, infer TInput, unknown> ? TInput : unknown;
|
|
10
10
|
|
|
11
|
-
export type RuleSettings<TRules extends readonly
|
|
11
|
+
export type RuleSettings<TRules extends readonly RegisteredRule<unknown>[]> = {
|
|
12
12
|
readonly [TCandidate in TRules[number] as TCandidate["id"]]?: RuleSetting<InputOf<TCandidate>>;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export type BuiltInRules = typeof builtInRules;
|
|
16
16
|
|
|
17
|
-
export interface QualityConfig<TLocal extends readonly
|
|
17
|
+
export interface QualityConfig<TLocal extends readonly RegisteredRule<unknown>[] = readonly RegisteredRule<unknown>[]> {
|
|
18
18
|
readonly baseline?: string;
|
|
19
19
|
readonly exceptions?: readonly ExceptionDeclaration[];
|
|
20
20
|
readonly extensions?: readonly string[];
|
|
@@ -24,6 +24,8 @@ export interface QualityConfig<TLocal extends readonly Rule[] = readonly Rule[]>
|
|
|
24
24
|
readonly sources?: readonly string[];
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export function defineConfig<const TLocal extends readonly
|
|
27
|
+
export function defineConfig<const TLocal extends readonly RegisteredRule<unknown>[] = readonly []>(
|
|
28
|
+
config: QualityConfig<TLocal>,
|
|
29
|
+
): QualityConfig<TLocal> {
|
|
28
30
|
return config;
|
|
29
31
|
}
|
package/src/decoded.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect, Result, Schema, SchemaIssue } from "effect";
|
|
2
|
+
import { describeIssue } from "#adapters/standardSchema.ts";
|
|
2
3
|
import { SetupFailure } from "./failure.ts";
|
|
3
|
-
import { describeIssue } from "./standardSchema.ts";
|
|
4
4
|
|
|
5
5
|
export type Decoded<TValue> = { readonly _tag: "Valid"; readonly value: TValue } | { readonly _tag: "Invalid"; readonly issues: readonly string[] };
|
|
6
6
|
|
package/src/engine/runRules.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { isAbsolute, relative } from "node:path";
|
|
1
|
+
import { basename, isAbsolute, relative } from "node:path";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
import { ManifestFailure } from "#adapters/manifestInventory.ts";
|
|
4
4
|
import { SetupFailure } from "#failure.ts";
|
|
5
|
+
import { FilesystemFailure } from "#inventory/filesystem.ts";
|
|
5
6
|
import { posix } from "#inventory/ignoreScope.ts";
|
|
6
7
|
import type { Finding, RuleCheck, RuleInputs, RuleServices } from "#rule.ts";
|
|
7
8
|
import type { ActiveLevel, Violation } from "./violation.ts";
|
|
@@ -49,19 +50,38 @@ function violationOf(rule: ActiveRule, root: string, finding: Finding, exception
|
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
function expectedFailure(rule: ActiveRule, root: string, cause: unknown): readonly Violation[] | undefined {
|
|
54
|
+
if (cause instanceof ManifestFailure || cause instanceof FilesystemFailure) {
|
|
55
|
+
const manifest = cause instanceof ManifestFailure || basename(cause.path) === "package.json";
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
file: repositoryPath(root, cause.path),
|
|
59
|
+
level: rule.level,
|
|
60
|
+
message: cause.message,
|
|
61
|
+
rule: manifest ? "manifests/valid" : rule.id,
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
52
68
|
function runRule(rule: ActiveRule, inputs: RuleInputs, exceptionFile: string): Effect.Effect<readonly Violation[], SetupFailure, RuleServices> {
|
|
53
69
|
return Effect.suspend(() => rule.check(inputs)).pipe(
|
|
54
|
-
Effect.catch((cause) =>
|
|
55
|
-
cause instanceof SetupFailure
|
|
56
|
-
? Effect.fail(new SetupFailure({ cause, message: `rule ${rule.id} failed: ${cause.message}` }))
|
|
57
|
-
: Effect.die(cause),
|
|
58
|
-
),
|
|
59
70
|
Effect.map((findings) => findings.map((finding) => violationOf(rule, inputs.root, finding, exceptionFile))),
|
|
60
|
-
Effect.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
Effect.catch((cause) => {
|
|
72
|
+
const findings = expectedFailure(rule, inputs.root, cause);
|
|
73
|
+
if (findings !== undefined) {
|
|
74
|
+
return Effect.succeed(findings);
|
|
75
|
+
}
|
|
76
|
+
if (cause instanceof SetupFailure) {
|
|
77
|
+
return Effect.fail(new SetupFailure({ cause, message: `rule ${rule.id} failed: ${cause.message}` }));
|
|
78
|
+
}
|
|
79
|
+
return Effect.die(cause);
|
|
80
|
+
}),
|
|
81
|
+
Effect.catchDefect((cause) => {
|
|
82
|
+
const findings = expectedFailure(rule, inputs.root, cause);
|
|
83
|
+
return findings === undefined ? Effect.die(new Error(`rule ${rule.id} failed: ${messageOf(cause)}`, { cause })) : Effect.succeed(findings);
|
|
84
|
+
}),
|
|
65
85
|
);
|
|
66
86
|
}
|
|
67
87
|
|
package/src/engine/session.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { relative } from "node:path";
|
|
2
|
-
import { Effect } from "effect";
|
|
2
|
+
import { Effect, type Scope } from "effect";
|
|
3
3
|
import { setManifestFiles } from "#adapters/manifestInventory.ts";
|
|
4
4
|
import { manifestReader } from "#adapters/manifestReader.ts";
|
|
5
5
|
import { loadConfig, type ResolvedConfig } from "#config/load.ts";
|
|
6
|
-
import
|
|
6
|
+
import { staleBiomeExceptions } from "#exceptions/biomeFindings.ts";
|
|
7
|
+
import type { RegistryEntry, StaleRegistryEntry } from "#exceptions/registry.ts";
|
|
7
8
|
import { registryEntries } from "#exceptions/registryEntries.ts";
|
|
8
9
|
import { SetupFailure } from "#failure.ts";
|
|
9
10
|
import { collectInventory, type Inventory } from "#inventory/collect.ts";
|
|
10
|
-
import type { FilesystemFailure } from "#inventory/filesystem.ts";
|
|
11
11
|
import type { RuleServices } from "#rule.ts";
|
|
12
12
|
import { type BaselineFile, readBaseline, readInput } from "./baselineFile.ts";
|
|
13
13
|
import { runRules } from "./runRules.ts";
|
|
@@ -18,12 +18,11 @@ export interface Session {
|
|
|
18
18
|
readonly config: ResolvedConfig;
|
|
19
19
|
readonly inventory: Inventory;
|
|
20
20
|
readonly registry: readonly RegistryEntry[];
|
|
21
|
+
readonly staleRegistry: readonly StaleRegistryEntry[];
|
|
21
22
|
readonly violations: readonly Violation[];
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
function setup<TValue, TRequirements>(
|
|
25
|
-
effect: Effect.Effect<TValue, FilesystemFailure | SetupFailure, TRequirements>,
|
|
26
|
-
): Effect.Effect<TValue, SetupFailure, TRequirements> {
|
|
25
|
+
function setup<TValue, TRequirements>(effect: Effect.Effect<TValue, Error, TRequirements>): Effect.Effect<TValue, SetupFailure, TRequirements> {
|
|
27
26
|
return Effect.mapError(effect, (failure) =>
|
|
28
27
|
failure instanceof SetupFailure ? failure : new SetupFailure({ cause: failure, message: failure.message }),
|
|
29
28
|
);
|
|
@@ -31,20 +30,22 @@ function setup<TValue, TRequirements>(
|
|
|
31
30
|
|
|
32
31
|
export const scan = Effect.fn("Engine.scan")(function* (
|
|
33
32
|
config: ResolvedConfig,
|
|
34
|
-
): Effect.fn.Return<Pick<Session, "inventory" | "violations">, SetupFailure, RuleServices> {
|
|
33
|
+
): Effect.fn.Return<Pick<Session, "inventory" | "staleRegistry" | "violations">, SetupFailure, RuleServices | Scope.Scope> {
|
|
35
34
|
const inventory = yield* setup(collectInventory(config.root, config));
|
|
36
35
|
const readText = yield* manifestReader(config.root);
|
|
37
36
|
setManifestFiles(readText, inventory.manifestFiles);
|
|
38
|
-
const
|
|
37
|
+
const inputs = {
|
|
39
38
|
configFile: relative(config.root, config.file),
|
|
40
39
|
exceptions: config.exceptions,
|
|
41
40
|
files: inventory.files,
|
|
42
41
|
readText,
|
|
43
42
|
root: config.root,
|
|
44
43
|
sources: inventory.sources,
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
};
|
|
45
|
+
const violations = yield* runRules(config.active, inputs);
|
|
46
|
+
const staleRegistry = yield* setup(staleBiomeExceptions(inputs));
|
|
47
|
+
return { inventory, staleRegistry, violations };
|
|
48
|
+
}, Effect.scoped);
|
|
48
49
|
|
|
49
50
|
export const openSession = Effect.fn("Engine.openSession")(function* (
|
|
50
51
|
cwd: string,
|
|
@@ -60,6 +61,6 @@ export const openSession = Effect.fn("Engine.openSession")(function* (
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
const baseline = yield* readBaseline(config);
|
|
63
|
-
const
|
|
64
|
-
return { baseline, config,
|
|
64
|
+
const scanned = yield* scan(config);
|
|
65
|
+
return { ...scanned, baseline, config, registry: registryEntries(config.exceptions) };
|
|
65
66
|
});
|
|
@@ -1,5 +1,34 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { biomeReport } from "#biome/report.ts";
|
|
3
|
+
import { withoutEntryPointImports } from "#biome/withoutEntryPointImports.ts";
|
|
4
|
+
import type { StaleRegistryEntry } from "#exceptions/registry.ts";
|
|
1
5
|
import type { Finding, RuleInputs } from "#rule.ts";
|
|
2
6
|
|
|
7
|
+
export const staleBiomeExceptions = Effect.fn("Exceptions.staleBiomeExceptions")(function* (inputs: RuleInputs) {
|
|
8
|
+
const declarations = inputs.exceptions ?? [];
|
|
9
|
+
const declared = declarations.flatMap(({ files, reason, rules }) =>
|
|
10
|
+
rules.filter((rule) => /^biome\/(?:lint|assist)\//u.test(rule)).flatMap((rule) => files.map((file) => ({ file, reason, rule }))),
|
|
11
|
+
);
|
|
12
|
+
const texts = yield* Effect.forEach(declared, ({ file }) => Effect.promise(() => inputs.readText(file)), { concurrency: "unbounded" });
|
|
13
|
+
const entries = declared.filter((_, index) => texts[index] !== undefined);
|
|
14
|
+
if (entries.length === 0) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
const exclusions = declarations.flatMap((entry) =>
|
|
18
|
+
entry.rules.includes("biome/files/includes") ? [{ ...entry, rules: ["biome/files/includes"] as const }] : [],
|
|
19
|
+
);
|
|
20
|
+
const report = yield* biomeReport(inputs.root, ["check", "--no-errors-on-unmatched"], exclusions, [...new Set(entries.map(({ file }) => file))]);
|
|
21
|
+
const diagnostics = yield* Effect.promise(() => withoutEntryPointImports(inputs.readText, report.diagnostics));
|
|
22
|
+
return entries
|
|
23
|
+
.filter(({ file, rule }) => !diagnostics.some((diagnostic) => diagnostic.location.path === file && `biome/${diagnostic.category}` === rule))
|
|
24
|
+
.map(
|
|
25
|
+
(entry): StaleRegistryEntry => ({
|
|
26
|
+
entry,
|
|
27
|
+
problem: `matches no finding. Remove this file/rule pair from exceptions in ${inputs.configFile ?? "quality.config.ts"}`,
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
3
32
|
export async function missingBiomeFiles(inputs: RuleInputs): Promise<readonly Finding[]> {
|
|
4
33
|
const paths = (inputs.exceptions ?? [])
|
|
5
34
|
.filter((entry) => entry.rules.some((rule) => rule.startsWith("biome/") && rule !== "biome/files/includes"))
|
package/src/hooks/preCommit.ts
CHANGED
|
@@ -25,7 +25,7 @@ const commitScripts = Effect.fnUntraced(function* (root: string) {
|
|
|
25
25
|
return yield* new SetupFailure({ message: `${file}: unsupported packageManager "${manager}". Use npm, pnpm, yarn or bun.` });
|
|
26
26
|
}
|
|
27
27
|
return { manager, scripts: ["typecheck", "quality:commit"].filter((script) => manifest.scripts?.[script] !== undefined) };
|
|
28
|
-
});
|
|
28
|
+
}, Effect.scoped);
|
|
29
29
|
|
|
30
30
|
const runScript = Effect.fnUntraced(
|
|
31
31
|
function* (root: string, manager: string, script: string) {
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
1
2
|
import ts from "typescript";
|
|
3
|
+
import { ImportCompiler } from "#adapters/ImportCompiler.ts";
|
|
2
4
|
import type { Finding, SourceFile } from "#rule.ts";
|
|
3
5
|
import { parse } from "#rules/parse.ts";
|
|
4
6
|
import { browserNames } from "./browserNames.ts";
|
|
5
7
|
|
|
6
|
-
function checkerOf(source: ts.SourceFile): ts.TypeChecker {
|
|
7
|
-
const options: ts.CompilerOptions = { allowJs: true, noLib: true, noResolve: true };
|
|
8
|
-
const host = ts.createCompilerHost(options);
|
|
9
|
-
host.getSourceFile = (path) => (path === source.fileName ? source : undefined);
|
|
10
|
-
return ts.createProgram([source.fileName], options, host).getTypeChecker();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
8
|
function unbound(checker: ts.TypeChecker, node: ts.Identifier): boolean {
|
|
14
9
|
return (checker.getSymbolAtLocation(node)?.declarations ?? []).length === 0;
|
|
15
10
|
}
|
|
@@ -107,13 +102,14 @@ function superclassesOf(node: ts.HeritageClause): readonly ts.Expression[] {
|
|
|
107
102
|
return node.types.map((base) => base.expression);
|
|
108
103
|
}
|
|
109
104
|
|
|
110
|
-
export
|
|
105
|
+
export const browserGlobals = Effect.fn("Imports.browserGlobals")(function* (file: SourceFile) {
|
|
111
106
|
const parsed = parse(file);
|
|
112
107
|
if (parsed === undefined) {
|
|
113
108
|
return [];
|
|
114
109
|
}
|
|
115
110
|
const source = parsed;
|
|
116
|
-
const
|
|
111
|
+
const compiler = yield* ImportCompiler;
|
|
112
|
+
const checker = yield* compiler.browserChecker(source);
|
|
117
113
|
const findings: Finding[] = [];
|
|
118
114
|
function visit(node: ts.Node): void {
|
|
119
115
|
if (ts.isHeritageClause(node)) {
|
|
@@ -139,4 +135,4 @@ export function browserGlobals(file: SourceFile): readonly Finding[] {
|
|
|
139
135
|
}
|
|
140
136
|
visit(source);
|
|
141
137
|
return findings;
|
|
142
|
-
}
|
|
138
|
+
}, Effect.provide(ImportCompiler.layer));
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { moduleRoot } from "#naming/moduleRoot.ts";
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { ImportCompiler } from "#adapters/ImportCompiler.ts";
|
|
4
3
|
import type { RuleInputs } from "#rule.ts";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import { type Project, projectsFor } from "./projects.ts";
|
|
8
|
-
import { resolveImport } from "./resolve.ts";
|
|
9
|
-
import { type SpecifierSite, specifierSites } from "./specifiers.ts";
|
|
10
|
-
import { packageOf, type WorkspacePackage, workspacePackages } from "./workspace.ts";
|
|
4
|
+
import type { SpecifierSite } from "./specifiers.ts";
|
|
5
|
+
import { workspacePackages } from "./workspace.ts";
|
|
11
6
|
|
|
12
7
|
export interface Departure extends SpecifierSite {
|
|
13
8
|
readonly file: string;
|
|
@@ -15,74 +10,8 @@ export interface Departure extends SpecifierSite {
|
|
|
15
10
|
readonly workspace: string | undefined;
|
|
16
11
|
}
|
|
17
12
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const TRAILING_SLASHES = /\/+$/u;
|
|
25
|
-
|
|
26
|
-
function noAmbient(): boolean {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function leavesLexically(path: string): boolean {
|
|
31
|
-
const normal = posix.normalize(path).replace(TRAILING_SLASHES, "");
|
|
32
|
-
return normal === ".." || normal.startsWith("../") || normal.includes("/");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface FileContext {
|
|
36
|
-
readonly from: string;
|
|
37
|
-
readonly packages: readonly WorkspacePackage[];
|
|
38
|
-
readonly path: string;
|
|
39
|
-
readonly project: Project;
|
|
40
|
-
readonly root: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function registersAdmin(from: string, specifier: string, target: string | undefined): boolean {
|
|
44
|
-
const root = moduleRoot(from);
|
|
45
|
-
const folder = posix.dirname(from);
|
|
46
|
-
return (
|
|
47
|
-
root !== undefined
|
|
48
|
-
&& (folder === `${root}/client` || folder === `${root}/server`)
|
|
49
|
-
&& /^registration\.[cm]?[jt]sx?$/u.test(posix.basename(from))
|
|
50
|
-
&& specifier.startsWith("./admin/")
|
|
51
|
-
&& target?.startsWith(`${folder}/admin/`) === true
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// A relative import leaves its folder when its path climbs or descends, or when it names a folder whose index file lies below.
|
|
56
|
-
function departureAt(context: FileContext, site: SpecifierSite): Departure | undefined {
|
|
57
|
-
const path = site.specifier.replace(QUERY, "");
|
|
58
|
-
if (!RELATIVE.test(path)) {
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
const request: ImportRequest = { kind: "import", line: site.line, specifier: site.specifier, type: site.type };
|
|
62
|
-
const target = resolveImport(context.root, noAmbient, request, context.from, context.project);
|
|
63
|
-
const local = target?.kind === "file" ? target.path : undefined;
|
|
64
|
-
if (registersAdmin(context.path, path, local)) {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
if (!(leavesLexically(path) || (local !== undefined && posix.dirname(local) !== posix.dirname(context.path)))) {
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
const owner = local === undefined ? undefined : packageOf(context.packages, local);
|
|
71
|
-
const workspace = owner !== undefined && owner !== packageOf(context.packages, context.path) ? owner.name : undefined;
|
|
72
|
-
return { ...site, file: context.path, installed: target?.kind === "external" ? target.package : undefined, workspace };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export async function departures(inputs: RuleInputs): Promise<readonly Departure[]> {
|
|
76
|
-
const root = realpathSync(inputs.root);
|
|
77
|
-
const projectOf = projectsFor(root);
|
|
78
|
-
const packages = await workspacePackages(inputs);
|
|
79
|
-
return inputs.sources.flatMap((file) => {
|
|
80
|
-
const syntax = MAY_BE_RELATIVE.test(file.text) ? parse(file) : undefined;
|
|
81
|
-
if (syntax === undefined) {
|
|
82
|
-
return [];
|
|
83
|
-
}
|
|
84
|
-
const from = posix.join(root, file.path);
|
|
85
|
-
const context = { from, packages, path: file.path, project: projectOf(from), root };
|
|
86
|
-
return specifierSites(syntax).flatMap((site) => departureAt(context, site) ?? []);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
13
|
+
export const departures = Effect.fn("Imports.departures")(function* (inputs: RuleInputs) {
|
|
14
|
+
const packages = yield* Effect.promise(() => workspacePackages(inputs));
|
|
15
|
+
const compiler = yield* ImportCompiler;
|
|
16
|
+
return yield* compiler.departures(inputs, packages);
|
|
17
|
+
}, Effect.provide(ImportCompiler.layer));
|
package/src/imports/extract.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type ImportKind = "import" | "path-reference" | "resolve" | "type-referen
|
|
|
5
5
|
export interface ImportRequest {
|
|
6
6
|
readonly kind: ImportKind;
|
|
7
7
|
readonly line: number;
|
|
8
|
+
readonly mode?: ts.ResolutionMode;
|
|
8
9
|
readonly specifier: string;
|
|
9
10
|
readonly type: boolean;
|
|
10
11
|
}
|
|
@@ -80,27 +81,28 @@ function nested(node: ts.Node): Found | undefined {
|
|
|
80
81
|
return undefined;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
function requestOf(source: ts.SourceFile, at: ts.Node, found: Found | undefined): readonly ImportRequest[] {
|
|
84
|
+
function requestOf(source: ts.SourceFile, at: ts.Node, found: Found | undefined, options?: ts.CompilerOptions): readonly ImportRequest[] {
|
|
84
85
|
if (found?.node === undefined || !ts.isStringLiteralLike(found.node)) {
|
|
85
86
|
return [];
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
+
const mode = options === undefined ? {} : { mode: ts.getModeForUsageLocation(source, found.node, options) };
|
|
89
|
+
return [{ ...mode, kind: found.kind, line: lineAt(source, at.getStart(source)), specifier: found.node.text, type: found.type }];
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
function nestedRequests(source: ts.SourceFile): readonly ImportRequest[] {
|
|
92
|
+
function nestedRequests(source: ts.SourceFile, options?: ts.CompilerOptions): readonly ImportRequest[] {
|
|
91
93
|
if (!MAY_CALL.test(source.text)) {
|
|
92
94
|
return [];
|
|
93
95
|
}
|
|
94
96
|
const requests: ImportRequest[] = [];
|
|
95
97
|
function visit(node: ts.Node): void {
|
|
96
|
-
requests.push(...requestOf(source, node, nested(node)));
|
|
98
|
+
requests.push(...requestOf(source, node, nested(node), options));
|
|
97
99
|
ts.forEachChild(node, visit);
|
|
98
100
|
}
|
|
99
101
|
visit(source);
|
|
100
102
|
return requests;
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
function jsDocRequests(source: ts.SourceFile): readonly ImportRequest[] {
|
|
105
|
+
function jsDocRequests(source: ts.SourceFile, options?: ts.CompilerOptions): readonly ImportRequest[] {
|
|
104
106
|
if (!source.text.includes(JSDOC_IMPORT)) {
|
|
105
107
|
return [];
|
|
106
108
|
}
|
|
@@ -108,7 +110,7 @@ function jsDocRequests(source: ts.SourceFile): readonly ImportRequest[] {
|
|
|
108
110
|
.flatMap((node) => ts.getJSDocCommentsAndTags(node))
|
|
109
111
|
.flatMap((doc) => (ts.isJSDoc(doc) ? (doc.tags ?? []) : [doc]))
|
|
110
112
|
.filter(ts.isJSDocImportTag);
|
|
111
|
-
return tags.flatMap((tag) => requestOf(source, tag, { kind: "import", node: tag.moduleSpecifier, type: true }));
|
|
113
|
+
return tags.flatMap((tag) => requestOf(source, tag, { kind: "import", node: tag.moduleSpecifier, type: true }, options));
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
function referenceRequests(source: ts.SourceFile): readonly ImportRequest[] {
|
|
@@ -118,12 +120,12 @@ function referenceRequests(source: ts.SourceFile): readonly ImportRequest[] {
|
|
|
118
120
|
return [...source.typeReferenceDirectives.map(requestFor("type-reference")), ...source.referencedFiles.map(requestFor("path-reference"))];
|
|
119
121
|
}
|
|
120
122
|
|
|
121
|
-
export function importsOf(source: ts.SourceFile, declarationFile: boolean): readonly ImportRequest[] {
|
|
123
|
+
export function importsOf(source: ts.SourceFile, declarationFile: boolean, options?: ts.CompilerOptions): readonly ImportRequest[] {
|
|
122
124
|
const all = [
|
|
123
125
|
...referenceRequests(source),
|
|
124
|
-
...source.statements.flatMap((statement) => requestOf(source, statement, declared(statement))),
|
|
125
|
-
...jsDocRequests(source),
|
|
126
|
-
...nestedRequests(source),
|
|
126
|
+
...source.statements.flatMap((statement) => requestOf(source, statement, declared(statement), options)),
|
|
127
|
+
...jsDocRequests(source, options),
|
|
128
|
+
...nestedRequests(source, options),
|
|
127
129
|
];
|
|
128
130
|
return declarationFile ? all.map((request) => ({ ...request, type: true })) : all;
|
|
129
131
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
1
2
|
import { importGraph } from "#imports/graph.ts";
|
|
2
|
-
import type {
|
|
3
|
+
import type { RuleInputs } from "#rule.ts";
|
|
3
4
|
import { compilePolicy } from "./compilePolicy.ts";
|
|
4
5
|
import { discoverFences } from "./discover.ts";
|
|
5
6
|
import type { Fence } from "./model.ts";
|
|
6
7
|
|
|
7
|
-
export
|
|
8
|
-
const graph =
|
|
9
|
-
const fences = [...configured, ...(
|
|
8
|
+
export const checkFences = Effect.fn("Imports.checkFences")(function* (inputs: RuleInputs, configured: readonly Fence[]) {
|
|
9
|
+
const graph = yield* importGraph(inputs);
|
|
10
|
+
const fences = [...configured, ...(yield* Effect.promise(() => discoverFences(inputs, graph.packages)))];
|
|
10
11
|
const policy = compilePolicy(fences, { files: inputs.files, packages: graph.packages });
|
|
11
12
|
return policy.flatMap((compiled) => compiled.evaluate(graph));
|
|
12
|
-
}
|
|
13
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { Endpoint } from "#imports/Endpoint.ts";
|
|
1
2
|
import type { ImportEdge } from "#imports/graph.ts";
|
|
2
3
|
import { packageNameOf } from "#imports/packageName.ts";
|
|
3
|
-
import type { Endpoint } from "#imports/resolve.ts";
|
|
4
4
|
import { type CompiledFence, compileFence, type FenceGraph } from "./evaluate.ts";
|
|
5
5
|
import type { PolicyScope } from "./match.ts";
|
|
6
6
|
import type { Chain, ExampleStep, Fence } from "./model.ts";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { Endpoint } from "#imports/Endpoint.ts";
|
|
1
2
|
import { builtinName, packageNameOf } from "#imports/packageName.ts";
|
|
2
|
-
import type { Endpoint } from "#imports/resolve.ts";
|
|
3
3
|
import { packageOf, type WorkspacePackage } from "#imports/workspace.ts";
|
|
4
4
|
import type { Selector } from "./model.ts";
|
|
5
5
|
|