@shivaedev/quality 0.76.0 → 0.77.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 +54 -0
- package/README.md +65 -59
- package/dist/adapters/biome/pluginContract.d.ts +1 -1
- package/dist/adapters/biome/pluginContract.d.ts.map +1 -1
- package/dist/adapters/biome/pluginContract.js +2 -5
- package/dist/adapters/biome/pluginContract.js.map +1 -1
- package/dist/adapters/biome/run.d.ts.map +1 -1
- package/dist/adapters/biome/run.js +2 -0
- package/dist/adapters/biome/run.js.map +1 -1
- package/dist/adapters/biome/withExceptionConfig.d.ts.map +1 -1
- package/dist/adapters/biome/withExceptionConfig.js +21 -4
- package/dist/adapters/biome/withExceptionConfig.js.map +1 -1
- package/dist/adapters/changeKeyCheck.d.ts +10 -0
- package/dist/adapters/changeKeyCheck.d.ts.map +1 -0
- package/dist/adapters/{changeKeyFindings.js → changeKeyCheck.js} +8 -22
- package/dist/adapters/changeKeyCheck.js.map +1 -0
- package/dist/adapters/commandLine.d.ts +2 -0
- package/dist/adapters/commandLine.d.ts.map +1 -1
- package/dist/adapters/contextCaptureCheck.d.ts +9 -0
- package/dist/adapters/contextCaptureCheck.d.ts.map +1 -0
- package/dist/adapters/contextCaptureCheck.js +91 -0
- package/dist/adapters/contextCaptureCheck.js.map +1 -0
- package/dist/adapters/databaseUrlFindings.d.ts +1 -1
- package/dist/adapters/databaseUrlFindings.d.ts.map +1 -1
- package/dist/adapters/declaration-files/initialize.d.ts +6 -0
- package/dist/adapters/declaration-files/initialize.d.ts.map +1 -0
- package/dist/adapters/declaration-files/initialize.js +4 -0
- package/dist/adapters/declaration-files/initialize.js.map +1 -0
- package/dist/adapters/declaration-files/parse.d.ts +5 -0
- package/dist/adapters/declaration-files/parse.d.ts.map +1 -0
- package/dist/adapters/declaration-files/parse.js +6 -0
- package/dist/adapters/declaration-files/parse.js.map +1 -0
- package/dist/adapters/declaration-files/reader.d.ts +5 -0
- package/dist/adapters/declaration-files/reader.d.ts.map +1 -0
- package/dist/adapters/declaration-files/reader.js +23 -0
- package/dist/adapters/declaration-files/reader.js.map +1 -0
- package/dist/adapters/declaration-files/service.d.ts +9 -0
- package/dist/adapters/declaration-files/service.d.ts.map +1 -0
- package/dist/adapters/declaration-files/service.js +14 -0
- package/dist/adapters/declaration-files/service.js.map +1 -0
- package/dist/adapters/foreignResources.d.ts.map +1 -1
- package/dist/adapters/foreignResources.js +0 -4
- package/dist/adapters/foreignResources.js.map +1 -1
- package/dist/adapters/import-compiler/graph.d.ts +8 -2
- package/dist/adapters/import-compiler/graph.d.ts.map +1 -1
- package/dist/adapters/import-compiler/graph.js +4 -1
- package/dist/adapters/import-compiler/graph.js.map +1 -1
- package/dist/adapters/import-compiler/service.d.ts +7 -1
- package/dist/adapters/import-compiler/service.d.ts.map +1 -1
- package/dist/adapters/imports/graph.d.ts +6 -3
- package/dist/adapters/imports/graph.d.ts.map +1 -1
- package/dist/adapters/imports/graph.js +31 -18
- package/dist/adapters/imports/graph.js.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 +6 -4
- 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.map +1 -1
- package/dist/adapters/knip/run.js +4 -1
- package/dist/adapters/knip/run.js.map +1 -1
- package/dist/adapters/outsideImportFindings.d.ts +4 -2
- package/dist/adapters/outsideImportFindings.d.ts.map +1 -1
- package/dist/adapters/outsideImportFindings.js +12 -52
- 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/rule.d.ts +9 -1
- package/dist/adapters/rule.d.ts.map +1 -1
- package/dist/adapters/rule.js +21 -6
- package/dist/adapters/rule.js.map +1 -1
- package/dist/adapters/runMain.d.ts +3 -4
- package/dist/adapters/runMain.d.ts.map +1 -1
- package/dist/adapters/runMain.js +2 -1
- package/dist/adapters/runMain.js.map +1 -1
- package/dist/adapters/serviceModelCheck.d.ts +9 -0
- package/dist/adapters/serviceModelCheck.d.ts.map +1 -0
- package/dist/adapters/{serviceModelFindings.js → serviceModelCheck.js} +9 -23
- package/dist/adapters/serviceModelCheck.js.map +1 -0
- package/dist/adapters/sharedErrorCatalog.d.ts +13 -0
- package/dist/adapters/sharedErrorCatalog.d.ts.map +1 -0
- package/dist/adapters/sharedErrorCatalog.js +28 -0
- package/dist/adapters/sharedErrorCatalog.js.map +1 -0
- package/dist/adapters/sharedErrorModules.d.ts +1 -1
- package/dist/adapters/sharedErrorModules.d.ts.map +1 -1
- package/dist/adapters/sharedErrorModules.js.map +1 -1
- package/dist/adapters/specReaderSources.d.ts +3 -2
- package/dist/adapters/specReaderSources.d.ts.map +1 -1
- package/dist/adapters/specReaderSources.js +6 -3
- package/dist/adapters/specReaderSources.js.map +1 -1
- package/dist/adapters/storyProgram.d.ts +2 -0
- package/dist/adapters/storyProgram.d.ts.map +1 -1
- package/dist/adapters/storyProgram.js +13 -3
- package/dist/adapters/storyProgram.js.map +1 -1
- package/dist/adapters/typeScriptProgram.d.ts +5 -0
- package/dist/adapters/typeScriptProgram.d.ts.map +1 -0
- package/dist/adapters/typeScriptProgram.js +43 -0
- package/dist/adapters/typeScriptProgram.js.map +1 -0
- package/dist/baseline/compare.d.ts +2 -0
- package/dist/baseline/compare.d.ts.map +1 -1
- package/dist/baseline/compare.js +43 -17
- package/dist/baseline/compare.js.map +1 -1
- package/dist/baseline/format.d.ts +1 -0
- package/dist/baseline/format.d.ts.map +1 -1
- package/dist/baseline/format.js +6 -2
- package/dist/baseline/format.js.map +1 -1
- package/dist/baseline/merge.d.ts.map +1 -1
- package/dist/baseline/merge.js +14 -1
- package/dist/baseline/merge.js.map +1 -1
- package/dist/baseline/rewrite.d.ts.map +1 -1
- package/dist/baseline/rewrite.js +3 -1
- package/dist/baseline/rewrite.js.map +1 -1
- package/dist/baseline/update.d.ts +7 -0
- package/dist/baseline/update.d.ts.map +1 -1
- package/dist/baseline/update.js +29 -8
- package/dist/baseline/update.js.map +1 -1
- package/dist/biome/exceptionConfig.d.ts +3 -0
- package/dist/biome/exceptionConfig.d.ts.map +1 -1
- package/dist/biome/exceptionConfig.js +15 -1
- package/dist/biome/exceptionConfig.js.map +1 -1
- package/dist/biome/scannerRules.d.ts +3 -0
- package/dist/biome/scannerRules.d.ts.map +1 -0
- package/dist/biome/scannerRules.js +42 -0
- package/dist/biome/scannerRules.js.map +1 -0
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +10 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/baseline.d.ts.map +1 -1
- package/dist/cli/baseline.js +5 -1
- package/dist/cli/baseline.js.map +1 -1
- package/dist/cli/lint.d.ts +3 -2
- package/dist/cli/lint.d.ts.map +1 -1
- package/dist/cli/lint.js +13 -5
- package/dist/cli/lint.js.map +1 -1
- package/dist/cli/misplaced.d.ts +6 -0
- package/dist/cli/misplaced.d.ts.map +1 -1
- package/dist/cli/misplaced.js +4 -2
- package/dist/cli/misplaced.js.map +1 -1
- package/dist/cli/program.js +1 -1
- package/dist/cli/program.js.map +1 -1
- package/dist/cli/runSet.d.ts +5 -0
- package/dist/cli/runSet.d.ts.map +1 -0
- package/dist/cli/runSet.js +15 -0
- package/dist/cli/runSet.js.map +1 -0
- package/dist/cli/shrink.d.ts +4 -4
- package/dist/cli/shrink.d.ts.map +1 -1
- package/dist/cli/shrink.js.map +1 -1
- package/dist/cli/usage.d.ts +1 -1
- package/dist/cli/usage.d.ts.map +1 -1
- package/dist/cli/usage.js +7 -2
- package/dist/cli/usage.js.map +1 -1
- package/dist/config/decode.d.ts +1 -0
- package/dist/config/decode.d.ts.map +1 -1
- package/dist/config/decode.js +1 -0
- package/dist/config/decode.js.map +1 -1
- package/dist/config/load.d.ts +2 -0
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +1 -0
- package/dist/config/load.js.map +1 -1
- package/dist/config/resolve.d.ts +2 -1
- package/dist/config/resolve.d.ts.map +1 -1
- package/dist/config/resolve.js +9 -4
- package/dist/config/resolve.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/engine/childStarted.d.ts +4 -0
- package/dist/engine/childStarted.d.ts.map +1 -0
- package/dist/engine/childStarted.js +7 -0
- package/dist/engine/childStarted.js.map +1 -0
- package/dist/engine/evaluate.d.ts +1 -0
- package/dist/engine/evaluate.d.ts.map +1 -1
- package/dist/engine/evaluate.js +2 -1
- package/dist/engine/evaluate.js.map +1 -1
- package/dist/engine/runRule.d.ts +21 -0
- package/dist/engine/runRule.d.ts.map +1 -0
- package/dist/engine/runRule.js +70 -0
- package/dist/engine/runRule.js.map +1 -0
- package/dist/engine/runRules.d.ts +5 -12
- package/dist/engine/runRules.d.ts.map +1 -1
- package/dist/engine/runRules.js +49 -65
- package/dist/engine/runRules.js.map +1 -1
- package/dist/engine/session.d.ts +2 -1
- package/dist/engine/session.d.ts.map +1 -1
- package/dist/engine/session.js +20 -6
- package/dist/engine/session.js.map +1 -1
- package/dist/engine/violation.d.ts +7 -0
- package/dist/engine/violation.d.ts.map +1 -1
- package/dist/engine/violation.js +9 -0
- package/dist/engine/violation.js.map +1 -1
- package/dist/exceptions/biomeFindings.d.ts +5 -1
- package/dist/exceptions/biomeFindings.d.ts.map +1 -1
- package/dist/exceptions/biomeFindings.js +17 -18
- package/dist/exceptions/biomeFindings.js.map +1 -1
- package/dist/exceptions/registry.d.ts.map +1 -1
- package/dist/exceptions/registry.js +2 -2
- package/dist/exceptions/registry.js.map +1 -1
- package/dist/hooks/preCommit.d.ts +1 -2
- package/dist/hooks/preCommit.d.ts.map +1 -1
- package/dist/hooks/preCommit.js +11 -1
- package/dist/hooks/preCommit.js.map +1 -1
- package/dist/hooks/stagedCheck.d.ts +5 -0
- package/dist/hooks/stagedCheck.d.ts.map +1 -0
- package/dist/hooks/stagedCheck.js +43 -0
- package/dist/hooks/stagedCheck.js.map +1 -0
- package/dist/hooks/withStagedContent.d.ts +5 -0
- package/dist/hooks/withStagedContent.d.ts.map +1 -0
- package/dist/hooks/withStagedContent.js +84 -0
- package/dist/hooks/withStagedContent.js.map +1 -0
- package/dist/imports/browserGlobals.d.ts +1 -1
- package/dist/imports/browserGlobals.d.ts.map +1 -1
- package/dist/imports/browserNames.d.ts +1 -1
- package/dist/imports/browserNames.d.ts.map +1 -1
- package/dist/imports/browserNames.js +5 -3
- package/dist/imports/browserNames.js.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/compilePolicy.js +1 -1
- package/dist/imports/fences/compilePolicy.js.map +1 -1
- package/dist/imports/fences/evaluate.d.ts +1 -1
- package/dist/imports/fences/evaluate.d.ts.map +1 -1
- package/dist/imports/fences/evaluate.js +1 -1
- package/dist/imports/fences/evaluate.js.map +1 -1
- package/dist/imports/graph.d.ts +6 -1
- package/dist/imports/graph.d.ts.map +1 -1
- package/dist/imports/graph.js +30 -2
- package/dist/imports/graph.js.map +1 -1
- package/dist/imports/withoutGenerated.js +1 -1
- package/dist/imports/withoutGenerated.js.map +1 -1
- package/dist/inventory/programmaticBuilds.d.ts +1 -1
- package/dist/inventory/programmaticBuilds.d.ts.map +1 -1
- package/dist/inventory/trackedPaths.d.ts +1 -0
- package/dist/inventory/trackedPaths.d.ts.map +1 -1
- package/dist/inventory/trackedPaths.js +9 -3
- package/dist/inventory/trackedPaths.js.map +1 -1
- package/dist/naming/testCode.d.ts +1 -1
- package/dist/naming/testCode.d.ts.map +1 -1
- package/dist/report/render.d.ts +1 -0
- package/dist/report/render.d.ts.map +1 -1
- package/dist/report/render.js +10 -3
- package/dist/report/render.js.map +1 -1
- package/dist/report/runSetLine.d.ts +3 -0
- package/dist/report/runSetLine.d.ts.map +1 -0
- package/dist/report/runSetLine.js +13 -0
- package/dist/report/runSetLine.js.map +1 -0
- package/dist/report/staleSections.d.ts.map +1 -1
- package/dist/report/staleSections.js +13 -0
- package/dist/report/staleSections.js.map +1 -1
- package/dist/rule.d.ts +30 -4
- package/dist/rule.d.ts.map +1 -1
- package/dist/rule.js +4 -2
- package/dist/rule.js.map +1 -1
- package/dist/rules/biome.d.ts +18 -1
- package/dist/rules/biome.d.ts.map +1 -1
- package/dist/rules/biome.js +32 -7
- package/dist/rules/biome.js.map +1 -1
- package/dist/rules/builtIn.d.ts +8 -8
- package/dist/rules/builtIn.d.ts.map +1 -1
- package/dist/rules/builtIn.js +0 -2
- package/dist/rules/builtIn.js.map +1 -1
- package/dist/rules/effect/adapterImports.d.ts +1 -1
- package/dist/rules/effect/adapterImports.d.ts.map +1 -1
- package/dist/rules/effect/adapterImports.js +1 -1
- package/dist/rules/effect/adapterImports.js.map +1 -1
- package/dist/rules/effect/boundary.d.ts +1 -1
- package/dist/rules/effect/boundary.d.ts.map +1 -1
- package/dist/rules/effect/boundary.js +60 -75
- package/dist/rules/effect/boundary.js.map +1 -1
- package/dist/rules/effect/boundaryFindings.d.ts +4 -0
- package/dist/rules/effect/boundaryFindings.d.ts.map +1 -0
- package/dist/rules/effect/boundaryFindings.js +63 -0
- package/dist/rules/effect/boundaryFindings.js.map +1 -0
- package/dist/rules/effect/boundaryReference.d.ts +4 -0
- package/dist/rules/effect/boundaryReference.d.ts.map +1 -1
- package/dist/rules/effect/boundaryReference.js +6 -3
- package/dist/rules/effect/boundaryReference.js.map +1 -1
- package/dist/rules/effect/contextCapture.d.ts.map +1 -1
- package/dist/rules/effect/contextCapture.js +3 -2
- package/dist/rules/effect/contextCapture.js.map +1 -1
- package/dist/rules/effect/errorTags.d.ts +10 -0
- package/dist/rules/effect/errorTags.d.ts.map +1 -0
- package/dist/rules/effect/errorTags.js +57 -0
- package/dist/rules/effect/errorTags.js.map +1 -0
- package/dist/rules/effect/failureHonesty.d.ts +1 -1
- package/dist/rules/effect/failureHonesty.d.ts.map +1 -1
- package/dist/rules/effect/failureHonesty.js +6 -5
- package/dist/rules/effect/failureHonesty.js.map +1 -1
- package/dist/rules/effect/policy.d.ts +1 -1
- package/dist/rules/effect/policy.d.ts.map +1 -1
- package/dist/rules/effect/policy.js +0 -2
- package/dist/rules/effect/policy.js.map +1 -1
- package/dist/rules/effect/promiseBridge.d.ts +3 -0
- package/dist/rules/effect/promiseBridge.d.ts.map +1 -0
- package/dist/rules/effect/promiseBridge.js +60 -0
- package/dist/rules/effect/promiseBridge.js.map +1 -0
- package/dist/rules/effect/rpcBoundary.d.ts.map +1 -1
- package/dist/rules/effect/rpcBoundary.js +92 -3
- package/dist/rules/effect/rpcBoundary.js.map +1 -1
- package/dist/rules/effect/serviceModel.d.ts.map +1 -1
- package/dist/rules/effect/serviceModel.js +3 -2
- package/dist/rules/effect/serviceModel.js.map +1 -1
- package/dist/rules/effect/serviceParameterCheck.d.ts +7 -0
- package/dist/rules/effect/serviceParameterCheck.d.ts.map +1 -0
- package/dist/rules/effect/serviceParameterCheck.js +15 -0
- package/dist/rules/effect/serviceParameterCheck.js.map +1 -0
- package/dist/rules/effect/serviceParameters.d.ts.map +1 -1
- package/dist/rules/effect/serviceParameters.js +4 -36
- package/dist/rules/effect/serviceParameters.js.map +1 -1
- package/dist/rules/effect/sharedErrorClasses.d.ts.map +1 -1
- package/dist/rules/effect/sharedErrorClasses.js +31 -2
- package/dist/rules/effect/sharedErrorClasses.js.map +1 -1
- package/dist/rules/effect/workspaceProgram.d.ts +5 -0
- package/dist/rules/effect/workspaceProgram.d.ts.map +1 -0
- package/dist/rules/effect/workspaceProgram.js +32 -0
- package/dist/rules/effect/workspaceProgram.js.map +1 -0
- package/dist/rules/imports/adminPaths.d.ts +1 -1
- package/dist/rules/imports/adminPaths.d.ts.map +1 -1
- package/dist/rules/imports/cycles.d.ts +1 -1
- package/dist/rules/imports/cycles.d.ts.map +1 -1
- package/dist/rules/imports/fences.d.ts +1 -1
- package/dist/rules/imports/fences.d.ts.map +1 -1
- package/dist/rules/imports/manifest.d.ts +1 -1
- package/dist/rules/imports/manifest.d.ts.map +1 -1
- package/dist/rules/imports/noTestCode.d.ts +1 -1
- package/dist/rules/imports/noTestCode.d.ts.map +1 -1
- package/dist/rules/imports/runtime.d.ts +1 -1
- package/dist/rules/imports/runtime.d.ts.map +1 -1
- package/dist/rules/imports/runtime.js +32 -5
- package/dist/rules/imports/runtime.js.map +1 -1
- package/dist/rules/manifestsNoTestKits.js +1 -1
- package/dist/rules/manifestsNoTestKits.js.map +1 -1
- package/dist/rules/maxLines.d.ts +1 -1
- package/dist/rules/maxLines.d.ts.map +1 -1
- package/dist/rules/packageFindings.d.ts +31 -0
- package/dist/rules/packageFindings.d.ts.map +1 -0
- package/dist/rules/packageFindings.js +65 -0
- package/dist/rules/packageFindings.js.map +1 -0
- package/dist/rules/parse.d.ts +4 -1
- package/dist/rules/parse.d.ts.map +1 -1
- package/dist/rules/parse.js +35 -2
- package/dist/rules/parse.js.map +1 -1
- package/dist/rules/rootedFindings.d.ts +5 -0
- package/dist/rules/rootedFindings.d.ts.map +1 -0
- package/dist/rules/rootedFindings.js +16 -0
- package/dist/rules/rootedFindings.js.map +1 -0
- package/dist/rules/stories/adapterOnlyFakes.d.ts +1 -1
- package/dist/rules/stories/adapterOnlyFakes.d.ts.map +1 -1
- package/dist/rules/stories/adapterOnlyFakes.js +1 -0
- package/dist/rules/stories/adapterOnlyFakes.js.map +1 -1
- package/dist/rules/stories/databaseUrl.d.ts +1 -1
- package/dist/rules/stories/databaseUrl.d.ts.map +1 -1
- package/dist/rules/stories/databaseUrl.js +1 -0
- package/dist/rules/stories/databaseUrl.js.map +1 -1
- package/dist/rules/stories/domainOutcomes.d.ts +1 -1
- package/dist/rules/stories/domainOutcomes.d.ts.map +1 -1
- package/dist/rules/stories/domainOutcomes.js +1 -0
- package/dist/rules/stories/domainOutcomes.js.map +1 -1
- package/dist/rules/stories/engine.d.ts +1 -1
- package/dist/rules/stories/engine.d.ts.map +1 -1
- package/dist/rules/stories/engine.js +1 -0
- package/dist/rules/stories/engine.js.map +1 -1
- package/dist/rules/stories/globalRetries.d.ts +1 -1
- package/dist/rules/stories/globalRetries.d.ts.map +1 -1
- package/dist/rules/stories/globalRetries.js +1 -0
- package/dist/rules/stories/globalRetries.js.map +1 -1
- package/dist/rules/stories/groupedOutcomes.d.ts +1 -1
- package/dist/rules/stories/groupedOutcomes.d.ts.map +1 -1
- package/dist/rules/stories/groupedOutcomes.js +1 -0
- package/dist/rules/stories/groupedOutcomes.js.map +1 -1
- package/dist/rules/stories/importedChangeKeys.js +2 -2
- package/dist/rules/stories/importedChangeKeys.js.map +1 -1
- package/dist/rules/stories/namedValues.d.ts +1 -1
- package/dist/rules/stories/namedValues.d.ts.map +1 -1
- package/dist/rules/stories/namedValues.js +1 -0
- package/dist/rules/stories/namedValues.js.map +1 -1
- package/dist/rules/stories/noExpect.d.ts +1 -1
- package/dist/rules/stories/noExpect.d.ts.map +1 -1
- package/dist/rules/stories/noLimitImports.d.ts +1 -1
- package/dist/rules/stories/noLimitImports.d.ts.map +1 -1
- package/dist/rules/stories/noLimitImports.js +1 -0
- package/dist/rules/stories/noLimitImports.js.map +1 -1
- package/dist/rules/stories/positiveRefusals.d.ts +1 -1
- package/dist/rules/stories/positiveRefusals.d.ts.map +1 -1
- package/dist/rules/stories/positiveRefusals.js +1 -0
- package/dist/rules/stories/positiveRefusals.js.map +1 -1
- package/dist/rules/stories/queueReadouts.d.ts +1 -1
- package/dist/rules/stories/queueReadouts.d.ts.map +1 -1
- package/dist/rules/stories/queueReadouts.js +1 -0
- package/dist/rules/stories/queueReadouts.js.map +1 -1
- package/dist/rules/stories/sources.d.ts +2 -2
- package/dist/rules/stories/sources.d.ts.map +1 -1
- package/dist/rules/stories/specHelpers.d.ts +1 -1
- package/dist/rules/stories/specHelpers.d.ts.map +1 -1
- package/dist/rules/stories/specHelpers.js +3 -2
- package/dist/rules/stories/specHelpers.js.map +1 -1
- package/dist/rules/stories/specs.d.ts +1 -1
- package/dist/rules/stories/specs.d.ts.map +1 -1
- package/dist/rules/stories/specs.js +1 -0
- package/dist/rules/stories/specs.js.map +1 -1
- package/dist/rules/stories/waitOnEvents.d.ts +1 -1
- package/dist/rules/stories/waitOnEvents.d.ts.map +1 -1
- package/dist/rules/stories/waitOnEvents.js +3 -3
- package/dist/rules/stories/waitOnEvents.js.map +1 -1
- package/dist/rules/suppressions/noDoubleCast.d.ts.map +1 -1
- package/dist/rules/suppressions/noDoubleCast.js +4 -49
- package/dist/rules/suppressions/noDoubleCast.js.map +1 -1
- package/dist/rules/suppressions/typedCastCheck.d.ts +10 -0
- package/dist/rules/suppressions/typedCastCheck.d.ts.map +1 -0
- package/dist/rules/suppressions/typedCastCheck.js +48 -0
- package/dist/rules/suppressions/typedCastCheck.js.map +1 -0
- package/dist/rules/unusedCode.d.ts.map +1 -1
- package/dist/rules/unusedCode.js +1 -0
- package/dist/rules/unusedCode.js.map +1 -1
- package/dist/testing/adapters/cli.d.ts +1 -0
- package/dist/testing/adapters/cli.d.ts.map +1 -1
- package/dist/testing/adapters/cli.js +10 -8
- package/dist/testing/adapters/cli.js.map +1 -1
- package/dist/testing/adapters/git.d.ts +1 -16
- package/dist/testing/adapters/git.d.ts.map +1 -1
- package/dist/testing/adapters/git.js +5 -10
- package/dist/testing/adapters/git.js.map +1 -1
- package/dist/testing/adapters/hookRepository.d.ts +3 -2
- package/dist/testing/adapters/hookRepository.d.ts.map +1 -1
- package/dist/testing/adapters/hookRepository.js +11 -8
- package/dist/testing/adapters/hookRepository.js.map +1 -1
- package/dist/testing/adapters/imports.d.ts.map +1 -1
- package/dist/testing/adapters/imports.js +4 -1
- package/dist/testing/adapters/imports.js.map +1 -1
- package/dist/testing/ruleStory.d.ts +1 -1
- package/dist/testing/ruleStory.js +2 -2
- package/dist/testing/ruleStory.js.map +1 -1
- package/docs/debt-and-hooks.md +5 -3
- package/package.json +19 -19
- package/src/adapters/biome/pluginContract.ts +2 -5
- package/src/adapters/biome/run.ts +2 -0
- package/src/adapters/biome/withExceptionConfig.ts +26 -5
- package/src/adapters/{changeKeyFindings.ts → changeKeyCheck.ts} +8 -24
- package/src/adapters/contextCaptureCheck.ts +106 -0
- package/src/adapters/declaration-files/initialize.ts +4 -0
- package/src/adapters/declaration-files/parse.ts +9 -0
- package/src/adapters/declaration-files/reader.ts +28 -0
- package/src/adapters/declaration-files/service.ts +16 -0
- package/src/adapters/foreignResources.ts +0 -4
- package/src/adapters/import-compiler/graph.ts +7 -2
- package/src/adapters/imports/graph.ts +43 -18
- package/src/adapters/knip/configuration.ts +6 -4
- package/src/adapters/knip/run.ts +4 -1
- package/src/adapters/outsideImportFindings.ts +21 -65
- package/src/adapters/rule.ts +29 -6
- package/src/adapters/runMain.ts +7 -6
- package/src/adapters/{serviceModelFindings.ts → serviceModelCheck.ts} +10 -25
- package/src/adapters/sharedErrorCatalog.ts +43 -0
- package/src/adapters/sharedErrorModules.ts +1 -1
- package/src/adapters/specReaderSources.ts +6 -3
- package/src/adapters/storyProgram.ts +20 -3
- package/src/adapters/typeScriptProgram.ts +57 -0
- package/src/baseline/compare.ts +59 -19
- package/src/baseline/format.ts +7 -2
- package/src/baseline/merge.ts +15 -1
- package/src/baseline/rewrite.ts +3 -1
- package/src/baseline/update.ts +38 -8
- package/src/biome/exceptionConfig.ts +24 -3
- package/src/biome/scannerRules.ts +42 -0
- package/src/cli/args.ts +13 -2
- package/src/cli/baseline.ts +7 -1
- package/src/cli/lint.ts +14 -6
- package/src/cli/misplaced.ts +4 -2
- package/src/cli/program.ts +1 -1
- package/src/cli/runSet.ts +17 -0
- package/src/cli/shrink.ts +4 -11
- package/src/cli/usage.ts +7 -2
- package/src/config/decode.ts +1 -0
- package/src/config/load.ts +3 -0
- package/src/config/resolve.ts +11 -6
- package/src/config.ts +3 -0
- package/src/engine/childStarted.ts +8 -0
- package/src/engine/evaluate.ts +3 -1
- package/src/engine/runRule.ts +103 -0
- package/src/engine/runRules.ts +64 -86
- package/src/engine/session.ts +23 -5
- package/src/engine/violation.ts +16 -0
- package/src/exceptions/biomeFindings.ts +24 -21
- package/src/exceptions/registry.ts +2 -2
- package/src/hooks/preCommit.ts +15 -1
- package/src/hooks/stagedCheck.ts +54 -0
- package/src/hooks/withStagedContent.ts +111 -0
- package/src/imports/browserNames.ts +7 -5
- package/src/imports/fences/compilePolicy.ts +1 -1
- package/src/imports/fences/evaluate.ts +2 -2
- package/src/imports/graph.ts +47 -3
- package/src/imports/withoutGenerated.ts +1 -1
- package/src/inventory/trackedPaths.ts +10 -3
- package/src/report/render.ts +12 -3
- package/src/report/runSetLine.ts +14 -0
- package/src/report/staleSections.ts +14 -0
- package/src/rule.ts +38 -7
- package/src/rules/biome.ts +53 -7
- package/src/rules/builtIn.ts +0 -2
- package/src/rules/effect/adapterImports.ts +1 -1
- package/src/rules/effect/boundary.ts +82 -83
- package/src/rules/effect/boundaryFindings.ts +71 -0
- package/src/rules/effect/boundaryReference.ts +7 -3
- package/src/rules/effect/contextCapture.ts +3 -2
- package/src/rules/effect/errorTags.ts +72 -0
- package/src/rules/effect/failureHonesty.ts +9 -5
- package/src/rules/effect/policy.ts +0 -2
- package/src/rules/effect/promiseBridge.ts +65 -0
- package/src/rules/effect/rpcBoundary.ts +111 -4
- package/src/rules/effect/serviceModel.ts +3 -2
- package/src/rules/effect/serviceParameterCheck.ts +22 -0
- package/src/rules/effect/serviceParameters.ts +5 -37
- package/src/rules/effect/sharedErrorClasses.ts +41 -3
- package/src/rules/effect/workspaceProgram.ts +34 -0
- package/src/rules/imports/runtime.ts +43 -6
- package/src/rules/manifestsNoTestKits.ts +1 -1
- package/src/rules/packageFindings.ts +103 -0
- package/src/rules/parse.ts +54 -3
- package/src/rules/rootedFindings.ts +19 -0
- package/src/rules/stories/adapterOnlyFakes.ts +1 -0
- package/src/rules/stories/databaseUrl.ts +1 -0
- package/src/rules/stories/domainOutcomes.ts +1 -0
- package/src/rules/stories/engine.ts +1 -0
- package/src/rules/stories/globalRetries.ts +1 -0
- package/src/rules/stories/groupedOutcomes.ts +1 -0
- package/src/rules/stories/importedChangeKeys.ts +2 -2
- package/src/rules/stories/namedValues.ts +1 -0
- package/src/rules/stories/noLimitImports.ts +1 -0
- package/src/rules/stories/positiveRefusals.ts +1 -0
- package/src/rules/stories/queueReadouts.ts +1 -0
- package/src/rules/stories/specHelpers.ts +8 -5
- package/src/rules/stories/specs.ts +1 -0
- package/src/rules/stories/waitOnEvents.ts +6 -3
- package/src/rules/suppressions/noDoubleCast.ts +5 -55
- package/src/rules/suppressions/typedCastCheck.ts +55 -0
- package/src/rules/unusedCode.ts +1 -0
- package/src/testing/adapters/cli.ts +13 -9
- package/src/testing/adapters/git.ts +6 -11
- package/src/testing/adapters/hookRepository.ts +12 -7
- package/src/testing/adapters/imports.ts +4 -1
- package/src/testing/ruleStory.ts +2 -2
- package/dist/adapters/biome/presetConfig.d.ts +0 -21
- package/dist/adapters/biome/presetConfig.d.ts.map +0 -1
- package/dist/adapters/biome/presetConfig.js +0 -32
- package/dist/adapters/biome/presetConfig.js.map +0 -1
- package/dist/adapters/changeKeyFindings.d.ts +0 -4
- package/dist/adapters/changeKeyFindings.d.ts.map +0 -1
- package/dist/adapters/changeKeyFindings.js.map +0 -1
- package/dist/adapters/contextCaptureFindings.d.ts +0 -4
- package/dist/adapters/contextCaptureFindings.d.ts.map +0 -1
- package/dist/adapters/contextCaptureFindings.js +0 -51
- package/dist/adapters/contextCaptureFindings.js.map +0 -1
- package/dist/adapters/nativeTransactionFindings.d.ts +0 -4
- package/dist/adapters/nativeTransactionFindings.d.ts.map +0 -1
- package/dist/adapters/nativeTransactionFindings.js +0 -98
- package/dist/adapters/nativeTransactionFindings.js.map +0 -1
- package/dist/adapters/rpcBoundaryFindings.d.ts +0 -4
- package/dist/adapters/rpcBoundaryFindings.d.ts.map +0 -1
- package/dist/adapters/rpcBoundaryFindings.js +0 -90
- package/dist/adapters/rpcBoundaryFindings.js.map +0 -1
- package/dist/adapters/serviceModelFindings.d.ts +0 -4
- package/dist/adapters/serviceModelFindings.d.ts.map +0 -1
- package/dist/adapters/serviceModelFindings.js.map +0 -1
- package/dist/adapters/sharedErrorFindings.d.ts +0 -4
- package/dist/adapters/sharedErrorFindings.d.ts.map +0 -1
- package/dist/adapters/sharedErrorFindings.js +0 -71
- package/dist/adapters/sharedErrorFindings.js.map +0 -1
- package/dist/adapters/transactionChanges.d.ts +0 -3
- package/dist/adapters/transactionChanges.d.ts.map +0 -1
- package/dist/adapters/transactionChanges.js +0 -81
- package/dist/adapters/transactionChanges.js.map +0 -1
- package/dist/adapters/vitePort.d.ts +0 -2
- package/dist/adapters/vitePort.d.ts.map +0 -1
- package/dist/adapters/vitePort.js +0 -5
- package/dist/adapters/vitePort.js.map +0 -1
- package/dist/appTestConfig.d.ts +0 -4
- package/dist/appTestConfig.d.ts.map +0 -1
- package/dist/appTestConfig.js +0 -9
- package/dist/appTestConfig.js.map +0 -1
- package/dist/appViteConfig.d.ts +0 -23
- package/dist/appViteConfig.d.ts.map +0 -1
- package/dist/appViteConfig.js +0 -17
- package/dist/appViteConfig.js.map +0 -1
- package/dist/biome/recommendedRules.d.ts +0 -3
- package/dist/biome/recommendedRules.d.ts.map +0 -1
- package/dist/biome/recommendedRules.js +0 -20
- package/dist/biome/recommendedRules.js.map +0 -1
- package/dist/rules/effect/program.d.ts +0 -8
- package/dist/rules/effect/program.d.ts.map +0 -1
- package/dist/rules/effect/program.js +0 -53
- package/dist/rules/effect/program.js.map +0 -1
- package/dist/rules/effect/sqlTransact.d.ts +0 -2
- package/dist/rules/effect/sqlTransact.d.ts.map +0 -1
- package/dist/rules/effect/sqlTransact.js +0 -9
- package/dist/rules/effect/sqlTransact.js.map +0 -1
- package/dist/rules/suppressions/biomeRecommended.d.ts +0 -7
- package/dist/rules/suppressions/biomeRecommended.d.ts.map +0 -1
- package/dist/rules/suppressions/biomeRecommended.js +0 -47
- package/dist/rules/suppressions/biomeRecommended.js.map +0 -1
- package/src/adapters/biome/presetConfig.ts +0 -34
- package/src/adapters/contextCaptureFindings.ts +0 -60
- package/src/adapters/nativeTransactionFindings.ts +0 -108
- package/src/adapters/rpcBoundaryFindings.ts +0 -98
- package/src/adapters/sharedErrorFindings.ts +0 -84
- package/src/adapters/transactionChanges.ts +0 -85
- package/src/adapters/vitePort.ts +0 -5
- package/src/appTestConfig.ts +0 -10
- package/src/appViteConfig.ts +0 -24
- package/src/biome/recommendedRules.ts +0 -27
- package/src/rules/effect/program.ts +0 -57
- package/src/rules/effect/sqlTransact.ts +0 -10
- package/src/rules/suppressions/biomeRecommended.ts +0 -60
package/src/engine/runRules.ts
CHANGED
|
@@ -1,99 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import type {
|
|
6
|
-
import { SetupFailure } from "#failure.ts";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
1
|
+
import { Deferred, Effect, Fiber } from "effect";
|
|
2
|
+
import { withStoryProgram } from "#adapters/storyProgram.ts";
|
|
3
|
+
import { ChildStarted } from "#engine/childStarted.ts";
|
|
4
|
+
import { type ActiveRule, runRule } from "#engine/runRule.ts";
|
|
5
|
+
import type { Violation } from "#engine/violation.ts";
|
|
6
|
+
import type { SetupFailure } from "#failure.ts";
|
|
7
|
+
import type { RuleInputs, RuleServices } from "#rule.ts";
|
|
8
|
+
import { PACKAGE_CHECKS, withPackageWalk } from "#rules/packageFindings.ts";
|
|
9
|
+
import { withSharedTrees } from "#rules/parse.ts";
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
readonly check: RuleCheck;
|
|
13
|
-
readonly description: string;
|
|
14
|
-
readonly family: boolean;
|
|
15
|
-
readonly id: string;
|
|
16
|
-
readonly level: ActiveLevel;
|
|
17
|
-
readonly registrable?: boolean;
|
|
18
|
-
}
|
|
11
|
+
type RuleRun = Effect.Effect<readonly Violation[], SetupFailure, RuleServices>;
|
|
19
12
|
|
|
20
|
-
function
|
|
21
|
-
return
|
|
13
|
+
function spawnsChild(rule: ActiveRule): boolean {
|
|
14
|
+
return rule.needs === "child-process";
|
|
22
15
|
}
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
17
|
+
const launched = Effect.fn("Engine.launched")(function* (child: RuleRun) {
|
|
18
|
+
const running = yield* Deferred.make<void>();
|
|
19
|
+
const fiber = yield* Effect.forkChild(Effect.provideService(child, ChildStarted, Deferred.succeed(running, undefined).pipe(Effect.asVoid)));
|
|
20
|
+
return { fiber, started: Effect.raceFirst(Deferred.await(running), Fiber.await(fiber)) };
|
|
21
|
+
});
|
|
28
22
|
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
const biome = /^biome\/(?:lint|assist)\/[a-zA-Z]+\/[a-zA-Z]+$/u.test(id);
|
|
32
|
-
if (!biome && rule.registrable === false) {
|
|
33
|
-
return "";
|
|
34
|
-
}
|
|
35
|
-
const shape = JSON.stringify({
|
|
36
|
-
files: [file],
|
|
37
|
-
reason: "Explain why this exception is permanent.",
|
|
38
|
-
rules: [id],
|
|
39
|
-
...(!rule.family && finding.subject !== undefined ? { subject: finding.subject } : {}),
|
|
40
|
-
});
|
|
41
|
-
return ` For a permanent exception, add to exceptions in ${config}: ${shape}.`;
|
|
23
|
+
function readsStories(rule: ActiveRule): boolean {
|
|
24
|
+
return rule.needs === "story-program";
|
|
42
25
|
}
|
|
43
26
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
level: rule.level,
|
|
49
|
-
message: finding.message + exceptionHint(rule, finding, repositoryPath(root, finding.file), exceptionFile),
|
|
50
|
-
rule: rule.family && finding.subject !== undefined ? `${rule.id}/${finding.subject}` : rule.id,
|
|
51
|
-
};
|
|
27
|
+
// A full run checks a rule's deep half as a run of its own in the deep tier; only that half reads the package walk.
|
|
28
|
+
function runsOf(rule: ActiveRule, skippedHalves: ReadonlySet<string>): readonly ActiveRule[] {
|
|
29
|
+
const { deepHalf, ...whole } = rule;
|
|
30
|
+
return deepHalf === undefined || skippedHalves.has(rule.id) ? [rule] : [rule, { ...whole, check: deepHalf.check, depth: "deep", half: "deep" }];
|
|
52
31
|
}
|
|
53
32
|
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
const manifest = cause instanceof ManifestFailure || basename(cause.path) === "package.json";
|
|
57
|
-
return [
|
|
58
|
-
{
|
|
59
|
-
file: repositoryPath(root, cause.path),
|
|
60
|
-
level: rule.level,
|
|
61
|
-
message: cause.message,
|
|
62
|
-
rule: manifest ? "manifests/valid" : rule.id,
|
|
63
|
-
},
|
|
64
|
-
];
|
|
65
|
-
}
|
|
66
|
-
return undefined;
|
|
33
|
+
function walks(rule: ActiveRule): boolean {
|
|
34
|
+
return PACKAGE_CHECKS.has(rule.id) && rule.deepHalf === undefined;
|
|
67
35
|
}
|
|
68
36
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
37
|
+
// Rules share one Node thread, so only the Biome and Knip child processes run beside the other rules, started first because synchronous rules would starve their preparation; a check that never reports its child as started finishes first. Each type-checker program, the package walk's included, is built alone.
|
|
38
|
+
// The rules that read the story program, which spans every source, run one after another so the run drops it after the last of them; they and the program share one tree per source, which goes with the program because keeping the trees for every rule raised the peak.
|
|
39
|
+
function runTiers(rules: readonly ActiveRule[], inputs: RuleInputs): RuleRun {
|
|
40
|
+
function run(rule: ActiveRule): RuleRun {
|
|
41
|
+
return runRule(rule, inputs, inputs.configFile ?? "quality.config.ts");
|
|
42
|
+
}
|
|
43
|
+
const walked = rules.filter(walks);
|
|
44
|
+
const inThread = rules.filter((rule) => !(walks(rule) || spawnsChild(rule) || readsStories(rule)));
|
|
45
|
+
const stories = rules.filter(readsStories).map(run);
|
|
46
|
+
const told =
|
|
47
|
+
stories.length === 0 ? [] : [Effect.map(withSharedTrees(inputs, withStoryProgram(inputs, Effect.all(stories))), (found) => found.flat())];
|
|
48
|
+
const fast = [...inThread.filter((rule) => rule.depth === "fast").map(run), ...told];
|
|
49
|
+
const deep = inThread.filter((rule) => rule.depth === "deep").map(run);
|
|
50
|
+
function lanes(thread: readonly RuleRun[]): RuleRun {
|
|
51
|
+
return Effect.gen(function* () {
|
|
52
|
+
const children = yield* Effect.forEach(rules.filter(spawnsChild).map(run), launched);
|
|
53
|
+
yield* Effect.forEach(children, ({ started }) => started, { concurrency: "unbounded" });
|
|
54
|
+
const inOrder = yield* Effect.all(thread);
|
|
55
|
+
return [...(yield* Effect.forEach(children, ({ fiber }) => Fiber.join(fiber))).flat(), ...inOrder.flat()];
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (walked.length === 0) {
|
|
59
|
+
return lanes([...fast, ...deep]);
|
|
60
|
+
}
|
|
61
|
+
return withPackageWalk(inputs, new Set(walked.map((rule) => rule.id)), (walk) =>
|
|
62
|
+
Effect.map(
|
|
63
|
+
Effect.all([lanes([Effect.as(walk, []), ...fast, ...deep]), Effect.all(walked.map(run), { concurrency: "unbounded" })], {
|
|
64
|
+
concurrency: "unbounded",
|
|
65
|
+
}),
|
|
66
|
+
([laned, waited]) => [...laned, ...waited.flat()],
|
|
78
67
|
),
|
|
79
|
-
Effect.catch((cause) => {
|
|
80
|
-
const findings = expectedFailure(rule, inputs.root, cause);
|
|
81
|
-
if (findings !== undefined) {
|
|
82
|
-
return Effect.succeed(findings);
|
|
83
|
-
}
|
|
84
|
-
if (cause instanceof SetupFailure) {
|
|
85
|
-
return Effect.fail(new SetupFailure({ cause, message: `rule ${rule.id} failed: ${cause.message}` }));
|
|
86
|
-
}
|
|
87
|
-
return Effect.die(cause);
|
|
88
|
-
}),
|
|
89
|
-
Effect.catchDefect((cause) => {
|
|
90
|
-
const findings = expectedFailure(rule, inputs.root, cause);
|
|
91
|
-
return findings === undefined ? Effect.die(new Error(`rule ${rule.id} failed: ${messageOf(cause)}`, { cause })) : Effect.succeed(findings);
|
|
92
|
-
}),
|
|
93
68
|
);
|
|
94
69
|
}
|
|
95
70
|
|
|
96
|
-
export const runRules = Effect.fn("Engine.runRules")(function* (
|
|
71
|
+
export const runRules = Effect.fn("Engine.runRules")(function* (
|
|
72
|
+
rules: readonly ActiveRule[],
|
|
73
|
+
inputs: RuleInputs,
|
|
74
|
+
skippedHalves: ReadonlySet<string> = new Set(),
|
|
75
|
+
) {
|
|
97
76
|
const validation = rules.find((rule) => rule.id === "manifests/valid");
|
|
98
77
|
if (validation !== undefined) {
|
|
99
78
|
const failures = yield* runRule(validation, inputs, inputs.configFile ?? "quality.config.ts");
|
|
@@ -101,13 +80,12 @@ export const runRules = Effect.fn("Engine.runRules")(function* (rules: readonly
|
|
|
101
80
|
return failures;
|
|
102
81
|
}
|
|
103
82
|
}
|
|
104
|
-
const results = yield*
|
|
105
|
-
rules.filter((rule) => rule !== validation),
|
|
106
|
-
|
|
107
|
-
{ concurrency: 2 },
|
|
83
|
+
const results = yield* runTiers(
|
|
84
|
+
rules.filter((rule) => rule !== validation).flatMap((rule) => runsOf(rule, skippedHalves)),
|
|
85
|
+
inputs,
|
|
108
86
|
);
|
|
109
87
|
const seen = new Set<string>();
|
|
110
|
-
return results.
|
|
88
|
+
return results.filter((finding) => {
|
|
111
89
|
if (finding.rule !== "manifests/valid") {
|
|
112
90
|
return true;
|
|
113
91
|
}
|
package/src/engine/session.ts
CHANGED
|
@@ -2,11 +2,12 @@ import * as NodePath from "@effect/platform-node/NodePath";
|
|
|
2
2
|
import { Effect, Path } from "effect";
|
|
3
3
|
import { setManifestFiles } from "#adapters/manifestInventory.ts";
|
|
4
4
|
import { manifestReader } from "#adapters/manifestReader.ts";
|
|
5
|
+
import { typeScriptProgram } from "#adapters/typeScriptProgram.ts";
|
|
5
6
|
import { loadConfig, type ResolvedConfig } from "#config/load.ts";
|
|
6
7
|
import { type BaselineFile, readBaseline, readInput } from "#engine/baselineFile.ts";
|
|
7
8
|
import { runRules } from "#engine/runRules.ts";
|
|
8
9
|
import type { Violation } from "#engine/violation.ts";
|
|
9
|
-
import {
|
|
10
|
+
import { biomeExceptions } from "#exceptions/biomeFindings.ts";
|
|
10
11
|
import type { RegistryEntry, StaleRegistryEntry } from "#exceptions/registry.ts";
|
|
11
12
|
import { registryEntries } from "#exceptions/registryEntries.ts";
|
|
12
13
|
import { SetupFailure } from "#failure.ts";
|
|
@@ -45,17 +46,34 @@ export const scan = Effect.fn("Engine.scan")(function* (
|
|
|
45
46
|
readText,
|
|
46
47
|
root: config.root,
|
|
47
48
|
sources: inventory.sources,
|
|
49
|
+
typeScript: yield* typeScriptProgram(config.root, inventory.sources),
|
|
48
50
|
};
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
return { inventory, staleRegistry, violations };
|
|
51
|
+
const { kept, stale } = yield* setup(biomeExceptions(yield* runRules(config.active, inputs, config.skippedHalves), inputs, config.skippedHalves));
|
|
52
|
+
return { inventory, staleRegistry: stale, violations: kept };
|
|
52
53
|
});
|
|
53
54
|
|
|
55
|
+
export type RunSet = "fast" | "full";
|
|
56
|
+
|
|
57
|
+
// A fast run leaves deep rules and deep halves out and sets aside the baseline entries and exceptions it cannot judge.
|
|
58
|
+
function selected(config: ResolvedConfig, set: RunSet): ResolvedConfig {
|
|
59
|
+
if (set === "full") {
|
|
60
|
+
return config;
|
|
61
|
+
}
|
|
62
|
+
const active = config.active.filter((rule) => rule.depth === "fast");
|
|
63
|
+
return {
|
|
64
|
+
...config,
|
|
65
|
+
active,
|
|
66
|
+
skipped: new Set(config.active.filter((rule) => rule.depth === "deep").map((rule) => rule.id)),
|
|
67
|
+
skippedHalves: new Set(active.filter((rule) => rule.deepHalf !== undefined).map((rule) => rule.id)),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
54
71
|
export const openSession = Effect.fn("Engine.openSession")(function* (
|
|
55
72
|
cwd: string,
|
|
56
73
|
configPath: string | undefined,
|
|
74
|
+
set: RunSet = "full",
|
|
57
75
|
): Effect.fn.Return<Session, SetupFailure, RuleServices> {
|
|
58
|
-
const config = yield* loadConfig(cwd, configPath);
|
|
76
|
+
const config = selected(yield* loadConfig(cwd, configPath), set);
|
|
59
77
|
const selection = configPath === undefined ? "" : ` --config ${configPath}`;
|
|
60
78
|
for (const path of new Set([config.registry, "quality/registry.json"])) {
|
|
61
79
|
if ((yield* readInput(config.root, path)) !== undefined) {
|
package/src/engine/violation.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Finding } from "#rule.ts";
|
|
|
4
4
|
export type ActiveLevel = "error";
|
|
5
5
|
|
|
6
6
|
export interface Violation extends Finding {
|
|
7
|
+
readonly deep?: true;
|
|
7
8
|
readonly level: ActiveLevel;
|
|
8
9
|
readonly rule: string;
|
|
9
10
|
}
|
|
@@ -32,6 +33,9 @@ export function groupBy<TItem>(items: readonly TItem[], key: (item: TItem) => st
|
|
|
32
33
|
export interface RuleIndex {
|
|
33
34
|
readonly families: ReadonlySet<string>;
|
|
34
35
|
readonly levels: ReadonlyMap<string, Level>;
|
|
36
|
+
readonly skipped: ReadonlySet<string>;
|
|
37
|
+
readonly skippedHalves: ReadonlySet<string>;
|
|
38
|
+
readonly split: ReadonlySet<string>;
|
|
35
39
|
readonly unregistrable: ReadonlySet<string>;
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -47,6 +51,18 @@ export function levelOf(index: RuleIndex, rule: string): Level | undefined {
|
|
|
47
51
|
return index.levels.get(ownerOf(index, rule));
|
|
48
52
|
}
|
|
49
53
|
|
|
54
|
+
export function skipped(index: RuleIndex, rule: string): boolean {
|
|
55
|
+
return index.skipped.has(ownerOf(index, rule));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function halfSkipped(index: RuleIndex, rule: string): boolean {
|
|
59
|
+
return index.skippedHalves.has(ownerOf(index, rule));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function isSplit(index: RuleIndex, rule: string): boolean {
|
|
63
|
+
return index.split.has(ownerOf(index, rule));
|
|
64
|
+
}
|
|
65
|
+
|
|
50
66
|
export function registrable(index: RuleIndex, rule: string): boolean {
|
|
51
67
|
return !index.unregistrable.has(ownerOf(index, rule));
|
|
52
68
|
}
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { needsScanner } from "#biome/scannerRules.ts";
|
|
3
|
+
import { keyOf, type Violation } from "#engine/violation.ts";
|
|
4
4
|
import type { StaleRegistryEntry } from "#exceptions/registry.ts";
|
|
5
5
|
import type { FilesystemFailure } from "#inventory/filesystem.ts";
|
|
6
6
|
import type { Finding, RuleInputs } from "#rule.ts";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
// The biome rule reports excepted diagnostics at any severity; the session drops them and names each exception that none matched.
|
|
9
|
+
export const biomeExceptions = Effect.fn("Exceptions.biomeExceptions")(function* (
|
|
10
|
+
violations: readonly Violation[],
|
|
11
|
+
inputs: Pick<RuleInputs, "configFile" | "exceptions" | "readText">,
|
|
12
|
+
skippedHalves: ReadonlySet<string>,
|
|
13
|
+
) {
|
|
14
|
+
const declared = (inputs.exceptions ?? []).flatMap(({ files, reason, rules }) =>
|
|
11
15
|
rules.filter((rule) => /^biome\/(?:lint|assist)\//u.test(rule)).flatMap((rule) => files.map((file) => ({ file, reason, rule }))),
|
|
12
16
|
);
|
|
17
|
+
const excepted = new Set(declared.map(({ file, rule }) => keyOf(rule, file)));
|
|
18
|
+
const reported = new Set(violations.map((violation) => keyOf(violation.rule, violation.file)));
|
|
13
19
|
const texts = yield* Effect.forEach(declared, ({ file }) => inputs.readText(file), { concurrency: "unbounded" });
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
const exclusions = declarations.flatMap((entry) =>
|
|
19
|
-
entry.rules.includes("biome/files/includes") ? [{ ...entry, rules: ["biome/files/includes"] as const }] : [],
|
|
20
|
+
const judged = declared.filter(
|
|
21
|
+
(entry, index) => texts[index] !== undefined && !(skippedHalves.has("biome") && needsScanner(entry.rule.slice("biome/".length))),
|
|
20
22
|
);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
return {
|
|
24
|
+
kept: violations.filter((violation) => !excepted.has(keyOf(violation.rule, violation.file))),
|
|
25
|
+
stale: judged
|
|
26
|
+
.filter(({ file, rule }) => !reported.has(keyOf(rule, file)))
|
|
27
|
+
.map(
|
|
28
|
+
(entry): StaleRegistryEntry => ({
|
|
29
|
+
entry,
|
|
30
|
+
problem: `matches no finding. Remove this file/rule pair from exceptions in ${inputs.configFile ?? "quality.config.ts"}`,
|
|
31
|
+
}),
|
|
32
|
+
),
|
|
33
|
+
};
|
|
31
34
|
});
|
|
32
35
|
|
|
33
36
|
const missingBiomeFile = Effect.fn("Exceptions.missingBiomeFile")(function* (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { type Decoded, decodeWith } from "#decoded.ts";
|
|
3
|
-
import { type RuleIndex, registrable, unusedEntryProblem, type Violation } from "#engine/violation.ts";
|
|
3
|
+
import { halfSkipped, type RuleIndex, registrable, skipped, unusedEntryProblem, type Violation } from "#engine/violation.ts";
|
|
4
4
|
|
|
5
5
|
const RegistryEntry = Schema.Struct({
|
|
6
6
|
file: Schema.NonEmptyString,
|
|
@@ -50,7 +50,7 @@ export function applyRegistry(violations: readonly Violation[], entries: readonl
|
|
|
50
50
|
return entry === undefined;
|
|
51
51
|
});
|
|
52
52
|
const stale = entries
|
|
53
|
-
.filter((entry) => !used.has(entry))
|
|
53
|
+
.filter((entry) => !(used.has(entry) || (registrable(rules, entry.rule) && (skipped(rules, entry.rule) || halfSkipped(rules, entry.rule)))))
|
|
54
54
|
.map((entry) => ({
|
|
55
55
|
entry,
|
|
56
56
|
problem: registrable(rules, entry.rule) ? unusedEntryProblem(rules, entry.rule, "matches no violation") : UNREGISTRABLE,
|
package/src/hooks/preCommit.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
-
import { Console, Effect, Path } from "effect";
|
|
2
|
+
import { Config, Console, Effect, Path } from "effect";
|
|
3
3
|
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
4
4
|
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
5
5
|
import { manifestReader } from "#adapters/manifestReader.ts";
|
|
@@ -7,6 +7,7 @@ import { reportLint } from "#cli/lint.ts";
|
|
|
7
7
|
import { loadConfig } from "#config/load.ts";
|
|
8
8
|
import { passes } from "#engine/evaluate.ts";
|
|
9
9
|
import { GateFailed, SetupFailure } from "#failure.ts";
|
|
10
|
+
import { stagedCheck } from "#hooks/stagedCheck.ts";
|
|
10
11
|
import { recap } from "#report/recap.ts";
|
|
11
12
|
|
|
12
13
|
const COMMIT_AGAIN =
|
|
@@ -43,8 +44,21 @@ const runScript = Effect.fnUntraced(
|
|
|
43
44
|
Effect.mapError((error) => new SetupFailure({ cause: error, message: `cannot run a pre-commit script: ${error.message}` })),
|
|
44
45
|
);
|
|
45
46
|
|
|
47
|
+
const inCloudSession = Config.String("CLAUDE_CODE_REMOTE").pipe(
|
|
48
|
+
Config.withDefault(""),
|
|
49
|
+
Config.map((value) => value === "true"),
|
|
50
|
+
);
|
|
51
|
+
|
|
46
52
|
export const preCommitHook = Effect.fn("Hooks.preCommitHook")(function* (cwd: string, path: string | undefined) {
|
|
47
53
|
const config = yield* loadConfig(cwd, path);
|
|
54
|
+
const cloud = yield* inCloudSession.pipe(Effect.mapError((cause) => new SetupFailure({ cause, message: "cannot read CLAUDE_CODE_REMOTE." })));
|
|
55
|
+
if (config.preCommit === "staged" && !cloud) {
|
|
56
|
+
if (!(yield* stagedCheck(config))) {
|
|
57
|
+
yield* Console.error(`quality: pre-commit failed: Biome on the staged files.\n${COMMIT_AGAIN}`);
|
|
58
|
+
return yield* new GateFailed();
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
48
62
|
const { manager, scripts } = yield* commitScripts(config.root);
|
|
49
63
|
const { context, outcome } = yield* reportLint(cwd, path, true);
|
|
50
64
|
const linted = passes(outcome);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, Path } from "effect";
|
|
3
|
+
import { manifestReader } from "#adapters/manifestReader.ts";
|
|
4
|
+
import { biomeReport } from "#biome/report.ts";
|
|
5
|
+
import type { ResolvedConfig } from "#config/load.ts";
|
|
6
|
+
import { readBaseline } from "#engine/baselineFile.ts";
|
|
7
|
+
import { evaluate, type Outcome, passes } from "#engine/evaluate.ts";
|
|
8
|
+
import type { Violation } from "#engine/violation.ts";
|
|
9
|
+
import { registryEntries } from "#exceptions/registryEntries.ts";
|
|
10
|
+
import { SetupFailure } from "#failure.ts";
|
|
11
|
+
import { gitOrFail } from "#git/command.ts";
|
|
12
|
+
import { withStagedContent } from "#hooks/withStagedContent.ts";
|
|
13
|
+
import { type ReportContext, renderFindings } from "#report/render.ts";
|
|
14
|
+
import { failingFindings } from "#rules/biome.ts";
|
|
15
|
+
|
|
16
|
+
const BIOME = ["check", "--files-ignore-unknown=true", "--no-errors-on-unmatched"];
|
|
17
|
+
|
|
18
|
+
function pathsOf(output: string): readonly string[] {
|
|
19
|
+
return output.split("\0").filter((path) => path !== "");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function failed(error: { readonly message: string }): SetupFailure {
|
|
23
|
+
return new SetupFailure({ cause: error, message: error.message });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const stagedCheck = Effect.fn("Hooks.stagedCheck")(function* (config: ResolvedConfig) {
|
|
27
|
+
const { relative } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
28
|
+
|
|
29
|
+
const staged = pathsOf(yield* gitOrFail(config.root, ["diff", "--cached", "--name-only", "--relative", "--diff-filter=d", "-z"]));
|
|
30
|
+
const unstaged = new Set(pathsOf(yield* gitOrFail(config.root, ["diff", "--name-only", "--relative", "-z"])));
|
|
31
|
+
const edited = staged.filter((path) => unstaged.has(path));
|
|
32
|
+
yield* Console.log(
|
|
33
|
+
`quality: checking ${staged.length === 1 ? "the staged file" : `the ${staged.length} staged files`} with Biome only, as preCommit is "staged".`,
|
|
34
|
+
);
|
|
35
|
+
const report =
|
|
36
|
+
staged.length === 0
|
|
37
|
+
? { diagnostics: [] }
|
|
38
|
+
: yield* withStagedContent(config.root, edited, biomeReport(config.root, BIOME, config.exceptions, staged, config.nonEffectFolders)).pipe(
|
|
39
|
+
Effect.mapError(failed),
|
|
40
|
+
);
|
|
41
|
+
const findings = yield* failingFindings({ readText: yield* manifestReader(config.root) }, report.diagnostics).pipe(Effect.mapError(failed));
|
|
42
|
+
const violations = findings.map((finding): Violation => ({ ...finding, level: "error", rule: `biome/${finding.subject ?? "internal"}` }));
|
|
43
|
+
const baseline = yield* readBaseline(config);
|
|
44
|
+
const evaluated = evaluate(violations, registryEntries(config.exceptions), baseline.entries, config);
|
|
45
|
+
const outcome: Outcome = { ...evaluated, looseBaseline: [], staleBaseline: [], staleRegistry: [], unsplitBaseline: [] };
|
|
46
|
+
const context: ReportContext = {
|
|
47
|
+
baseline: config.baseline,
|
|
48
|
+
checked: staged.length,
|
|
49
|
+
descriptions: new Map(config.active.map((rule) => [rule.id, rule.description])),
|
|
50
|
+
registry: config.exceptions.length === 0 ? config.registry : `${relative(config.root, config.file)} exceptions`,
|
|
51
|
+
};
|
|
52
|
+
yield* Console.log(renderFindings(outcome, context));
|
|
53
|
+
return passes(outcome);
|
|
54
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, FileSystem, Path } from "effect";
|
|
3
|
+
import type { ChildProcessSpawner } from "effect/process";
|
|
4
|
+
import { SetupFailure } from "#failure.ts";
|
|
5
|
+
import { gitOrFail } from "#git/command.ts";
|
|
6
|
+
import { shellWords } from "#hooks/command.ts";
|
|
7
|
+
import { orWhenAbsent } from "#inventory/filesystem.ts";
|
|
8
|
+
|
|
9
|
+
type WorkingCopy =
|
|
10
|
+
| { readonly kind: "absent"; readonly path: string }
|
|
11
|
+
| { readonly blob: string; readonly bytes: Uint8Array; readonly kind: "file"; readonly mode: number; readonly path: string }
|
|
12
|
+
| { readonly kind: "link"; readonly path: string; readonly target: string };
|
|
13
|
+
|
|
14
|
+
function failed(error: { readonly message: string }): SetupFailure {
|
|
15
|
+
return new SetupFailure({ cause: error, message: error.message });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function recovery(copy: WorkingCopy): string {
|
|
19
|
+
const path = shellWords([copy.path]);
|
|
20
|
+
switch (copy.kind) {
|
|
21
|
+
case "absent":
|
|
22
|
+
return `rm -f ${path}`;
|
|
23
|
+
case "file":
|
|
24
|
+
return `git cat-file blob ${copy.blob} > ${path} && chmod ${copy.mode.toString(8)} ${path}`;
|
|
25
|
+
case "link":
|
|
26
|
+
return `ln -sfn ${shellWords([copy.target])} ${path}`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function notice(root: string, copies: readonly WorkingCopy[]): string {
|
|
31
|
+
const [only] = copies;
|
|
32
|
+
const intro =
|
|
33
|
+
copies.length === 1 && only !== undefined
|
|
34
|
+
? `${only.path} changed after staging; Biome checks its staged content in place, then the working copy is put back. If the hook stops first, run this in ${root}:`
|
|
35
|
+
: `${copies.length} files changed after staging; Biome checks their staged content in place, then the working copies are put back. If the hook stops first, run these in ${root}:`;
|
|
36
|
+
return [`quality: ${intro}`, ...copies.map((copy) => ` ${recovery(copy)}`)].join("\n");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// The blob outlives a killed hook, so the printed command still recovers the working copy.
|
|
40
|
+
const setAside = Effect.fn("Hooks.setAside")(function* (
|
|
41
|
+
root: string,
|
|
42
|
+
path: string,
|
|
43
|
+
): Effect.fn.Return<WorkingCopy, SetupFailure, FileSystem.FileSystem | ChildProcessSpawner.ChildProcessSpawner> {
|
|
44
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
45
|
+
|
|
46
|
+
const fs = yield* FileSystem.FileSystem;
|
|
47
|
+
const at = join(root, path);
|
|
48
|
+
const info = yield* orWhenAbsent(at, fs.lstat(at), undefined).pipe(Effect.mapError(failed));
|
|
49
|
+
if (info === undefined) {
|
|
50
|
+
return { kind: "absent", path };
|
|
51
|
+
}
|
|
52
|
+
if (info.type === "SymbolicLink") {
|
|
53
|
+
return { kind: "link", path, target: yield* fs.readLink(at).pipe(Effect.mapError(failed)) };
|
|
54
|
+
}
|
|
55
|
+
if (info.type !== "File") {
|
|
56
|
+
return yield* new SetupFailure({ message: `${path} changed after staging into a ${info.type}, so the staged check cannot set it aside.` });
|
|
57
|
+
}
|
|
58
|
+
const bytes = yield* fs.readFile(at).pipe(Effect.mapError(failed));
|
|
59
|
+
const blob = (yield* gitOrFail(root, ["hash-object", "-w", "--no-filters", "--", path])).trim();
|
|
60
|
+
return { blob, bytes, kind: "file", mode: info.mode & 0o7777, path };
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const setAsideAll = Effect.fn("Hooks.setAsideAll")(function* (root: string, paths: readonly string[]) {
|
|
64
|
+
const copies = yield* Effect.forEach(paths, (path) => setAside(root, path));
|
|
65
|
+
yield* Console.log(notice(root, copies));
|
|
66
|
+
return copies;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const putBack = Effect.fn("Hooks.putBack")(function* (root: string, copy: WorkingCopy) {
|
|
70
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
71
|
+
|
|
72
|
+
const fs = yield* FileSystem.FileSystem;
|
|
73
|
+
const at = join(root, copy.path);
|
|
74
|
+
yield* fs.remove(at, { force: true });
|
|
75
|
+
if (copy.kind === "file") {
|
|
76
|
+
yield* fs.writeFile(at, copy.bytes);
|
|
77
|
+
yield* fs.chmod(at, copy.mode);
|
|
78
|
+
}
|
|
79
|
+
if (copy.kind === "link") {
|
|
80
|
+
yield* fs.symlink(copy.target, at);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const restore = Effect.fn("Hooks.restore")(function* (root: string, copies: readonly WorkingCopy[]) {
|
|
85
|
+
const [, failures] = yield* Effect.partition(copies, (copy) => Effect.mapError(putBack(root, copy), (error) => ({ copy, error })));
|
|
86
|
+
if (failures.length === 0) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const lines = failures.map(({ copy, error }) => `quality: cannot put back the working copy of ${copy.path}: ${error.message}\n ${recovery(copy)}`);
|
|
90
|
+
yield* Console.error(lines.join("\n"));
|
|
91
|
+
return yield* new SetupFailure({
|
|
92
|
+
message: `${failures.length === 1 ? "a working copy was" : `${failures.length} working copies were`} not put back; run the commands above in ${root}.`,
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Biome reports no diagnostics for content piped to its stdin, so a file edited again after staging shows Biome its staged content
|
|
97
|
+
// on disk until the check ends.
|
|
98
|
+
export const withStagedContent = Effect.fn("Hooks.withStagedContent")(function* <TValue, TError, TRequirements>(
|
|
99
|
+
root: string,
|
|
100
|
+
edited: readonly string[],
|
|
101
|
+
check: Effect.Effect<TValue, TError, TRequirements>,
|
|
102
|
+
) {
|
|
103
|
+
if (edited.length === 0) {
|
|
104
|
+
return yield* check;
|
|
105
|
+
}
|
|
106
|
+
return yield* Effect.acquireUseRelease(
|
|
107
|
+
setAsideAll(root, edited),
|
|
108
|
+
() => Effect.andThen(gitOrFail(root, ["--literal-pathspecs", "checkout-index", "--force", "--", ...edited]), check),
|
|
109
|
+
(copies) => restore(root, copies),
|
|
110
|
+
);
|
|
111
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { dirname, join } from "node:path";
|
|
2
|
-
import { Effect, type FileSystem } from "effect";
|
|
2
|
+
import { type Context, Effect, type FileSystem } from "effect";
|
|
3
3
|
import ts from "typescript";
|
|
4
|
+
import { DeclarationFiles } from "#adapters/declaration-files/service.ts";
|
|
4
5
|
import { type FilesystemFailure, readRequiredText } from "#inventory/filesystem.ts";
|
|
5
6
|
|
|
6
7
|
const portable = new Set([
|
|
@@ -67,8 +68,7 @@ const portable = new Set([
|
|
|
67
68
|
"structuredClone",
|
|
68
69
|
]);
|
|
69
70
|
|
|
70
|
-
function namesInDom(
|
|
71
|
-
const source = ts.createSourceFile(path, text, ts.ScriptTarget.Latest, true);
|
|
71
|
+
function namesInDom(source: ts.SourceFile): readonly string[] {
|
|
72
72
|
return source.statements.flatMap((statement) => {
|
|
73
73
|
if (ts.isVariableStatement(statement)) {
|
|
74
74
|
return statement.declarationList.declarations.flatMap(({ name }) => (ts.isIdentifier(name) ? [name.text] : []));
|
|
@@ -80,9 +80,11 @@ function namesInDom(path: string, text: string): readonly string[] {
|
|
|
80
80
|
export const browserNames = Effect.fn("Imports.browserNames")(function* (): Effect.fn.Return<
|
|
81
81
|
ReadonlySet<string>,
|
|
82
82
|
FilesystemFailure,
|
|
83
|
-
FileSystem.FileSystem
|
|
83
|
+
Context.Service.Identifier<typeof DeclarationFiles> | FileSystem.FileSystem
|
|
84
84
|
> {
|
|
85
85
|
const path = join(dirname(ts.getDefaultLibFilePath({})), "lib.dom.d.ts");
|
|
86
86
|
const text = yield* readRequiredText(path);
|
|
87
|
-
|
|
87
|
+
const declarations = yield* DeclarationFiles;
|
|
88
|
+
const source = yield* declarations.parse(path, text, { target: ts.ScriptTarget.Latest });
|
|
89
|
+
return new Set(namesInDom(source).filter((name) => !portable.has(name)));
|
|
88
90
|
});
|
|
@@ -26,7 +26,7 @@ function graphOf(chain: Chain): FenceGraph | undefined {
|
|
|
26
26
|
const edges = files.map(
|
|
27
27
|
(from, index): ImportEdge => ({ from, kind: "import", line: 1, specifier: "", to: endpointOf(chain[index + 1] ?? from), type: false }),
|
|
28
28
|
);
|
|
29
|
-
return { edges, modules: files };
|
|
29
|
+
return { edges, ignoredEdges: [], modules: files };
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function crossedBy(policy: readonly CompiledFence[], graph: FenceGraph): readonly string[] {
|
|
@@ -6,7 +6,7 @@ import type { ImportEdge, ImportGraph } from "#imports/graph.ts";
|
|
|
6
6
|
import { isTestCode } from "#naming/testName.ts";
|
|
7
7
|
import type { Finding } from "#rule.ts";
|
|
8
8
|
|
|
9
|
-
export type FenceGraph = Pick<ImportGraph, "edges" | "modules">;
|
|
9
|
+
export type FenceGraph = Pick<ImportGraph, "edges" | "ignoredEdges" | "modules">;
|
|
10
10
|
|
|
11
11
|
export type Evaluate = (graph: FenceGraph) => readonly Finding[];
|
|
12
12
|
|
|
@@ -49,7 +49,7 @@ function importFindings(fence: Fence, importer: (path: string) => boolean, to: M
|
|
|
49
49
|
|
|
50
50
|
function reachFindings(fence: Fence, importer: (path: string) => boolean, to: Matcher): Evaluate {
|
|
51
51
|
return (graph) => {
|
|
52
|
-
const edgesFrom = outgoing(graph.edges);
|
|
52
|
+
const edgesFrom = outgoing([...graph.edges, ...graph.ignoredEdges]);
|
|
53
53
|
return graph.modules.filter(importer).flatMap((module) =>
|
|
54
54
|
reachedFrom(module, edgesFrom, to).map((reached) => ({
|
|
55
55
|
file: module,
|