@goodbones/oxlint 0.1.0-beta.1 → 0.1.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dts/campaigns-rule.d.ts +6 -0
- package/build/dts/campaigns-rule.d.ts.map +1 -0
- package/build/dts/config-loader.d.ts +2 -1
- package/build/dts/config-loader.d.ts.map +1 -1
- package/build/dts/exports-rule.d.ts.map +1 -1
- package/build/dts/imports-rule.d.ts.map +1 -1
- package/build/dts/members-rule.d.ts.map +1 -1
- package/build/dts/oxlint-api.d.ts +4 -33
- package/build/dts/oxlint-api.d.ts.map +1 -1
- package/build/dts/plugin.d.ts +1 -0
- package/build/dts/plugin.d.ts.map +1 -1
- package/build/dts/surface-rule.d.ts.map +1 -1
- package/build/esm/campaigns-rule.js +164 -0
- package/build/esm/campaigns-rule.js.map +1 -0
- package/build/esm/config-loader.js +85 -7
- package/build/esm/config-loader.js.map +1 -1
- package/build/esm/exports-rule.js +15 -71
- package/build/esm/exports-rule.js.map +1 -1
- package/build/esm/imports-rule.js +14 -26
- package/build/esm/imports-rule.js.map +1 -1
- package/build/esm/members-rule.js +10 -112
- package/build/esm/members-rule.js.map +1 -1
- package/build/esm/oxlint-api.js +22 -20
- package/build/esm/oxlint-api.js.map +1 -1
- package/build/esm/plugin.js +6 -2
- package/build/esm/plugin.js.map +1 -1
- package/build/esm/surface-rule.js +11 -127
- package/build/esm/surface-rule.js.map +1 -1
- package/package.json +5 -3
- package/src/campaigns-rule.ts +242 -0
- package/src/config-loader.ts +105 -7
- package/src/exports-rule.ts +19 -106
- package/src/imports-rule.ts +16 -35
- package/src/members-rule.ts +11 -165
- package/src/oxlint-api.ts +31 -47
- package/src/plugin.ts +7 -2
- package/src/surface-rule.ts +15 -189
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type SectorIndex } from "@goodbones/campaigns";
|
|
2
|
+
import { type LoadedPolicy } from "@goodbones/core";
|
|
3
|
+
import { type OxlintRule } from "./oxlint-api.js";
|
|
4
|
+
export type SectorIndexes = ReadonlyMap<string, SectorIndex>;
|
|
5
|
+
export declare const makeCampaignsRule: (policy: LoadedPolicy, indexes?: SectorIndexes) => OxlintRule;
|
|
6
|
+
//# sourceMappingURL=campaigns-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"campaigns-rule.d.ts","sourceRoot":"","sources":["../../src/campaigns-rule.ts"],"names":[],"mappings":"AAEA,OAAO,EAoBL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAiB,KAAK,YAAY,EAAqB,MAAM,iBAAiB,CAAC;AAGtF,OAAO,EAEL,KAAK,UAAU,EAIhB,MAAM,iBAAiB,CAAC;AAsBzB,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AA0D7D,eAAO,MAAM,iBAAiB,WACpB,YAAY,YACX,aAAa,KACrB,UA6HF,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type SectorIndex } from "@goodbones/campaigns";
|
|
1
2
|
import { type LoadedPolicy } from "@goodbones/core";
|
|
2
3
|
export type { LoadedPolicy } from "@goodbones/core";
|
|
3
|
-
export
|
|
4
|
+
export declare const discoverSectorIndexes: (policy: LoadedPolicy) => ReadonlyMap<string, SectorIndex>;
|
|
4
5
|
export declare const loadPolicyFromFile: (repoRoot: string, configFilename?: string) => Promise<LoadedPolicy>;
|
|
5
6
|
//# sourceMappingURL=config-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/config-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/config-loader.ts"],"names":[],"mappings":"AAGA,OAAO,EAOL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAKL,KAAK,YAAY,EAKlB,MAAM,iBAAiB,CAAC;AAIzB,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAOpD,eAAO,MAAM,qBAAqB,WAAY,YAAY,KAAG,WAAW,CAAC,MAAM,EAAE,WAAW,CA6B3F,CAAC;AAmBF,eAAO,MAAM,kBAAkB,aACnB,MAAM,mBACC,MAAM,KACtB,OAAO,CAAC,YAAY,CAgDtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports-rule.d.ts","sourceRoot":"","sources":["../../src/exports-rule.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"exports-rule.d.ts","sourceRoot":"","sources":["../../src/exports-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAIL,KAAK,UAAU,EAIhB,MAAM,iBAAiB,CAAC;AAYzB,eAAO,MAAM,eAAe,WAAY,YAAY,KAAG,UA6ErD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imports-rule.d.ts","sourceRoot":"","sources":["../../src/imports-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAGlB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"imports-rule.d.ts","sourceRoot":"","sources":["../../src/imports-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAGlB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAGL,KAAK,UAAU,EAIhB,MAAM,iBAAiB,CAAC;AAOzB,eAAO,MAAM,eAAe,WAAY,YAAY,KAAG,UAoDrD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"members-rule.d.ts","sourceRoot":"","sources":["../../src/members-rule.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"members-rule.d.ts","sourceRoot":"","sources":["../../src/members-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAGL,KAAK,UAAU,EAIhB,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,eAAe,WAAY,YAAY,KAAG,UAiCrD,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ReadFacts, type SyntaxNode } from "@goodbones/typescript";
|
|
1
2
|
import type { RuleTester } from "oxlint/plugins-dev";
|
|
2
3
|
export type OxlintRule = Parameters<RuleTester["run"]>[1];
|
|
3
4
|
export type RuleContext = Parameters<Extract<OxlintRule, {
|
|
@@ -8,39 +9,9 @@ export type ReportableNode = Extract<Diagnostic, {
|
|
|
8
9
|
node: unknown;
|
|
9
10
|
}>["node"];
|
|
10
11
|
export type Fixer = Parameters<NonNullable<Diagnostic["fix"]>>[0];
|
|
11
|
-
export type
|
|
12
|
-
readonly source?: {
|
|
13
|
-
readonly value?: unknown;
|
|
14
|
-
} | null;
|
|
15
|
-
};
|
|
12
|
+
export type Program = RuleContext["sourceCode"]["ast"];
|
|
16
13
|
export declare const toRepoRelative: (repoRoot: string, filename: string) => string;
|
|
17
|
-
export declare const
|
|
18
|
-
export
|
|
19
|
-
readonly callee?: {
|
|
20
|
-
readonly type: string;
|
|
21
|
-
readonly name?: unknown;
|
|
22
|
-
} | null;
|
|
23
|
-
readonly arguments?: ReadonlyArray<{
|
|
24
|
-
readonly type: string;
|
|
25
|
-
readonly value?: unknown;
|
|
26
|
-
}> | null;
|
|
27
|
-
};
|
|
28
|
-
export type ImportExpressionNode = ReportableNode & {
|
|
29
|
-
readonly source?: {
|
|
30
|
-
readonly type?: string;
|
|
31
|
-
readonly value?: unknown;
|
|
32
|
-
} | null;
|
|
33
|
-
};
|
|
34
|
-
export type ImportEqualsNode = ReportableNode & {
|
|
35
|
-
readonly moduleReference?: {
|
|
36
|
-
readonly type: string;
|
|
37
|
-
readonly expression?: {
|
|
38
|
-
readonly value?: unknown;
|
|
39
|
-
} | null;
|
|
40
|
-
} | null;
|
|
41
|
-
};
|
|
42
|
-
export declare const requireSpecifierOf: (node: CallNode) => string | null;
|
|
43
|
-
export declare const importExpressionSpecifierOf: (node: ImportExpressionNode) => string | null;
|
|
44
|
-
export declare const importEqualsSpecifierOf: (node: ImportEqualsNode) => string | null;
|
|
14
|
+
export declare const at: (node: SyntaxNode) => ReportableNode;
|
|
15
|
+
export declare const factsOfProgram: (file: string, program: Program) => ReadFacts;
|
|
45
16
|
export {};
|
|
46
17
|
//# sourceMappingURL=oxlint-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oxlint-api.d.ts","sourceRoot":"","sources":["../../src/oxlint-api.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKrD,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpG,KAAK,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5E,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"oxlint-api.d.ts","sourceRoot":"","sources":["../../src/oxlint-api.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,SAAS,EAEd,KAAK,UAAU,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKrD,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpG,KAAK,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5E,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAIlE,MAAM,MAAM,OAAO,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC;AAEvD,eAAO,MAAM,cAAc,aAAc,MAAM,YAAY,MAAM,KAAG,MACP,CAAC;AAI9D,eAAO,MAAM,EAAE,SAAU,UAAU,KAAG,cAEpC,CAAC;AAOH,eAAO,MAAM,cAAc,SAAU,MAAM,WAAW,OAAO,KAAG,SAW/D,CAAC"}
|
package/build/dts/plugin.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAoBlD,eAAO,MAAM,KAAK,EAAE;IAClB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;CAUhC,CAAC;AAEF,QAAA,MAAM,MAAM,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,KAAK,CAAA;CAGrF,CAAC;eAEa,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surface-rule.d.ts","sourceRoot":"","sources":["../../src/surface-rule.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"surface-rule.d.ts","sourceRoot":"","sources":["../../src/surface-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAElB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAGL,KAAK,UAAU,EAIhB,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,eAAe,WAAY,YAAY,KAAG,UA4CrD,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { campaignsOf, campaignsSelecting, derivePhase, detectorCandidatesOf, detectorOf, evaluateObjectives, ledgerKeyOf, LEGACY_PHASE, LEGACY_SECTOR, membershipOf, needsSyntax, objectivesInWindow, positionOf, reconcileSector, sectorEntryOf, } from "@goodbones/campaigns";
|
|
3
|
+
import { formatMessage, ReportUnavailable } from "@goodbones/core";
|
|
4
|
+
import { sourceFactsOf } from "@goodbones/typescript";
|
|
5
|
+
import { factsOfProgram, toRepoRelative, } from "./oxlint-api.js";
|
|
6
|
+
const unledgered = (policy, rule, sector, root, hits) => {
|
|
7
|
+
const carried = new Set();
|
|
8
|
+
const byObjective = new Map();
|
|
9
|
+
for (const hit of hits) {
|
|
10
|
+
byObjective.set(hit.objective, [...(byObjective.get(hit.objective) ?? []), hit]);
|
|
11
|
+
}
|
|
12
|
+
for (const [objectiveId, own] of byObjective) {
|
|
13
|
+
const objective = rule.objectives.find((one) => one.id === objectiveId);
|
|
14
|
+
const ledger = campaignsOf(policy).ledgers.get(ledgerKeyOf(rule.id, objectiveId));
|
|
15
|
+
if (objective === undefined || ledger === undefined)
|
|
16
|
+
continue;
|
|
17
|
+
const entries = own.map((hit) => sectorEntryOf(hit.violation, root));
|
|
18
|
+
const known = new Set(reconcileSector(ledger, sector, entries, objective.unit).ledgered);
|
|
19
|
+
own.forEach((hit, i) => {
|
|
20
|
+
if (known.has(entries[i] ?? ""))
|
|
21
|
+
carried.add(hit);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return hits.filter((hit) => !carried.has(hit));
|
|
25
|
+
};
|
|
26
|
+
// The objectives in window for the sector, read off the ledgers. A sector
|
|
27
|
+
// no `clear` has placed — no record of it — stands at the first phase, as
|
|
28
|
+
// the legacy does, rather than deriving to the end from ledgers that
|
|
29
|
+
// carry nothing for it.
|
|
30
|
+
const inWindowFor = (policy, rule, sector) => {
|
|
31
|
+
const record = campaignsOf(policy).sectorRecords.get(ledgerKeyOf(rule.id, sector));
|
|
32
|
+
const position = positionOf(rule, record);
|
|
33
|
+
const counts = (objectiveId) => campaignsOf(policy).ledgers.get(ledgerKeyOf(rule.id, objectiveId))?.sectors[sector]?.holdouts.length ?? 0;
|
|
34
|
+
const phase = sector === LEGACY_SECTOR || record === undefined
|
|
35
|
+
? Math.min(LEGACY_PHASE, rule.phases.length)
|
|
36
|
+
: derivePhase(rule, counts, position);
|
|
37
|
+
return objectivesInWindow(rule, phase, position).filter((one) => one.detect !== null);
|
|
38
|
+
};
|
|
39
|
+
// A `report` a campaign names that cannot be read — a command the kernel
|
|
40
|
+
// refused to spawn, a file no step wrote — is one fact about the run, not
|
|
41
|
+
// one about each file the campaign selects. The live source keeps the
|
|
42
|
+
// failure per spec; this keeps which failures have been said, so the first
|
|
43
|
+
// selected file carries the notice and the rest stay quiet. Without it, a
|
|
44
|
+
// lint of eight hundred files is eight hundred copies of oxlint's generic
|
|
45
|
+
// "error running JS plugin", with the cause dropped by the terser formats.
|
|
46
|
+
const aside = (cause) => `A report a campaign names could not be read, so no campaign naming it is judged in this ` +
|
|
47
|
+
`run: ${cause.message}`;
|
|
48
|
+
export const makeCampaignsRule = (policy, indexes = new Map()) => {
|
|
49
|
+
// Per rule instance, which is per plugin load — one process — rather than
|
|
50
|
+
// per `createOnce`, which a host may call more often than that.
|
|
51
|
+
const said = new Set();
|
|
52
|
+
const known = new Set(policy.languages.flatMap((one) => one.extensions));
|
|
53
|
+
return {
|
|
54
|
+
meta: {
|
|
55
|
+
type: "problem",
|
|
56
|
+
docs: {
|
|
57
|
+
description: "the campaigns: every place a pattern the repository is migrating away from still occurs, in a sector whose phase asks for it, that its ledger does not carry",
|
|
58
|
+
},
|
|
59
|
+
schema: [],
|
|
60
|
+
},
|
|
61
|
+
createOnce(context) {
|
|
62
|
+
let file = "";
|
|
63
|
+
let selected = [];
|
|
64
|
+
return {
|
|
65
|
+
before() {
|
|
66
|
+
file = toRepoRelative(policy.repoRoot, context.filename);
|
|
67
|
+
if (file.startsWith(".."))
|
|
68
|
+
return false;
|
|
69
|
+
// A file the packs would not walk — one oxlint lints anyway — is
|
|
70
|
+
// seen only by a campaign that widened its scope to it, so both
|
|
71
|
+
// hosts answer about the same files.
|
|
72
|
+
const extension = path.extname(file);
|
|
73
|
+
selected = campaignsSelecting(campaignsOf(policy).campaignRules, file).filter((rule) => known.size === 0 || known.has(extension) || rule.extensions.includes(extension));
|
|
74
|
+
return selected.length > 0;
|
|
75
|
+
},
|
|
76
|
+
Program(node) {
|
|
77
|
+
const text = context.sourceCode.text;
|
|
78
|
+
const detectors = selected.flatMap((rule) => [
|
|
79
|
+
...rule.objectives.flatMap((one) => {
|
|
80
|
+
const detect = detectorOf(one);
|
|
81
|
+
return detect === null ? [] : [detect];
|
|
82
|
+
}),
|
|
83
|
+
...(rule.perimeter?.kind === "match" ? [rule.perimeter.detect] : []),
|
|
84
|
+
]);
|
|
85
|
+
const input = {
|
|
86
|
+
file,
|
|
87
|
+
text,
|
|
88
|
+
facts: sourceFactsOf(factsOfProgram(file, node)),
|
|
89
|
+
resolver: policy.resolver,
|
|
90
|
+
fileSystem: policy.fileSystem,
|
|
91
|
+
syntax: needsSyntax(detectors) ? policy.syntax.parse(file, text) : null,
|
|
92
|
+
functions: campaignsOf(policy).functions,
|
|
93
|
+
reports: campaignsOf(policy).reports,
|
|
94
|
+
};
|
|
95
|
+
// One campaign at a time, so a report one of them cannot read costs
|
|
96
|
+
// that campaign's answer for this file and not its neighbours'.
|
|
97
|
+
const unrecorded = [];
|
|
98
|
+
for (const rule of selected) {
|
|
99
|
+
try {
|
|
100
|
+
const perimeter = rule.perimeter;
|
|
101
|
+
const anchors = perimeter?.kind === "match"
|
|
102
|
+
? detectorCandidatesOf(perimeter.detect, perimeter.unit, input).map((one) => one.key.split("#")[0] ?? one.key)
|
|
103
|
+
: [];
|
|
104
|
+
const place = membershipOf(rule, file, indexes.get(rule.id) ?? null, anchors);
|
|
105
|
+
// Hits grouped by the sector they fall in, then judged
|
|
106
|
+
// against that sector's window and ledger.
|
|
107
|
+
const bySector = new Map();
|
|
108
|
+
const windows = new Map();
|
|
109
|
+
const placedAt = (subject) => {
|
|
110
|
+
const placement = place(subject);
|
|
111
|
+
if (placement === null)
|
|
112
|
+
return null;
|
|
113
|
+
if (!windows.has(placement.sector)) {
|
|
114
|
+
windows.set(placement.sector, new Set(inWindowFor(policy, rule, placement.sector).map((one) => one.id)));
|
|
115
|
+
}
|
|
116
|
+
return placement;
|
|
117
|
+
};
|
|
118
|
+
const whole = placedAt(null);
|
|
119
|
+
const candidates = whole === null
|
|
120
|
+
? rule.objectives.filter((one) => one.detect !== null)
|
|
121
|
+
: rule.objectives.filter((one) => one.detect !== null && (windows.get(whole.sector)?.has(one.id) ?? false));
|
|
122
|
+
if (perimeter?.kind !== "match" && whole === null)
|
|
123
|
+
continue;
|
|
124
|
+
for (const hit of evaluateObjectives(candidates, input)) {
|
|
125
|
+
const placement = placedAt(hit.violation.subject);
|
|
126
|
+
if (placement === null)
|
|
127
|
+
continue;
|
|
128
|
+
if (!(windows.get(placement.sector)?.has(hit.objective) ?? false))
|
|
129
|
+
continue;
|
|
130
|
+
const group = bySector.get(placement.sector) ?? { root: placement.root, hits: [] };
|
|
131
|
+
group.hits.push(hit);
|
|
132
|
+
bySector.set(placement.sector, group);
|
|
133
|
+
}
|
|
134
|
+
for (const [sector, group] of bySector) {
|
|
135
|
+
for (const hit of unledgered(policy, rule, sector, group.root, group.hits)) {
|
|
136
|
+
unrecorded.push(hit);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (cause) {
|
|
141
|
+
if (!(cause instanceof ReportUnavailable))
|
|
142
|
+
throw cause;
|
|
143
|
+
const message = aside(cause);
|
|
144
|
+
if (said.has(message))
|
|
145
|
+
continue;
|
|
146
|
+
said.add(message);
|
|
147
|
+
context.report({ message, loc: { line: 1, column: 0 } });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
for (const hit of unrecorded) {
|
|
151
|
+
// A match lands where it was found; a file-unit hit, on line 1, as
|
|
152
|
+
// the structure rule places a finding about the file itself.
|
|
153
|
+
const at = hit.range ?? { start: { line: 0, column: 0 } };
|
|
154
|
+
context.report({
|
|
155
|
+
message: formatMessage(hit.violation),
|
|
156
|
+
loc: { line: at.start.line + 1, column: at.start.column },
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=campaigns-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"campaigns-rule.js","sourceRoot":"","sources":["../../src/campaigns-rule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAGL,WAAW,EACX,kBAAkB,EAGlB,WAAW,EACX,oBAAoB,EACpB,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,aAAa,GAEd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAqB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EACL,cAAc,EAId,cAAc,GACf,MAAM,iBAAiB,CAAC;AAwBzB,MAAM,UAAU,GAAG,CACjB,MAAoB,EACpB,IAAsB,EACtB,MAAc,EACd,IAAY,EACZ,IAAgC,EACJ,EAAE;IAC9B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAe,CAAC;IACvC,MAAM,WAAW,GAAG,IAAI,GAAG,EAA8B,CAAC;IAC1D,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IACnF,CAAC;IACD,KAAK,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,IAAI,WAAW,EAAE,CAAC;QAC7C,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,WAAW,CAAC,CAAC;QACxE,MAAM,MAAM,GAAG,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OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;wBAC3D,CAAC;oBACH,CAAC;oBAED,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;wBAC7B,mEAAmE;wBACnE,6DAA6D;wBAC7D,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;wBAC1D,OAAO,CAAC,MAAM,CAAC;4BACb,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC;4BACrC,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE;yBAC1D,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,24 +1,102 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { astGrepMatcher } from "@goodbones/ast-grep";
|
|
3
|
+
import { campaignsExtension, campaignsOf, discoverSectors, loadCampaignFunctions, makeReportSourceLive, reportSpecsOf, } from "@goodbones/campaigns";
|
|
4
|
+
import { findManifestFile, globToRegExp, listSourceFiles, listWorkspaceProjects, loadPolicy, makeFileSystemLive, readManifestFile, ReportUnavailable, } from "@goodbones/core";
|
|
3
5
|
import { typescriptLanguage } from "@goodbones/typescript";
|
|
4
6
|
import * as Result from "effect/Result";
|
|
5
|
-
|
|
7
|
+
// A `marker` or `nx` perimeter needs the other files to say which sector a
|
|
8
|
+
// file is in — the markers, or the workspace's projects — so the plugin
|
|
9
|
+
// reads them once at load, from a walk of the repository that reads no
|
|
10
|
+
// source text but the markers'. The other perimeters answer from the path
|
|
11
|
+
// or the file itself, and need nothing here.
|
|
12
|
+
export const discoverSectorIndexes = (policy) => {
|
|
13
|
+
const indexes = new Map();
|
|
14
|
+
const needing = campaignsOf(policy).campaignRules.filter((rule) => rule.perimeter?.kind === "marker" || rule.perimeter?.kind === "nx");
|
|
15
|
+
if (needing.length === 0)
|
|
16
|
+
return indexes;
|
|
17
|
+
const widened = [...new Set(needing.flatMap((rule) => rule.extensions))];
|
|
18
|
+
const files = listSourceFiles(policy.repoRoot, ["."], policy.languages, widened);
|
|
19
|
+
const known = new Set(policy.languages.flatMap((one) => one.extensions));
|
|
20
|
+
const projects = needing.some((rule) => rule.perimeter?.kind === "nx")
|
|
21
|
+
? listWorkspaceProjects(policy.repoRoot, ["."])
|
|
22
|
+
: [];
|
|
23
|
+
for (const rule of needing) {
|
|
24
|
+
const scoped = files.filter((file) => rule.scope.some((pattern) => pattern.test(file)) &&
|
|
25
|
+
(known.has(path.extname(file)) || rule.extensions.includes(path.extname(file))));
|
|
26
|
+
indexes.set(rule.id, discoverSectors(rule, {
|
|
27
|
+
files: scoped,
|
|
28
|
+
readText: (file) => policy.fileSystem.readText(file),
|
|
29
|
+
globToRegExp,
|
|
30
|
+
projects,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
return indexes;
|
|
34
|
+
};
|
|
35
|
+
// The clock the campaigns are judged by; `ARCHITECTURE_NOW` pins it, as it
|
|
36
|
+
// does for the CLI.
|
|
37
|
+
const hostNow = () => {
|
|
38
|
+
const pinned = process.env.ARCHITECTURE_NOW;
|
|
39
|
+
if (pinned === undefined || pinned === "")
|
|
40
|
+
return Date.now();
|
|
41
|
+
const parsed = /^\d+$/.test(pinned) ? Number(pinned) : Date.parse(pinned);
|
|
42
|
+
if (Number.isNaN(parsed)) {
|
|
43
|
+
throw new Error(`ARCHITECTURE_NOW is ${JSON.stringify(pinned)}, which is not a date.`);
|
|
44
|
+
}
|
|
45
|
+
return parsed;
|
|
46
|
+
};
|
|
6
47
|
// The plugin's composition root: read the manifest file, construct the
|
|
7
48
|
// language packs and the live file system, and hand them to the loader. A load
|
|
8
49
|
// failure throws out of here and out of oxlint's import of the plugin — a
|
|
9
50
|
// plugin that came up with no policy would report nothing and be
|
|
10
51
|
// indistinguishable from a clean codebase.
|
|
11
|
-
export const loadPolicyFromFile = async (repoRoot, configFilename
|
|
12
|
-
|
|
52
|
+
export const loadPolicyFromFile = async (repoRoot, configFilename) => {
|
|
53
|
+
// Named, or discovered: architecture.yaml, .yml, .json, or .config.mjs,
|
|
54
|
+
// exactly one of which may be present.
|
|
55
|
+
const configPath = configFilename === undefined
|
|
56
|
+
? findManifestFile(repoRoot)
|
|
57
|
+
: path.resolve(repoRoot, configFilename);
|
|
58
|
+
const read = await readManifestFile(configPath);
|
|
59
|
+
// The `fn` terms are imported here, before the policy loads, as the CLI
|
|
60
|
+
// does; the pack is composed with ast-grep for the campaigns family's
|
|
61
|
+
// `syntax` term, and the plugin parses with it for that family only.
|
|
62
|
+
const { functions, manifest } = await loadCampaignFunctions(configPath, read.manifest);
|
|
13
63
|
const loaded = loadPolicy({
|
|
14
64
|
repoRoot,
|
|
15
65
|
configPath,
|
|
16
|
-
manifest
|
|
17
|
-
|
|
66
|
+
manifest,
|
|
67
|
+
locate: read.locate,
|
|
68
|
+
languages: [typescriptLanguage({ syntax: astGrepMatcher() })],
|
|
18
69
|
fileSystem: makeFileSystemLive(repoRoot),
|
|
70
|
+
// A `report` command runs once per process — once per editor session
|
|
71
|
+
// for oxlint's language server, which then sees that report until it
|
|
72
|
+
// restarts. A report the build writes to a file is the predictable form.
|
|
73
|
+
extensions: [campaignsExtension({ functions, reports: makeReportSourceLive(repoRoot) })],
|
|
74
|
+
now: hostNow(),
|
|
19
75
|
});
|
|
20
76
|
if (Result.isFailure(loaded))
|
|
21
77
|
throw loaded.failure;
|
|
22
|
-
|
|
78
|
+
const policy = loaded.success;
|
|
79
|
+
// Every `report` a campaign names is read now, while oxlint has linted
|
|
80
|
+
// nothing. A `command` forks this process, and once the linter is running
|
|
81
|
+
// Linux can refuse the fork: the linter's per-thread AST buffers merge
|
|
82
|
+
// into one mapping larger than RAM and swap together, which the default
|
|
83
|
+
// overcommit heuristic refuses to duplicate. The source keeps the answer,
|
|
84
|
+
// and a failure, so the rules read what was read here — a term's several
|
|
85
|
+
// commands run at once. A report that cannot be read is not a load
|
|
86
|
+
// failure — the campaigns rule reports it once, on the first file a
|
|
87
|
+
// campaign naming it selects; one that does not parse is.
|
|
88
|
+
const campaigns = campaignsOf(policy);
|
|
89
|
+
await Promise.all(reportSpecsOf(campaigns.campaignRules).map(async (spec) => {
|
|
90
|
+
if (campaigns.reports.read !== undefined)
|
|
91
|
+
return campaigns.reports.read(spec);
|
|
92
|
+
try {
|
|
93
|
+
campaigns.reports.diagnosticsOf(spec, "");
|
|
94
|
+
}
|
|
95
|
+
catch (cause) {
|
|
96
|
+
if (!(cause instanceof ReportUnavailable))
|
|
97
|
+
throw cause;
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
return policy;
|
|
23
101
|
};
|
|
24
102
|
//# sourceMappingURL=config-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../../src/config-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../../src/config-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,GAEd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,qBAAqB,EAErB,UAAU,EACV,kBAAkB,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ACnD,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC;IAC9B,uEAAuE;IACvE,0EAA0E;IAC1E,uEAAuE;IACvE,wEAAwE;IACxE,0EAA0E;IAC1E,yEAAyE;IACzE,mEAAmE;IACnE,oEAAoE;IACpE,0DAA0D;IAC1D,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,OAAO,CAAC,GAAG,CACf,aAAa,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACxD,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9E,IAAI,CAAC;YACH,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,CAAC,KAAK,YAAY,iBAAiB,CAAC;gBAAE,MAAM,KAAK,CAAC;QACzD,CAAC;IACH,CAAC,CAAC,CACH,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,49 +1,6 @@
|
|
|
1
1
|
import { evaluateSelectedBindings, exportRulesSelecting, formatMessage, } from "@goodbones/core";
|
|
2
2
|
import * as Result from "effect/Result";
|
|
3
|
-
import {
|
|
4
|
-
const nameOf = (node) => {
|
|
5
|
-
if (node === null || node === undefined)
|
|
6
|
-
return null;
|
|
7
|
-
if (typeof node.name === "string")
|
|
8
|
-
return node.name;
|
|
9
|
-
// `import { "a-b" as ab }` — a string-literal export name.
|
|
10
|
-
return typeof node.value === "string" ? node.value : null;
|
|
11
|
-
};
|
|
12
|
-
// The whole module, as one binding. `export * from "m"`, `export * as ns from
|
|
13
|
-
// "m"`, `import x = require("m")`, `import("m")` and `require("m")` all carry
|
|
14
|
-
// every export of `m` at once, exactly as `import * as ns` does — and are the
|
|
15
|
-
// same way around a rule about a name. A side-effect import carries nothing.
|
|
16
|
-
const wholeModule = (node, local = "") => ({
|
|
17
|
-
symbol: "*",
|
|
18
|
-
kind: "namespace",
|
|
19
|
-
node,
|
|
20
|
-
local,
|
|
21
|
-
});
|
|
22
|
-
const boundOf = (specifier) => {
|
|
23
|
-
const local = nameOf(specifier.local) ?? "";
|
|
24
|
-
switch (specifier.type) {
|
|
25
|
-
case "ImportSpecifier": {
|
|
26
|
-
const symbol = nameOf(specifier.imported);
|
|
27
|
-
return symbol === null ? null : { symbol, kind: "named", node: specifier, local };
|
|
28
|
-
}
|
|
29
|
-
case "ImportDefaultSpecifier":
|
|
30
|
-
return { symbol: "default", kind: "default", node: specifier, local };
|
|
31
|
-
case "ImportNamespaceSpecifier":
|
|
32
|
-
return { symbol: "*", kind: "namespace", node: specifier, local };
|
|
33
|
-
// `export { a } from "…"` — `local` is the name in the source module.
|
|
34
|
-
case "ExportSpecifier": {
|
|
35
|
-
const symbol = nameOf(specifier.local);
|
|
36
|
-
return symbol === null ? null : { symbol, kind: "named", node: specifier, local: symbol };
|
|
37
|
-
}
|
|
38
|
-
default:
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const specifierOf = (node) => {
|
|
43
|
-
const value = node.source?.value;
|
|
44
|
-
return typeof value === "string" ? value : null;
|
|
45
|
-
};
|
|
46
|
-
const boundSpecifiers = (node) => (node.specifiers ?? []).map(boundOf).filter((one) => one !== null);
|
|
3
|
+
import { at, factsOfProgram, toRepoRelative, } from "./oxlint-api.js";
|
|
47
4
|
// `import { A, B as C } from "pkg"` becomes `import * as A from "pkg/A"` and
|
|
48
5
|
// `import * as C from "pkg/B"`. Only whole-declaration rewrites are offered: a
|
|
49
6
|
// declaration mixing restricted named imports with a default or namespace one
|
|
@@ -64,15 +21,16 @@ export const makeExportsRule = (policy) => ({
|
|
|
64
21
|
createOnce(context) {
|
|
65
22
|
let importer = "";
|
|
66
23
|
let selected = [];
|
|
67
|
-
// `
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
const check = (
|
|
71
|
-
|
|
24
|
+
// Only an `import` declaration can be rewritten into subpath namespace
|
|
25
|
+
// imports. `export *` and the whole-module forms are reported and left
|
|
26
|
+
// for the author.
|
|
27
|
+
const check = (edge) => {
|
|
28
|
+
const { bindings: bound, node, specifier } = edge;
|
|
29
|
+
if (bound.length === 0)
|
|
72
30
|
return;
|
|
73
31
|
const outcome = evaluateSelectedBindings(selected, policy.resolver, {
|
|
74
32
|
importer,
|
|
75
|
-
specifier
|
|
33
|
+
specifier,
|
|
76
34
|
bindings: bound,
|
|
77
35
|
});
|
|
78
36
|
if (Result.isFailure(outcome)) {
|
|
@@ -87,20 +45,20 @@ export const makeExportsRule = (policy) => ({
|
|
|
87
45
|
// The rewrite is `import * as X from "pkg/<name>"`, which only means
|
|
88
46
|
// something for a named binding — a namespace one has no name to put
|
|
89
47
|
// in the subpath.
|
|
90
|
-
const rewritable =
|
|
48
|
+
const rewritable = edge.form === "import" &&
|
|
91
49
|
rule.fix === "subpath-namespace-import" &&
|
|
92
50
|
offending.length === bound.length &&
|
|
93
51
|
offending.every((one) => one.kind === "named");
|
|
94
52
|
if (rewritable) {
|
|
95
53
|
context.report({
|
|
96
|
-
node,
|
|
54
|
+
node: at(node),
|
|
97
55
|
message: formatMessage(violation),
|
|
98
|
-
fix: (fixer) => fixer.replaceText(node, subpathNamespaceImport(
|
|
56
|
+
fix: (fixer) => fixer.replaceText(at(node), subpathNamespaceImport(specifier, offending)),
|
|
99
57
|
});
|
|
100
58
|
continue;
|
|
101
59
|
}
|
|
102
60
|
context.report({
|
|
103
|
-
node: offending[0]?.node ?? node,
|
|
61
|
+
node: at(offending[0]?.node ?? node),
|
|
104
62
|
message: formatMessage(violation),
|
|
105
63
|
});
|
|
106
64
|
}
|
|
@@ -113,23 +71,9 @@ export const makeExportsRule = (policy) => ({
|
|
|
113
71
|
selected = exportRulesSelecting(policy.exportRules, importer);
|
|
114
72
|
return selected.length > 0;
|
|
115
73
|
},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
ExportNamedDeclaration(node) {
|
|
120
|
-
check(node, specifierOf(node), boundSpecifiers(node), false);
|
|
121
|
-
},
|
|
122
|
-
ExportAllDeclaration(node) {
|
|
123
|
-
check(node, specifierOf(node), [wholeModule(node, nameOf(node.exported) ?? "")], false);
|
|
124
|
-
},
|
|
125
|
-
ImportExpression(node) {
|
|
126
|
-
check(node, importExpressionSpecifierOf(node), [wholeModule(node)], false);
|
|
127
|
-
},
|
|
128
|
-
CallExpression(node) {
|
|
129
|
-
check(node, requireSpecifierOf(node), [wholeModule(node)], false);
|
|
130
|
-
},
|
|
131
|
-
TSImportEqualsDeclaration(node) {
|
|
132
|
-
check(node, importEqualsSpecifierOf(node), [wholeModule(node)], false);
|
|
74
|
+
Program(node) {
|
|
75
|
+
for (const edge of factsOfProgram(importer, node).edges)
|
|
76
|
+
check(edge);
|
|
133
77
|
},
|
|
134
78
|
};
|
|
135
79
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports-rule.js","sourceRoot":"","sources":["../../src/exports-rule.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"exports-rule.js","sourceRoot":"","sources":["../../src/exports-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,aAAa,GAGd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EACL,EAAE,EACF,cAAc,EAKd,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,6EAA6E;AAC7E,+EAA+E;AAC/E,8EAA8E;AAC9E,gFAAgF;AAChF,uDAAuD;AACvD,MAAM,sBAAsB,GAAG,CAAC,SAAiB,EAAE,KAAiC,EAAU,EAAE,CAC9F,KAAK;KACF,GAAG,CAAC,CAA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