@shivaedev/quality 0.75.0 → 0.76.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 +14 -0
- package/README.md +1 -1
- package/dist/adapters/databaseUrlFindings.d.ts +1 -1
- package/dist/adapters/databaseUrlFindings.d.ts.map +1 -1
- package/dist/adapters/knip/configuration.d.ts +1 -1
- package/dist/adapters/knip/configuration.d.ts.map +1 -1
- package/dist/adapters/knip/configuration.js +5 -1
- package/dist/adapters/knip/configuration.js.map +1 -1
- package/dist/adapters/knip/entryPointFindings.d.ts +1 -1
- package/dist/adapters/knip/entryPointFindings.d.ts.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/outsideImportFindings.d.ts +2 -1
- package/dist/adapters/outsideImportFindings.d.ts.map +1 -1
- package/dist/adapters/outsideImportFindings.js.map +1 -1
- package/dist/adapters/queueReadoutFindings.d.ts +1 -1
- package/dist/adapters/queueReadoutFindings.d.ts.map +1 -1
- package/dist/adapters/rpcBoundaryFindings.d.ts +1 -1
- package/dist/adapters/rpcBoundaryFindings.d.ts.map +1 -1
- package/dist/adapters/serviceIdFindings.d.ts +1 -1
- package/dist/adapters/serviceIdFindings.d.ts.map +1 -1
- package/dist/cli/lint.d.ts +8 -1
- package/dist/cli/lint.d.ts.map +1 -1
- package/dist/cli/lint.js +9 -4
- package/dist/cli/lint.js.map +1 -1
- package/dist/cli/migrateExceptions.d.ts.map +1 -1
- package/dist/cli/migrateExceptions.js +5 -8
- package/dist/cli/migrateExceptions.js.map +1 -1
- package/dist/exceptions/MigrationFailure.d.ts +9 -0
- package/dist/exceptions/MigrationFailure.d.ts.map +1 -0
- package/dist/exceptions/MigrationFailure.js +4 -0
- package/dist/exceptions/MigrationFailure.js.map +1 -0
- package/dist/exceptions/migrateBiome.d.ts +3 -1
- package/dist/exceptions/migrateBiome.d.ts.map +1 -1
- package/dist/exceptions/migrateBiome.js +5 -3
- package/dist/exceptions/migrateBiome.js.map +1 -1
- package/dist/exceptions/migrateConfig.d.ts +3 -1
- package/dist/exceptions/migrateConfig.d.ts.map +1 -1
- package/dist/exceptions/migrateConfig.js +40 -25
- package/dist/exceptions/migrateConfig.js.map +1 -1
- package/dist/hooks/preCommit.d.ts.map +1 -1
- package/dist/hooks/preCommit.js +7 -3
- package/dist/hooks/preCommit.js.map +1 -1
- package/dist/imports/departures.d.ts +1 -1
- package/dist/imports/departures.d.ts.map +1 -1
- package/dist/imports/fences/check.d.ts +1 -1
- package/dist/imports/fences/check.d.ts.map +1 -1
- package/dist/imports/fences/check.js +1 -1
- package/dist/imports/fences/check.js.map +1 -1
- package/dist/imports/fences/compilePolicy.d.ts +3 -1
- package/dist/imports/fences/compilePolicy.d.ts.map +1 -1
- package/dist/imports/fences/compilePolicy.js +4 -2
- package/dist/imports/fences/compilePolicy.js.map +1 -1
- package/dist/imports/globMatcher.d.ts.map +1 -1
- package/dist/imports/globMatcher.js +33 -31
- package/dist/imports/globMatcher.js.map +1 -1
- package/dist/imports/graph.d.ts +1 -1
- package/dist/imports/graph.d.ts.map +1 -1
- package/dist/imports/pnpmWorkspacePatterns.d.ts +12 -2
- package/dist/imports/pnpmWorkspacePatterns.d.ts.map +1 -1
- package/dist/imports/pnpmWorkspacePatterns.js +31 -32
- package/dist/imports/pnpmWorkspacePatterns.js.map +1 -1
- package/dist/imports/workspace.d.ts +1 -1
- package/dist/imports/workspace.d.ts.map +1 -1
- package/dist/imports/workspace.js +1 -1
- package/dist/imports/workspace.js.map +1 -1
- package/dist/inventory/programmaticBuilds.d.ts +1 -1
- package/dist/inventory/programmaticBuilds.d.ts.map +1 -1
- package/dist/manifests/deliveredDependencies.d.ts +3 -0
- package/dist/manifests/deliveredDependencies.d.ts.map +1 -0
- package/dist/manifests/deliveredDependencies.js +8 -0
- package/dist/manifests/deliveredDependencies.js.map +1 -0
- package/dist/naming/developmentCode.d.ts +1 -1
- package/dist/naming/developmentCode.d.ts.map +1 -1
- package/dist/naming/packageTests.d.ts +1 -1
- package/dist/naming/packageTests.d.ts.map +1 -1
- package/dist/naming/testCode.d.ts +1 -1
- package/dist/naming/testCode.d.ts.map +1 -1
- package/dist/report/recap.d.ts +4 -0
- package/dist/report/recap.d.ts.map +1 -0
- package/dist/report/recap.js +23 -0
- package/dist/report/recap.js.map +1 -0
- package/dist/report/render.d.ts +1 -0
- package/dist/report/render.d.ts.map +1 -1
- package/dist/report/render.js +1 -1
- package/dist/report/render.js.map +1 -1
- package/dist/rules/manifestsApplication.d.ts.map +1 -1
- package/dist/rules/manifestsApplication.js +4 -5
- package/dist/rules/manifestsApplication.js.map +1 -1
- package/dist/rules/stories/sources.d.ts +2 -2
- package/dist/rules/stories/sources.d.ts.map +1 -1
- package/docs/debt-and-hooks.md +3 -1
- package/package.json +4 -4
- package/src/adapters/knip/configuration.ts +5 -1
- package/src/adapters/outsideImportFindings.ts +2 -1
- package/src/cli/lint.ts +24 -16
- package/src/cli/migrateExceptions.ts +8 -9
- package/src/exceptions/MigrationFailure.ts +5 -0
- package/src/exceptions/migrateBiome.ts +10 -4
- package/src/exceptions/migrateConfig.ts +66 -29
- package/src/hooks/preCommit.ts +7 -6
- package/src/imports/fences/check.ts +1 -1
- package/src/imports/fences/compilePolicy.ts +5 -3
- package/src/imports/globMatcher.ts +42 -35
- package/src/imports/pnpmWorkspacePatterns.ts +44 -39
- package/src/imports/workspace.ts +1 -1
- package/src/manifests/deliveredDependencies.ts +11 -0
- package/src/report/recap.ts +29 -0
- package/src/report/render.ts +1 -1
- package/src/rules/manifestsApplication.ts +4 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"programmaticBuilds.d.ts","sourceRoot":"","sources":["../../src/inventory/programmaticBuilds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"programmaticBuilds.d.ts","sourceRoot":"","sources":["../../src/inventory/programmaticBuilds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,kBAAkB,oWAM7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deliveredDependencies.d.ts","sourceRoot":"","sources":["../../src/manifests/deliveredDependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK3D,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,CAK9G"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const MANIFEST_EXPORT = "./package.json";
|
|
2
|
+
// A package that exports only its manifest and holds no sources ships no code: the dependencies it installs are what it delivers.
|
|
3
|
+
export function deliveredDependencies(manifest, sources) {
|
|
4
|
+
const exported = typeof manifest.exports === "object" && manifest.exports !== null ? Object.keys(manifest.exports) : [];
|
|
5
|
+
const shell = sources.length === 0 && manifest.bin === undefined && manifest.main === undefined && exported.length === 1 && exported[0] === MANIFEST_EXPORT;
|
|
6
|
+
return shell ? Object.keys(manifest.dependencies ?? {}) : [];
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=deliveredDependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deliveredDependencies.js","sourceRoot":"","sources":["../../src/manifests/deliveredDependencies.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAEzC,kIAAkI;AAClI,MAAM,UAAU,qBAAqB,CAAC,QAAyB,EAAE,OAA0B;IAC1F,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACxH,MAAM,KAAK,GACV,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,GAAG,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,eAAe,CAAC;IAC/I,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { RuleInputs } from "#rule.ts";
|
|
3
|
-
export declare const developmentCode: (inputs: RuleInputs) => Effect.Effect<(path: string) => boolean, import("../imports/globMatcher.ts").GlobFailure | import("#adapters/manifestInventory.ts").ManifestReadFailure, never>;
|
|
3
|
+
export declare const developmentCode: (inputs: RuleInputs) => Effect.Effect<(path: string) => boolean, import("../imports/globMatcher.ts").GlobFailure | import("../imports/pnpmWorkspacePatterns.ts").PnpmWorkspaceFailure | import("#adapters/manifestInventory.ts").ManifestReadFailure, never>;
|
|
4
4
|
//# sourceMappingURL=developmentCode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"developmentCode.d.ts","sourceRoot":"","sources":["../../src/naming/developmentCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAKtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,eAAe,+CASb,MAAM,
|
|
1
|
+
{"version":3,"file":"developmentCode.d.ts","sourceRoot":"","sources":["../../src/naming/developmentCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAKtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,eAAe,+CASb,MAAM,yMAInB,CAAC"}
|
|
@@ -3,5 +3,5 @@ import type { RuleInputs } from "#rule.ts";
|
|
|
3
3
|
export declare const packageTests: (inputs: RuleInputs) => Effect.Effect<{
|
|
4
4
|
packages: import("#imports/workspace.ts").WorkspacePackage[];
|
|
5
5
|
sourcePath: (path: string) => string | undefined;
|
|
6
|
-
}, import("../imports/globMatcher.ts").GlobFailure | import("#adapters/manifestInventory.ts").ManifestReadFailure, never>;
|
|
6
|
+
}, import("../imports/globMatcher.ts").GlobFailure | import("../imports/pnpmWorkspacePatterns.ts").PnpmWorkspaceFailure | import("#adapters/manifestInventory.ts").ManifestReadFailure, never>;
|
|
7
7
|
//# sourceMappingURL=packageTests.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageTests.d.ts","sourceRoot":"","sources":["../../src/naming/packageTests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,YAAY;;uBASE,MAAM,KAAG,MAAM,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"packageTests.d.ts","sourceRoot":"","sources":["../../src/naming/packageTests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,YAAY;;uBASE,MAAM,KAAG,MAAM,GAAG,SAAS;8LASpD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { RuleInputs } from "#rule.ts";
|
|
3
|
-
export declare const testCode: (inputs: RuleInputs) => Effect.Effect<(path: string) => boolean, import("../imports/globMatcher.ts").GlobFailure | import("../adapters/ImportAnalysisFailure.ts").ImportAnalysisFailure | import("#adapters/manifestInventory.ts").ManifestReadFailure, never>;
|
|
3
|
+
export declare const testCode: (inputs: RuleInputs) => Effect.Effect<(path: string) => boolean, import("../imports/globMatcher.ts").GlobFailure | import("../adapters/ImportAnalysisFailure.ts").ImportAnalysisFailure | import("../imports/pnpmWorkspacePatterns.ts").PnpmWorkspaceFailure | import("#adapters/manifestInventory.ts").ManifestReadFailure, never>;
|
|
4
4
|
//# sourceMappingURL=testCode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testCode.d.ts","sourceRoot":"","sources":["../../src/naming/testCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAUtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,QAAQ,+CAGI,MAAM,
|
|
1
|
+
{"version":3,"file":"testCode.d.ts","sourceRoot":"","sources":["../../src/naming/testCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAUtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,QAAQ,+CAGI,MAAM,gRA6C7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recap.d.ts","sourceRoot":"","sources":["../../src/report/recap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAgBjE,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAStE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { groupBy } from "#engine/violation.ts";
|
|
2
|
+
import { plural } from "#report/plural.ts";
|
|
3
|
+
import { failures } from "#report/render.ts";
|
|
4
|
+
const FILES_SHOWN = 3;
|
|
5
|
+
function firstFiles(files) {
|
|
6
|
+
const distinct = [...new Set(files)];
|
|
7
|
+
const shown = distinct.slice(0, FILES_SHOWN).join(", ");
|
|
8
|
+
return distinct.length > FILES_SHOWN ? `${shown} and ${plural(distinct.length - FILES_SHOWN, "more file")}` : shown;
|
|
9
|
+
}
|
|
10
|
+
function staleLine(file, entries) {
|
|
11
|
+
return entries.length === 0
|
|
12
|
+
? []
|
|
13
|
+
: [` error ${file} (${plural(entries.length, "stale entry", "stale entries")}): ${firstFiles(entries.map(({ entry }) => entry.file))}`];
|
|
14
|
+
}
|
|
15
|
+
export function recap(outcome, context) {
|
|
16
|
+
return [
|
|
17
|
+
`quality lint failed with ${failures(outcome)}:`,
|
|
18
|
+
...[...groupBy(outcome.errors, (violation) => violation.rule).entries()].map(([rule, inRule]) => ` error ${rule} (${inRule.length}): ${firstFiles(inRule.map((violation) => violation.file))}`),
|
|
19
|
+
...staleLine(context.baseline, outcome.staleBaseline),
|
|
20
|
+
...staleLine(context.registry, outcome.staleRegistry),
|
|
21
|
+
].join("\n");
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=recap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recap.js","sourceRoot":"","sources":["../../src/report/recap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAsB,MAAM,mBAAmB,CAAC;AAEjE,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,SAAS,UAAU,CAAC,KAAwB;IAC3C,MAAM,QA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,EAAE,OAAO,CAAC,aAAa,CAAC;QACrD,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,aAAa,CAAC;KACrD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC"}
|
package/dist/report/render.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export interface ReportContext {
|
|
|
5
5
|
readonly descriptions: ReadonlyMap<string, string>;
|
|
6
6
|
readonly registry: string;
|
|
7
7
|
}
|
|
8
|
+
export declare function failures(outcome: Outcome): string;
|
|
8
9
|
export declare function render(outcome: Outcome, context: ReportContext): string;
|
|
9
10
|
//# sourceMappingURL=render.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/report/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,qBAAqB,CAAC;AAK3D,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/report/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,qBAAqB,CAAC;AAK3D,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAgCD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAMjD;AAiBD,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAQvE"}
|
package/dist/report/render.js
CHANGED
|
@@ -25,7 +25,7 @@ function detailed(violations, regressions) {
|
|
|
25
25
|
function ruleSections(violations, context, regressions) {
|
|
26
26
|
return [...groupBy(violations, (violation) => violation.rule).entries()].map(([rule, inRule]) => [...heading(rule, inRule, context), ...detailed(inRule, regressions)].join("\n"));
|
|
27
27
|
}
|
|
28
|
-
function failures(outcome) {
|
|
28
|
+
export function failures(outcome) {
|
|
29
29
|
const stale = outcome.staleBaseline.length + outcome.staleRegistry.length;
|
|
30
30
|
return [
|
|
31
31
|
...(outcome.errors.length > 0 ? [plural(outcome.errors.length, "error")] : []),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/report/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAkB,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AASzD,SAAS,MAAM,CAAC,SAAoB;IACnC,OAAO,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;AAC9F,CAAC;AAED,SAAS,cAAc,CAAC,UAAsB;IAC7C,OAAO,KAAK,UAAU,CAAC,KAAK,CAAC,IAAI,0BAA0B,UAAU,CAAC,KAAK,YAAY,UAAU,CAAC,KAAK,CAAC,KAAK,aAAa,CAAC;AAC5H,CAAC;AAED,SAAS,OAAO,CAAC,IAAY,EAAE,UAAgC,EAAE,OAAsB;IACtF,M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AO,GAAG,OAAO,KAAK,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,UAAU,GAAG,CAAC;AACtF,CAAC;AAED,SAAS,SAAS,CAAC,OAAgB;IAClC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,4FAA4F,CAAC,CAAC;AAC9H,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,OAAgB,EAAE,OAAsB;IAC9D,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACxI,OAAO;QACN,GAAG,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC;QACrD,GAAG,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC;QAClC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC;QACzB,GAAG,SAAS,CAAC,OAAO,CAAC;KACrB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifestsApplication.d.ts","sourceRoot":"","sources":["../../src/rules/manifestsApplication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manifestsApplication.d.ts","sourceRoot":"","sources":["../../src/rules/manifestsApplication.ts"],"names":[],"mappings":"AAyFA,eAAO,MAAM,oBAAoB,oEA0B/B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dirname, posix, relative, resolve, sep } from "node:path";
|
|
2
|
-
import { Effect } from "effect";
|
|
2
|
+
import { Effect, Result } from "effect";
|
|
3
3
|
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
4
4
|
import { pnpmWorkspaceList } from "#imports/pnpmWorkspacePatterns.ts";
|
|
5
5
|
import { workspacePackages } from "#imports/workspace.ts";
|
|
@@ -35,10 +35,9 @@ const hoistFindings = Effect.fn("Manifests.hoistFindings")(function* (inputs, ma
|
|
|
35
35
|
if (workspace === undefined) {
|
|
36
36
|
return [{ file: manifestPath, message: `Depends on "${PLATFORM}" without a pnpm-workspace.yaml. ${repair}`, subject: HOIST_KEY }];
|
|
37
37
|
}
|
|
38
|
-
const parsed =
|
|
39
|
-
if (parsed
|
|
40
|
-
|
|
41
|
-
return [{ file: workspace.path, message: `${cause instanceof Error ? cause.message : String(cause)}. Write ${HOIST_LINE}.`, subject: HOIST_KEY }];
|
|
38
|
+
const parsed = pnpmWorkspaceList(workspace.text, HOIST_KEY);
|
|
39
|
+
if (Result.isFailure(parsed)) {
|
|
40
|
+
return [{ file: workspace.path, message: `${parsed.failure.message}. Write ${HOIST_LINE}.`, subject: HOIST_KEY }];
|
|
42
41
|
}
|
|
43
42
|
const patterns = parsed.success;
|
|
44
43
|
const included = patterns.some((pattern) => !pattern.startsWith("!") && hoists(pattern));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifestsApplication.js","sourceRoot":"","sources":["../../src/rules/manifestsApplication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"manifestsApplication.js","sourceRoot":"","sources":["../../src/rules/manifestsApplication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAA4B,mBAAmB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,CAAC;YACnB,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;YAC3D,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YAC3E,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC9B,OAAO,EAAE,CAAC;YACX,CAAC;YACD,OAAO;gBACN,GAAG,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;gBAC1D,GAAG,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;aACnF,CAAC;QACH,CAAC,CAAC,EACH,EAAE,WAAW,EAAE,WAAW,EAAE,CAC5B,CAAC;QACF,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC,CAAC;IACH,WAAW,EAAE,6CAA6C,QAAQ,YAAY,OAAO,yGAAyG;IAC9L,EAAE,EAAE,uBAAuB;CAC3B,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { RuleInputs } from "#rule.ts";
|
|
3
|
-
export declare const storySources: (inputs: RuleInputs) => Effect.Effect<import("#rule.ts").SourceFile[], import("../../imports/globMatcher.ts").GlobFailure | import("../../adapters/ImportAnalysisFailure.ts").ImportAnalysisFailure | import("../../adapters/manifestInventory.ts").ManifestReadFailure, never>;
|
|
4
|
-
export declare const storyWaitSources: (inputs: RuleInputs) => Effect.Effect<import("#rule.ts").SourceFile[], import("../../imports/globMatcher.ts").GlobFailure | import("../../adapters/ImportAnalysisFailure.ts").ImportAnalysisFailure | import("../../adapters/manifestInventory.ts").ManifestReadFailure, never>;
|
|
3
|
+
export declare const storySources: (inputs: RuleInputs) => Effect.Effect<import("#rule.ts").SourceFile[], import("../../imports/globMatcher.ts").GlobFailure | import("../../adapters/ImportAnalysisFailure.ts").ImportAnalysisFailure | import("../../imports/pnpmWorkspacePatterns.ts").PnpmWorkspaceFailure | import("../../adapters/manifestInventory.ts").ManifestReadFailure, never>;
|
|
4
|
+
export declare const storyWaitSources: (inputs: RuleInputs) => Effect.Effect<import("#rule.ts").SourceFile[], import("../../imports/globMatcher.ts").GlobFailure | import("../../adapters/ImportAnalysisFailure.ts").ImportAnalysisFailure | import("../../imports/pnpmWorkspacePatterns.ts").PnpmWorkspaceFailure | import("../../adapters/manifestInventory.ts").ManifestReadFailure, never>;
|
|
5
5
|
//# sourceMappingURL=sources.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../../src/rules/stories/sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMhC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAI3C,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../../src/rules/stories/sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMhC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAI3C,eAAO,MAAM,YAAY,yVAsBvB,CAAC;AAEH,eAAO,MAAM,gBAAgB,yVAe3B,CAAC"}
|
package/docs/debt-and-hooks.md
CHANGED
|
@@ -69,9 +69,11 @@ Export an object or `defineConfig({ ... })` without spreads for automatic editin
|
|
|
69
69
|
|
|
70
70
|
Scripts run from the config's folder, or the current directory when there is no config. Without a manifest or either script, the hook runs lint alone. An invalid manifest stops the run. Baseline tightening is an explicit command; the hook does not change or stage debt records.
|
|
71
71
|
|
|
72
|
-
After a reported lint failure or a nonzero command exit, later commands still run, so one attempt shows their results too. A config, setup or process-launch failure stops the run. `lint` and the commands check the files on disk, not only what is staged. When checks report failures, the hook blocks the commit and ends with the checks that failed and what to do next:
|
|
72
|
+
After a reported lint failure or a nonzero command exit, later commands still run, so one attempt shows their results too. A config, setup or process-launch failure stops the run. `lint` and the commands check the files on disk, not only what is staged. When checks report failures, the hook blocks the commit and ends with the checks that failed and what to do next. A failed lint is repeated there, after the output of the scripts, with each rule's count and its first three files, and the files of stale baseline or registry entries:
|
|
73
73
|
|
|
74
74
|
```text
|
|
75
|
+
quality lint failed with 2 errors:
|
|
76
|
+
error structure/max-lines (2): src/notes.ts, src/server.ts
|
|
75
77
|
quality: pre-commit failed: quality lint, `pnpm run typecheck` (exit code 2).
|
|
76
78
|
help: fix what the output above reports, then commit again; `quality hooks pre-commit` repeats these checks without committing.
|
|
77
79
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/quality",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.76.0",
|
|
4
4
|
"description": "Repository quality gate with typed rules, a baseline of existing debt and a registry of reasoned exceptions",
|
|
5
5
|
"homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/quality#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@shivaedev/errors": "0.11.0",
|
|
57
57
|
"@shivaedev/heavy-lock": "0.11.1",
|
|
58
58
|
"@shivaedev/service": "0.9.0",
|
|
59
|
-
"@shivaedev/skills": "0.
|
|
59
|
+
"@shivaedev/skills": "0.9.0",
|
|
60
60
|
"@vitest/coverage-v8": "5.0.5",
|
|
61
61
|
"browserslist": "4.29.5",
|
|
62
62
|
"ignore": "7.0.14",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@effect/platform-node": "4.1.1",
|
|
69
69
|
"@effect/platform-node-shared": "4.1.1",
|
|
70
70
|
"@effect/vitest": "4.1.1",
|
|
71
|
-
"@shivaedev/test-story": "0.46.
|
|
71
|
+
"@shivaedev/test-story": "0.46.1",
|
|
72
72
|
"@types/node": "24.19.2",
|
|
73
73
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
74
74
|
"effect": "4.1.1",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@effect/platform-node": "4.1.1",
|
|
79
79
|
"@effect/platform-node-shared": "4.1.1",
|
|
80
|
-
"@shivaedev/test-story": "0.46.
|
|
80
|
+
"@shivaedev/test-story": "0.46.1",
|
|
81
81
|
"effect": "4.1.1",
|
|
82
82
|
"vitest": "5.0.5"
|
|
83
83
|
},
|
|
@@ -9,6 +9,7 @@ import type { ReachableBuilds } from "#adapters/reachableBuilds.ts";
|
|
|
9
9
|
import { scriptPaths } from "#adapters/scriptPaths.ts";
|
|
10
10
|
import { exportedModule, exportTargets } from "#imports/packageExports.ts";
|
|
11
11
|
import { packageOf, workspacePackages } from "#imports/workspace.ts";
|
|
12
|
+
import { deliveredDependencies } from "#manifests/deliveredDependencies.ts";
|
|
12
13
|
import type { PackageManifest } from "#PackageManifest.ts";
|
|
13
14
|
import type { RuleInputs } from "#rule.ts";
|
|
14
15
|
|
|
@@ -104,7 +105,10 @@ export const knipConfiguration = Effect.fn("Knip.knipConfiguration")(function* (
|
|
|
104
105
|
...workspaceEntries,
|
|
105
106
|
],
|
|
106
107
|
// A bundle leaves its externals as runtime imports, which the bundling package's own dependencies satisfy.
|
|
107
|
-
ignoreDependencies:
|
|
108
|
+
ignoreDependencies: [
|
|
109
|
+
...externalDependencies(manifest, builds.externals.get(directory === "." ? "" : directory) ?? new Set()),
|
|
110
|
+
...deliveredDependencies(manifest, sources),
|
|
111
|
+
],
|
|
108
112
|
paths: importPaths(manifest.imports ?? {}),
|
|
109
113
|
project: [...sources, ...ui, ...styles, ...workspaceEntries],
|
|
110
114
|
vitest: { config: ["vitest*.config.{ts,mts,cts,js,mjs,cjs}", "vitest.{workspace,projects}.{ts,mts,cts,js,mjs,cjs,json}"] },
|
|
@@ -5,6 +5,7 @@ import type { GlobFailure } from "#imports/globMatcher.ts";
|
|
|
5
5
|
import { importGraph } from "#imports/graph.ts";
|
|
6
6
|
import { isPackageRootConfig } from "#imports/isTooling.ts";
|
|
7
7
|
import { packageNameOf } from "#imports/packageName.ts";
|
|
8
|
+
import type { PnpmWorkspaceFailure } from "#imports/pnpmWorkspacePatterns.ts";
|
|
8
9
|
import { packageOf } from "#imports/workspace.ts";
|
|
9
10
|
import { testName } from "#naming/testName.ts";
|
|
10
11
|
import type { Finding, RuleInputs } from "#rule.ts";
|
|
@@ -42,7 +43,7 @@ function exempt(directory: string, path: string, name: string): boolean {
|
|
|
42
43
|
|
|
43
44
|
export const outsideImportFindings = Effect.fn("Imports.outsideImportFindings")(function* (
|
|
44
45
|
inputs: RuleInputs,
|
|
45
|
-
): Effect.fn.Return<readonly Finding[], GlobFailure | ImportAnalysisFailure | ManifestReadFailure> {
|
|
46
|
+
): Effect.fn.Return<readonly Finding[], GlobFailure | ImportAnalysisFailure | ManifestReadFailure | PnpmWorkspaceFailure> {
|
|
46
47
|
const graph = yield* importGraph(inputs);
|
|
47
48
|
const owners = [...graph.packages.map((owner) => owner.directory), "."];
|
|
48
49
|
const runtime = new Map(
|
package/src/cli/lint.ts
CHANGED
|
@@ -3,15 +3,20 @@ import * as NodePath from "@effect/platform-node/NodePath";
|
|
|
3
3
|
import { Console, Effect, Path } from "effect";
|
|
4
4
|
import { withHeavyLock } from "@shivaedev/heavy-lock/withHeavyLock.ts";
|
|
5
5
|
import { looseStagedEntries } from "#baseline/looseStagedEntries.ts";
|
|
6
|
-
import { evaluate, passes } from "#engine/evaluate.ts";
|
|
6
|
+
import { evaluate, type Outcome, passes } from "#engine/evaluate.ts";
|
|
7
7
|
import { openSession } from "#engine/session.ts";
|
|
8
8
|
import { keyOf } from "#engine/violation.ts";
|
|
9
9
|
import { GateFailed, SetupFailure } from "#failure.ts";
|
|
10
|
-
import { render } from "#report/render.ts";
|
|
10
|
+
import { type ReportContext, render } from "#report/render.ts";
|
|
11
11
|
import type { RuleServices } from "#rule.ts";
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
|
|
13
|
+
export interface LintResult {
|
|
14
|
+
readonly context: ReportContext;
|
|
15
|
+
readonly outcome: Outcome;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const reportLint = Effect.fn("Cli.reportLint")(
|
|
19
|
+
function* (cwd: string, config: string | undefined, staged: boolean): Effect.fn.Return<LintResult, SetupFailure, RuleServices> {
|
|
15
20
|
const { relative } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
16
21
|
|
|
17
22
|
const session = yield* openSession(cwd, config);
|
|
@@ -24,18 +29,14 @@ export const lint = Effect.fn("Cli.lint")(
|
|
|
24
29
|
staleBaseline: [...evaluated.staleBaseline, ...loose],
|
|
25
30
|
staleRegistry: [...evaluated.staleRegistry, ...session.staleRegistry],
|
|
26
31
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
);
|
|
36
|
-
if (!passes(outcome)) {
|
|
37
|
-
return yield* new GateFailed();
|
|
38
|
-
}
|
|
32
|
+
const context = {
|
|
33
|
+
baseline: session.config.baseline,
|
|
34
|
+
checked: session.inventory.sources.length,
|
|
35
|
+
descriptions: new Map(session.config.active.map((rule) => [rule.id, rule.description])),
|
|
36
|
+
registry: session.config.exceptions.length === 0 ? session.config.registry : `${relative(session.config.root, session.config.file)} exceptions`,
|
|
37
|
+
};
|
|
38
|
+
yield* Console.log(render(outcome, context));
|
|
39
|
+
return { context, outcome };
|
|
39
40
|
},
|
|
40
41
|
(effect) =>
|
|
41
42
|
withHeavyLock(effect, { command: "quality lint" }).pipe(
|
|
@@ -44,3 +45,10 @@ export const lint = Effect.fn("Cli.lint")(
|
|
|
44
45
|
Effect.provide(NodePath.layer),
|
|
45
46
|
),
|
|
46
47
|
);
|
|
48
|
+
|
|
49
|
+
export const lint = Effect.fn("Cli.lint")(function* (cwd: string, config: string | undefined) {
|
|
50
|
+
const { outcome } = yield* reportLint(cwd, config, false);
|
|
51
|
+
if (!passes(outcome)) {
|
|
52
|
+
return yield* new GateFailed();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
-
import { Console, Effect, FileSystem, Path } from "effect";
|
|
2
|
+
import { Console, Effect, FileSystem, Path, type Result } from "effect";
|
|
3
3
|
import { loadConfig } from "#config/load.ts";
|
|
4
4
|
import { validOrFail } from "#decoded.ts";
|
|
5
5
|
import { readInput } from "#engine/baselineFile.ts";
|
|
6
6
|
import { decodeExceptions, type ExceptionDeclaration } from "#exceptions/declaration.ts";
|
|
7
|
+
import type { MigrationFailure } from "#exceptions/MigrationFailure.ts";
|
|
7
8
|
import { migrateBiome } from "#exceptions/migrateBiome.ts";
|
|
8
9
|
import { migrateConfig } from "#exceptions/migrateConfig.ts";
|
|
9
10
|
import { decodeRegistry } from "#exceptions/registry.ts";
|
|
@@ -33,6 +34,10 @@ function merge(entries: readonly ExceptionDeclaration[]): readonly ExceptionDecl
|
|
|
33
34
|
return merged;
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
function migrated(result: Result.Result<string, MigrationFailure>): Effect.Effect<string, SetupFailure> {
|
|
38
|
+
return Effect.mapError(Effect.fromResult(result), (failure) => new SetupFailure({ cause: failure, message: `Error: ${failure.message}` }));
|
|
39
|
+
}
|
|
40
|
+
|
|
36
41
|
export const migrateExceptions = Effect.fnUntraced(function* (
|
|
37
42
|
cwd: string,
|
|
38
43
|
configPath: string | undefined,
|
|
@@ -61,19 +66,13 @@ export const migrateExceptions = Effect.fnUntraced(function* (
|
|
|
61
66
|
]);
|
|
62
67
|
yield* validOrFail(config.file, decodeExceptions(entries));
|
|
63
68
|
const text = yield* readInput("", config.file);
|
|
64
|
-
const next = yield*
|
|
65
|
-
catch: (cause) => new SetupFailure({ cause, message: String(cause) }),
|
|
66
|
-
try: () => migrateConfig(text, config.file, entries, config.biomeDeclarations.length > 0),
|
|
67
|
-
});
|
|
69
|
+
const next = yield* migrated(migrateConfig(text, config.file, entries, config.biomeDeclarations.length > 0));
|
|
68
70
|
const updates: Array<{ readonly path: string; readonly text: string }> = [{ path: config.file, text: next }];
|
|
69
71
|
if (config.biomeDeclarations.length > 0) {
|
|
70
72
|
for (const file of ["biome.json", "biome.jsonc"]) {
|
|
71
73
|
const biome = yield* readInput(config.root, file);
|
|
72
74
|
if (biome !== undefined) {
|
|
73
|
-
const updated = yield*
|
|
74
|
-
catch: (cause) => new SetupFailure({ cause, message: String(cause) }),
|
|
75
|
-
try: () => migrateBiome(biome, file, config.biomeDeclarations),
|
|
76
|
-
});
|
|
75
|
+
const updated = yield* migrated(migrateBiome(biome, file, config.biomeDeclarations));
|
|
77
76
|
updates.push({ path: join(config.root, file), text: updated });
|
|
78
77
|
}
|
|
79
78
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Result } from "effect";
|
|
1
2
|
import ts from "typescript";
|
|
3
|
+
import { MigrationFailure } from "#exceptions/MigrationFailure.ts";
|
|
2
4
|
import type { Declaration } from "#rules/suppressions/biome/declarations.ts";
|
|
3
5
|
|
|
4
6
|
function nameOf(property: ts.ObjectLiteralElementLike): string | undefined {
|
|
@@ -34,11 +36,13 @@ function settingPath(rule: string): readonly string[] {
|
|
|
34
36
|
return tool === "files" ? ["files", "includes"] : [tool === "lint" ? "linter" : "assist", tool === "lint" ? "rules" : "actions", group, name];
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
export function migrateBiome(text: string, file: string, declarations: readonly Declaration[]): string {
|
|
39
|
+
export function migrateBiome(text: string, file: string, declarations: readonly Declaration[]): Result.Result<string, MigrationFailure> {
|
|
38
40
|
const source = ts.parseJsonText(file, text);
|
|
39
41
|
const root = source.statements[0]?.expression;
|
|
40
42
|
if (ts.parseConfigFileTextToJson(file, text).error !== undefined || root === undefined || !ts.isObjectLiteralExpression(root)) {
|
|
41
|
-
|
|
43
|
+
return Result.fail(
|
|
44
|
+
new MigrationFailure({ message: `Cannot migrate invalid Biome config ${file}. Repair it, then run quality exceptions migrate again.` }),
|
|
45
|
+
);
|
|
42
46
|
}
|
|
43
47
|
const globals = declarations.filter((entry) => entry.rule === "files/includes");
|
|
44
48
|
const stripped = strip(
|
|
@@ -46,7 +50,7 @@ export function migrateBiome(text: string, file: string, declarations: readonly
|
|
|
46
50
|
globals.map((entry) => settingPath(entry.rule)),
|
|
47
51
|
);
|
|
48
52
|
if (!ts.isObjectLiteralExpression(stripped)) {
|
|
49
|
-
|
|
53
|
+
return Result.fail(new MigrationFailure({ message: `Cannot migrate ${file}.` }));
|
|
50
54
|
}
|
|
51
55
|
const properties = stripped.properties.flatMap((property) => {
|
|
52
56
|
if (nameOf(property) !== "overrides" || !ts.isPropertyAssignment(property) || !ts.isArrayLiteralExpression(property.initializer)) {
|
|
@@ -74,5 +78,7 @@ export function migrateBiome(text: string, file: string, declarations: readonly
|
|
|
74
78
|
? []
|
|
75
79
|
: [ts.factory.updatePropertyAssignment(property, property.name, ts.factory.updateArrayLiteralExpression(property.initializer, overrides))];
|
|
76
80
|
});
|
|
77
|
-
return
|
|
81
|
+
return Result.succeed(
|
|
82
|
+
`${ts.createPrinter().printNode(ts.EmitHint.Expression, ts.factory.updateObjectLiteralExpression(root, properties), source)}\n`,
|
|
83
|
+
);
|
|
78
84
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { Result } from "effect";
|
|
1
2
|
import ts from "typescript";
|
|
2
3
|
import type { ExceptionDeclaration } from "#exceptions/declaration.ts";
|
|
4
|
+
import { MigrationFailure } from "#exceptions/MigrationFailure.ts";
|
|
5
|
+
|
|
6
|
+
interface KeptProperty {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly text: string;
|
|
9
|
+
}
|
|
3
10
|
|
|
4
11
|
function objectOf(expression: ts.Expression): ts.ObjectLiteralExpression | undefined {
|
|
5
12
|
if (ts.isObjectLiteralExpression(expression)) {
|
|
@@ -13,52 +20,82 @@ function objectOf(expression: ts.Expression): ts.ObjectLiteralExpression | undef
|
|
|
13
20
|
: undefined;
|
|
14
21
|
}
|
|
15
22
|
|
|
16
|
-
function nameOf(property: ts.ObjectLiteralElementLike): string | undefined {
|
|
23
|
+
function nameOf(property: ts.ObjectLiteralElementLike): Result.Result<string | undefined, MigrationFailure> {
|
|
17
24
|
const name = property.name;
|
|
18
25
|
if (name === undefined) {
|
|
19
|
-
return undefined;
|
|
26
|
+
return Result.succeed(undefined);
|
|
20
27
|
}
|
|
21
28
|
if (ts.isComputedPropertyName(name)) {
|
|
22
29
|
if (ts.isStringLiteral(name.expression) || ts.isNoSubstitutionTemplateLiteral(name.expression) || ts.isNumericLiteral(name.expression)) {
|
|
23
|
-
return name.expression.text;
|
|
30
|
+
return Result.succeed(name.expression.text);
|
|
24
31
|
}
|
|
25
|
-
|
|
32
|
+
return Result.fail(
|
|
33
|
+
new MigrationFailure({
|
|
34
|
+
message: "Cannot migrate a computed property automatically. Use literal property keys, then run quality exceptions migrate again.",
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
26
37
|
}
|
|
27
|
-
return ts.isStringLiteral(name) || ts.isIdentifier(name) || ts.isNumericLiteral(name) ? name.text : undefined;
|
|
38
|
+
return Result.succeed(ts.isStringLiteral(name) || ts.isIdentifier(name) || ts.isNumericLiteral(name) ? name.text : undefined);
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
function keptRules(initializer: ts.ObjectLiteralExpression, source: ts.SourceFile): Result.Result<readonly KeptProperty[], MigrationFailure> {
|
|
42
|
+
return Result.map(
|
|
43
|
+
Result.all(initializer.properties.map((rule) => Result.map(nameOf(rule), (name) => (name === "suppressions/biome-overrides" ? [] : [rule])))),
|
|
44
|
+
(kept) => {
|
|
45
|
+
const rules = kept.flat();
|
|
46
|
+
return rules.length === 0 ? [] : [{ name: "rules", text: `rules: {\n${rules.map((rule) => rule.getFullText(source).trim()).join(",\n")}\n}` }];
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function keptProperty(
|
|
52
|
+
property: ts.ObjectLiteralElementLike,
|
|
53
|
+
source: ts.SourceFile,
|
|
54
|
+
file: string,
|
|
55
|
+
hasDeclarations: boolean,
|
|
56
|
+
): Result.Result<readonly KeptProperty[], MigrationFailure> {
|
|
57
|
+
return Result.flatMap(nameOf(property), (name): Result.Result<readonly KeptProperty[], MigrationFailure> => {
|
|
44
58
|
if (name === "registry" || name === "exceptions") {
|
|
45
|
-
return [];
|
|
59
|
+
return Result.succeed([]);
|
|
46
60
|
}
|
|
47
61
|
if (name !== "rules" || !hasDeclarations) {
|
|
48
|
-
return [{ name: name ?? "", text: property.getFullText(source).trim() }];
|
|
62
|
+
return Result.succeed([{ name: name ?? "", text: property.getFullText(source).trim() }]);
|
|
49
63
|
}
|
|
50
64
|
if (
|
|
51
65
|
!(ts.isPropertyAssignment(property) && ts.isObjectLiteralExpression(property.initializer))
|
|
52
66
|
|| property.initializer.properties.some(ts.isSpreadAssignment)
|
|
53
67
|
) {
|
|
54
|
-
|
|
68
|
+
return Result.fail(new MigrationFailure({ message: `Inline the rules object in ${file}, then run quality exceptions migrate again.` }));
|
|
55
69
|
}
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
return keptRules(property.initializer, source);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function migrateConfig(
|
|
75
|
+
text: string | undefined,
|
|
76
|
+
file: string,
|
|
77
|
+
exceptions: readonly ExceptionDeclaration[],
|
|
78
|
+
hasDeclarations: boolean,
|
|
79
|
+
): Result.Result<string, MigrationFailure> {
|
|
80
|
+
if (text === undefined) {
|
|
81
|
+
return Result.succeed(`export default { exceptions: ${JSON.stringify(exceptions, null, "\t")} };\n`);
|
|
82
|
+
}
|
|
83
|
+
const source = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
84
|
+
const exported = source.statements.find(ts.isExportAssignment);
|
|
85
|
+
const object = exported === undefined ? undefined : objectOf(exported.expression);
|
|
86
|
+
if (object === undefined || object.properties.some(ts.isSpreadAssignment)) {
|
|
87
|
+
return Result.fail(
|
|
88
|
+
new MigrationFailure({
|
|
89
|
+
message: `Cannot migrate ${file} automatically. Export an object or defineConfig({ ... }) without spreads, then run quality exceptions migrate again.`,
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
return Result.map(Result.all(object.properties.map((property) => keptProperty(property, source, file, hasDeclarations))), (kept) => {
|
|
94
|
+
const properties = kept.flat();
|
|
95
|
+
const next = properties.map((property) => property.text);
|
|
96
|
+
const index = properties.findIndex((property) => property.name > "exceptions");
|
|
97
|
+
next.splice(index < 0 ? next.length : index, 0, `exceptions: ${JSON.stringify(exceptions, null, "\t")}`);
|
|
98
|
+
const replacement = `{\n${next.join(",\n")}\n}`;
|
|
99
|
+
return text.slice(0, object.getStart(source)) + replacement + text.slice(object.end);
|
|
58
100
|
});
|
|
59
|
-
const next = properties.map((property) => property.text);
|
|
60
|
-
const index = properties.findIndex((property) => property.name > "exceptions");
|
|
61
|
-
next.splice(index < 0 ? next.length : index, 0, `exceptions: ${JSON.stringify(exceptions, null, "\t")}`);
|
|
62
|
-
const replacement = `{\n${next.join(",\n")}\n}`;
|
|
63
|
-
return text.slice(0, object.getStart(source)) + replacement + text.slice(object.end);
|
|
64
101
|
}
|