@shivaedev/quality 0.75.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 +68 -0
- package/README.md +66 -60
- 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 +2 -2
- package/dist/adapters/knip/configuration.d.ts.map +1 -1
- package/dist/adapters/knip/configuration.js +11 -5
- 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/knip/run.js +4 -1
- package/dist/adapters/knip/run.js.map +1 -1
- package/dist/adapters/outsideImportFindings.d.ts +5 -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/serviceIdFindings.d.ts +1 -1
- package/dist/adapters/serviceIdFindings.d.ts.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 +9 -1
- package/dist/cli/lint.d.ts.map +1 -1
- package/dist/cli/lint.js +18 -5
- 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/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/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/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/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/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 +18 -4
- 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/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 +5 -3
- 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/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 +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/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/withoutGenerated.js +1 -1
- package/dist/imports/withoutGenerated.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/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/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 +2 -0
- package/dist/report/render.d.ts.map +1 -1
- package/dist/report/render.js +11 -4
- 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/manifestsApplication.d.ts.map +1 -1
- package/dist/rules/manifestsApplication.js +4 -5
- package/dist/rules/manifestsApplication.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 +8 -4
- 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 +11 -5
- package/src/adapters/knip/run.ts +4 -1
- package/src/adapters/outsideImportFindings.ts +22 -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 +34 -18
- package/src/cli/migrateExceptions.ts +8 -9
- 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/MigrationFailure.ts +5 -0
- package/src/exceptions/biomeFindings.ts +24 -21
- package/src/exceptions/migrateBiome.ts +10 -4
- package/src/exceptions/migrateConfig.ts +66 -29
- package/src/exceptions/registry.ts +2 -2
- package/src/hooks/preCommit.ts +22 -7
- 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/check.ts +1 -1
- package/src/imports/fences/compilePolicy.ts +6 -4
- package/src/imports/fences/evaluate.ts +2 -2
- package/src/imports/globMatcher.ts +42 -35
- package/src/imports/graph.ts +47 -3
- package/src/imports/pnpmWorkspacePatterns.ts +44 -39
- package/src/imports/withoutGenerated.ts +1 -1
- package/src/imports/workspace.ts +1 -1
- package/src/inventory/trackedPaths.ts +10 -3
- package/src/manifests/deliveredDependencies.ts +11 -0
- package/src/report/recap.ts +29 -0
- package/src/report/render.ts +13 -4
- 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/manifestsApplication.ts +4 -5
- 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,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
|
}
|
|
@@ -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,11 +1,14 @@
|
|
|
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";
|
|
6
|
-
import {
|
|
6
|
+
import { reportLint } from "#cli/lint.ts";
|
|
7
7
|
import { loadConfig } from "#config/load.ts";
|
|
8
|
+
import { passes } from "#engine/evaluate.ts";
|
|
8
9
|
import { GateFailed, SetupFailure } from "#failure.ts";
|
|
10
|
+
import { stagedCheck } from "#hooks/stagedCheck.ts";
|
|
11
|
+
import { recap } from "#report/recap.ts";
|
|
9
12
|
|
|
10
13
|
const COMMIT_AGAIN =
|
|
11
14
|
"help: fix what the output above reports, then commit again; `quality hooks pre-commit` repeats these checks without committing.";
|
|
@@ -41,13 +44,24 @@ const runScript = Effect.fnUntraced(
|
|
|
41
44
|
Effect.mapError((error) => new SetupFailure({ cause: error, message: `cannot run a pre-commit script: ${error.message}` })),
|
|
42
45
|
);
|
|
43
46
|
|
|
47
|
+
const inCloudSession = Config.String("CLAUDE_CODE_REMOTE").pipe(
|
|
48
|
+
Config.withDefault(""),
|
|
49
|
+
Config.map((value) => value === "true"),
|
|
50
|
+
);
|
|
51
|
+
|
|
44
52
|
export const preCommitHook = Effect.fn("Hooks.preCommitHook")(function* (cwd: string, path: string | undefined) {
|
|
45
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
|
+
}
|
|
46
62
|
const { manager, scripts } = yield* commitScripts(config.root);
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
Effect.catchTag("GateFailed", () => Effect.succeed(false)),
|
|
50
|
-
);
|
|
63
|
+
const { context, outcome } = yield* reportLint(cwd, path, true);
|
|
64
|
+
const linted = passes(outcome);
|
|
51
65
|
const failed = linted ? [] : ["quality lint"];
|
|
52
66
|
for (const script of scripts) {
|
|
53
67
|
const command = `${manager} run ${script}`;
|
|
@@ -58,7 +72,8 @@ export const preCommitHook = Effect.fn("Hooks.preCommitHook")(function* (cwd: st
|
|
|
58
72
|
}
|
|
59
73
|
}
|
|
60
74
|
if (failed.length > 0) {
|
|
61
|
-
|
|
75
|
+
const findings = linted ? [] : [recap(outcome, context)];
|
|
76
|
+
yield* Console.error([...findings, `quality: pre-commit failed: ${failed.join(", ")}.`, COMMIT_AGAIN].join("\n"));
|
|
62
77
|
return yield* new GateFailed();
|
|
63
78
|
}
|
|
64
79
|
});
|
|
@@ -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
|
+
});
|