@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/adapters/runMain.ts
CHANGED
|
@@ -4,8 +4,8 @@ import * as NodeChildProcessSpawner from "@effect/platform-node/NodeChildProcess
|
|
|
4
4
|
import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
|
|
5
5
|
import * as NodePath from "@effect/platform-node/NodePath";
|
|
6
6
|
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
|
7
|
-
import { Cause, Console, Effect, Exit,
|
|
8
|
-
import
|
|
7
|
+
import { Cause, Console, Effect, Exit, Layer, Runtime } from "effect";
|
|
8
|
+
import { DeclarationFiles } from "#adapters/declaration-files/service.ts";
|
|
9
9
|
import { SetupFailure } from "#failure.ts";
|
|
10
10
|
|
|
11
11
|
const INTERRUPTED = 130;
|
|
@@ -46,7 +46,10 @@ export function quietOnClosedPipe(stream: EventEmitter): void {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export const services = NodeChildProcessSpawner.layer.pipe(
|
|
49
|
+
export const services = NodeChildProcessSpawner.layer.pipe(
|
|
50
|
+
Layer.provideMerge(Layer.mergeAll(NodeFileSystem.layer, NodePath.layer)),
|
|
51
|
+
Layer.merge(DeclarationFiles.layer),
|
|
52
|
+
);
|
|
50
53
|
|
|
51
54
|
export function explained<TValue, TError, TRequirements>(
|
|
52
55
|
program: Effect.Effect<TValue, TError, TRequirements>,
|
|
@@ -54,9 +57,7 @@ export function explained<TValue, TError, TRequirements>(
|
|
|
54
57
|
return Effect.tapCause(program, (cause) => (Cause.hasInterruptsOnly(cause) ? Effect.void : explain(cause)));
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
export function runMain<TValue, TError>(
|
|
58
|
-
program: Effect.Effect<TValue, TError, FileSystem.FileSystem | ChildProcessSpawner.ChildProcessSpawner>,
|
|
59
|
-
): void {
|
|
60
|
+
export function runMain<TValue, TError>(program: Effect.Effect<TValue, TError, Layer.Success<typeof services>>): void {
|
|
60
61
|
quietOnClosedPipe(process.stdout);
|
|
61
62
|
quietOnClosedPipe(process.stderr);
|
|
62
63
|
NodeRuntime.runMain(Effect.provide(explained(program), services), { disableErrorReporting: true, teardown });
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
1
|
import ts from "typescript";
|
|
4
2
|
import { serviceAssemblyImports } from "#adapters/serviceAssemblyImports.ts";
|
|
5
3
|
import { directServiceDefinitions } from "#adapters/serviceAssemblySyntax.ts";
|
|
6
4
|
import { serviceOperationProblems } from "#adapters/serviceOperationProblems.ts";
|
|
7
5
|
import { serviceStateProblems } from "#adapters/serviceStateProblems.ts";
|
|
8
|
-
import type { Finding,
|
|
9
|
-
import { effectProgram } from "#rules/effect/program.ts";
|
|
6
|
+
import type { Finding, SourceFile, TypeScriptProgram } from "#rule.ts";
|
|
10
7
|
import { serviceCatalog } from "#rules/effect/serviceCatalog.ts";
|
|
11
8
|
import { parse } from "#rules/parse.ts";
|
|
12
9
|
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
|
|
10
|
+
function definesServices(file: SourceFile): boolean {
|
|
11
|
+
const source = file.text.includes("defineService") ? parse(file) : undefined;
|
|
12
|
+
return source !== undefined && directServiceDefinitions(source, serviceAssemblyImports(source).definitions).length > 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function checkServices(sources: readonly SourceFile[], { checker, program, sourceFile }: TypeScriptProgram): readonly Finding[] {
|
|
16
16
|
const services = serviceCatalog(program, checker, [], true);
|
|
17
17
|
const found: Finding[] = [];
|
|
18
|
-
for (const file of
|
|
19
|
-
const source =
|
|
18
|
+
for (const file of sources) {
|
|
19
|
+
const source = sourceFile(file.path);
|
|
20
20
|
if (source === undefined) {
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
@@ -34,19 +34,4 @@ function checkServices(inputs: RuleInputs): readonly Finding[] {
|
|
|
34
34
|
return found;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export const
|
|
38
|
-
Effect.sync(() => {
|
|
39
|
-
const groups = new Map<string, RuleInputs["sources"][number][]>();
|
|
40
|
-
for (const file of inputs.sources) {
|
|
41
|
-
const source = parse(file);
|
|
42
|
-
if (source === undefined || directServiceDefinitions(source, serviceAssemblyImports(source).definitions).length === 0) {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
const group = /^(?:packages|examples)\/[^/]+/u.exec(file.path)?.[0] ?? ".";
|
|
46
|
-
const sources = groups.get(group) ?? [];
|
|
47
|
-
sources.push(file);
|
|
48
|
-
groups.set(group, sources);
|
|
49
|
-
}
|
|
50
|
-
return [...groups.values()].flatMap((sources) => checkServices({ ...inputs, sources }));
|
|
51
|
-
}),
|
|
52
|
-
);
|
|
37
|
+
export const serviceModelCheck = { checks: definesServices, findings: checkServices };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import { sharedErrorModules } from "#adapters/sharedErrorModules.ts";
|
|
5
|
+
import type { RuleInputs } from "#rule.ts";
|
|
6
|
+
import { taggedClasses } from "#rules/effect/errorTags.ts";
|
|
7
|
+
|
|
8
|
+
export interface SharedError {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly path: string;
|
|
11
|
+
readonly specifier: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SharedErrorCatalog {
|
|
15
|
+
readonly byTag: ReadonlyMap<string, SharedError>;
|
|
16
|
+
readonly tagOf: (specifier: string, name: string) => string | undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Published packages ship their sources beside the declarations, and a source states each tag as a literal where a declaration buries it in a type.
|
|
20
|
+
function moduleSource(file: string): ts.SourceFile | undefined {
|
|
21
|
+
const published = file.replace(/\/dist\/(?<module>.+)\.d\.(?<kind>[cm]?)ts$/u, "/src/$<module>.$<kind>ts");
|
|
22
|
+
const path = published !== file && ts.sys.fileExists(published) ? published : file;
|
|
23
|
+
const text = ts.sys.readFile(path);
|
|
24
|
+
return text === undefined ? undefined : ts.createSourceFile(ts.sys.realpath?.(path) ?? path, text, ts.ScriptTarget.Latest, true);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const sharedErrorCatalog = Effect.fn("SharedErrors.sharedErrorCatalog")(function* (inputs: Pick<RuleInputs, "readText" | "root" | "sources">) {
|
|
28
|
+
const root = ts.sys.realpath?.(inputs.root) ?? inputs.root;
|
|
29
|
+
const byTag = new Map<string, SharedError>();
|
|
30
|
+
const bySpecifier = new Map<string, Map<string, string>>();
|
|
31
|
+
for (const { file, specifier } of yield* sharedErrorModules(inputs)) {
|
|
32
|
+
const source = moduleSource(file);
|
|
33
|
+
const exported = (source === undefined ? [] : taggedClasses(source, () => undefined)).filter(
|
|
34
|
+
({ name, node }) => name !== undefined && ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export,
|
|
35
|
+
);
|
|
36
|
+
for (const { name = "", tag } of exported) {
|
|
37
|
+
byTag.set(tag, { name, path: relative(root, source?.fileName ?? file).replaceAll("\\", "/"), specifier });
|
|
38
|
+
bySpecifier.set(specifier, new Map([...(bySpecifier.get(specifier) ?? []), [name, tag]]));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const catalog: SharedErrorCatalog = { byTag, tagOf: (specifier, name) => bySpecifier.get(specifier)?.get(name) };
|
|
42
|
+
return catalog;
|
|
43
|
+
});
|
|
@@ -47,7 +47,7 @@ function resolveModules(specifiers: readonly string[], from: string, project: Pr
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export const sharedErrorModules = Effect.fn("SharedErrors.sharedErrorModules")(function* (inputs: RuleInputs) {
|
|
50
|
+
export const sharedErrorModules = Effect.fn("SharedErrors.sharedErrorModules")(function* (inputs: Pick<RuleInputs, "readText" | "root" | "sources">) {
|
|
51
51
|
const projectOf = projectsFor(inputs.root);
|
|
52
52
|
const manifests = new Map<string, string>();
|
|
53
53
|
for (const source of inputs.sources) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
1
2
|
import ts from "typescript";
|
|
2
3
|
import { asymmetricMatcher } from "#adapters/asymmetricMatcher.ts";
|
|
4
|
+
import { DeclarationFiles } from "#adapters/declaration-files/service.ts";
|
|
3
5
|
import type { SourceFile } from "#rule.ts";
|
|
4
6
|
import { parse } from "#rules/parse.ts";
|
|
5
7
|
import { topLevelHelpers, unwrapped } from "#rules/stories/syntax.ts";
|
|
@@ -37,7 +39,7 @@ const READ_METHODS = new Set([
|
|
|
37
39
|
"values",
|
|
38
40
|
]);
|
|
39
41
|
|
|
40
|
-
export
|
|
42
|
+
export const specReaderSources = Effect.fn("SpecHelpers.specReaderSources")(function* (files: readonly SourceFile[]) {
|
|
41
43
|
const sources = files.flatMap((file) => {
|
|
42
44
|
const source = parse(file);
|
|
43
45
|
return source === undefined || topLevelHelpers(source).length === 0 ? [] : [source];
|
|
@@ -47,7 +49,8 @@ export function specReaderSources(files: readonly SourceFile[]) {
|
|
|
47
49
|
}
|
|
48
50
|
const options: ts.CompilerOptions = { allowJs: true, noResolve: true, target: ts.ScriptTarget.ESNext, types: [] };
|
|
49
51
|
const host = ts.createCompilerHost(options);
|
|
50
|
-
const
|
|
52
|
+
const declarations = yield* DeclarationFiles;
|
|
53
|
+
const getSourceFile = yield* declarations.reader(host, options);
|
|
51
54
|
const parsed = new Map(sources.map((source) => [source.fileName, source]));
|
|
52
55
|
host.getSourceFile = (path, ...args) => parsed.get(path) ?? getSourceFile(path, ...args);
|
|
53
56
|
const program = ts.createProgram([...parsed.keys()], options, host);
|
|
@@ -74,4 +77,4 @@ export function specReaderSources(files: readonly SourceFile[]) {
|
|
|
74
77
|
);
|
|
75
78
|
}
|
|
76
79
|
return sources.map((source) => ({ readCall, source }));
|
|
77
|
-
}
|
|
80
|
+
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
+
import { Effect } from "effect";
|
|
2
3
|
import ts from "typescript";
|
|
3
4
|
import { projectsFor } from "#adapters/imports/projects.ts";
|
|
4
5
|
import type { ImportGraph } from "#imports/graph.ts";
|
|
5
6
|
import type { RuleInputs } from "#rule.ts";
|
|
7
|
+
import { parse } from "#rules/parse.ts";
|
|
6
8
|
|
|
7
9
|
const programs = new WeakMap<RuleInputs["sources"], ts.Program>();
|
|
8
10
|
|
|
@@ -11,7 +13,7 @@ export function storyProgram(inputs: RuleInputs, graph: ImportGraph): ts.Program
|
|
|
11
13
|
if (known !== undefined) {
|
|
12
14
|
return known;
|
|
13
15
|
}
|
|
14
|
-
const sources = new Map(inputs.sources.map((file) => [join(inputs.root, file.path), file
|
|
16
|
+
const sources = new Map(inputs.sources.map((file) => [join(inputs.root, file.path), file]));
|
|
15
17
|
const targets = new Map(
|
|
16
18
|
graph.edges.flatMap((edge) =>
|
|
17
19
|
edge.to.kind === "file" ? [[`${join(inputs.root, edge.from)}:${edge.specifier}`, join(inputs.root, edge.to.path)] as const] : [],
|
|
@@ -23,10 +25,15 @@ export function storyProgram(inputs: RuleInputs, graph: ImportGraph): ts.Program
|
|
|
23
25
|
...ts.createCompilerHost(options),
|
|
24
26
|
fileExists: (path) => sources.has(path) || ts.sys.fileExists(path),
|
|
25
27
|
getSourceFile: (path) => {
|
|
26
|
-
const
|
|
28
|
+
const file = sources.get(path);
|
|
29
|
+
const tree = file === undefined ? undefined : parse(file);
|
|
30
|
+
if (tree !== undefined) {
|
|
31
|
+
return tree;
|
|
32
|
+
}
|
|
33
|
+
const text = file?.text ?? ts.sys.readFile(path);
|
|
27
34
|
return text === undefined ? undefined : ts.createSourceFile(path, text, ts.ScriptTarget.Latest, true);
|
|
28
35
|
},
|
|
29
|
-
readFile: (path) => sources.get(path) ?? ts.sys.readFile(path),
|
|
36
|
+
readFile: (path) => sources.get(path)?.text ?? ts.sys.readFile(path),
|
|
30
37
|
resolveModuleNames: (names, from) =>
|
|
31
38
|
names.map((name) => {
|
|
32
39
|
const path = targets.get(`${from}:${name}`);
|
|
@@ -44,3 +51,13 @@ export function storyProgram(inputs: RuleInputs, graph: ImportGraph): ts.Program
|
|
|
44
51
|
programs.set(inputs.sources, program);
|
|
45
52
|
return program;
|
|
46
53
|
}
|
|
54
|
+
|
|
55
|
+
export function withStoryProgram<TValue, TError, TServices>(
|
|
56
|
+
inputs: RuleInputs,
|
|
57
|
+
rules: Effect.Effect<TValue, TError, TServices>,
|
|
58
|
+
): Effect.Effect<TValue, TError, TServices> {
|
|
59
|
+
return Effect.ensuring(
|
|
60
|
+
rules,
|
|
61
|
+
Effect.sync(() => programs.delete(inputs.sources)),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import { DeclarationFiles } from "#adapters/declaration-files/service.ts";
|
|
5
|
+
import { projectsFor } from "#adapters/imports/projects.ts";
|
|
6
|
+
import type { SourceFile, TypeScriptProgram } from "#rule.ts";
|
|
7
|
+
|
|
8
|
+
const OPTIONS: ts.CompilerOptions = {
|
|
9
|
+
allowJs: true,
|
|
10
|
+
jsx: ts.JsxEmit.Preserve,
|
|
11
|
+
skipLibCheck: true,
|
|
12
|
+
strict: true,
|
|
13
|
+
target: ts.ScriptTarget.ESNext,
|
|
14
|
+
types: [],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const compile = Effect.fn("TypeScriptProgram.compile")(function* (
|
|
18
|
+
root: string,
|
|
19
|
+
files: readonly string[],
|
|
20
|
+
texts: ReadonlyMap<string, string>,
|
|
21
|
+
projectOf: ReturnType<typeof projectsFor>,
|
|
22
|
+
) {
|
|
23
|
+
const host = ts.createCompilerHost(OPTIONS);
|
|
24
|
+
const read = host.readFile;
|
|
25
|
+
host.readFile = (path) => texts.get(path) ?? read(path);
|
|
26
|
+
host.resolveModuleNames = (names, from) =>
|
|
27
|
+
names.map((name) => {
|
|
28
|
+
const project = projectOf(from);
|
|
29
|
+
return ts.resolveModuleName(name, from, project.typesOptions, host, project.typesCache).resolvedModule;
|
|
30
|
+
});
|
|
31
|
+
const declarations = yield* DeclarationFiles;
|
|
32
|
+
host.getSourceFile = yield* declarations.reader(host, OPTIONS);
|
|
33
|
+
const program = ts.createProgram([...files], OPTIONS, host);
|
|
34
|
+
const compiled: TypeScriptProgram = {
|
|
35
|
+
checker: program.getTypeChecker(),
|
|
36
|
+
program,
|
|
37
|
+
sourceFile: (path) => program.getSourceFile(join(root, path)),
|
|
38
|
+
ts,
|
|
39
|
+
};
|
|
40
|
+
return compiled;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Programs built with the same projects share their parsed tsconfigs and module resolutions.
|
|
44
|
+
export const sourcesProgram = Effect.fn("TypeScriptProgram.sourcesProgram")(function* (
|
|
45
|
+
root: string,
|
|
46
|
+
sources: readonly SourceFile[],
|
|
47
|
+
projectOf = projectsFor(root),
|
|
48
|
+
) {
|
|
49
|
+
const texts = new Map(sources.map((source) => [join(root, source.path), source.text]));
|
|
50
|
+
return yield* compile(root, [...texts.keys()], texts, projectOf);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Rules receive the program as an Effect without requirements, so it keeps the declaration files of the run that scanned the sources.
|
|
54
|
+
export const typeScriptProgram = Effect.fn("TypeScriptProgram.typeScriptProgram")(function* (root: string, sources: readonly SourceFile[]) {
|
|
55
|
+
const declarations = yield* DeclarationFiles;
|
|
56
|
+
return yield* Effect.cached(sourcesProgram(root, sources).pipe(Effect.provideService(DeclarationFiles, declarations)));
|
|
57
|
+
});
|
package/src/baseline/compare.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { BaselineEntry } from "#baseline/format.ts";
|
|
2
|
-
import { groupBy, keyOf, levelOf, type RuleIndex, unusedEntryProblem, type Violation } from "#engine/violation.ts";
|
|
2
|
+
import { groupBy, halfSkipped, isSplit, keyOf, levelOf, type RuleIndex, skipped, unusedEntryProblem, type Violation } from "#engine/violation.ts";
|
|
3
3
|
|
|
4
4
|
export interface Regression {
|
|
5
|
+
readonly allowed?: number;
|
|
5
6
|
readonly count: number;
|
|
6
7
|
readonly entry: BaselineEntry;
|
|
7
8
|
}
|
|
@@ -23,32 +24,71 @@ export function countOf(violations: readonly Violation[]): number {
|
|
|
23
24
|
return violations.reduce((total, violation) => total + (violation.count ?? 1), 0);
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
interface Allowance {
|
|
28
|
+
readonly allowed: number;
|
|
29
|
+
readonly exact: boolean;
|
|
30
|
+
readonly share: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Without its deep half, a run judges a split entry by the share it recorded for the fast half, or only as an upper bound when it recorded none.
|
|
34
|
+
function allowance(entry: BaselineEntry, rules: RuleIndex): Allowance {
|
|
35
|
+
if (!halfSkipped(rules, entry.rule)) {
|
|
36
|
+
return { allowed: entry.count, exact: true, share: "" };
|
|
37
|
+
}
|
|
38
|
+
return entry.deep === undefined
|
|
39
|
+
? { allowed: entry.count, exact: false, share: "" }
|
|
40
|
+
: { allowed: entry.count - entry.deep, exact: true, share: " for its fast half" };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type Verdict =
|
|
44
|
+
| { readonly kind: "aside" }
|
|
45
|
+
| { readonly kind: "covered"; readonly loose?: string }
|
|
46
|
+
| { readonly kind: "regression"; readonly regression: Regression }
|
|
47
|
+
| { readonly kind: "unused"; readonly problem: string };
|
|
48
|
+
|
|
49
|
+
function verdict(entry: BaselineEntry, group: readonly Violation[], rules: RuleIndex): Verdict {
|
|
50
|
+
const { allowed, exact, share } = allowance(entry, rules);
|
|
51
|
+
if (group.length === 0) {
|
|
52
|
+
if (levelOf(rules, entry.rule) !== undefined && !(exact && allowed > 0)) {
|
|
53
|
+
return { kind: "aside" };
|
|
54
|
+
}
|
|
55
|
+
const left = share === "" ? "has no violations left" : `has no violations left${share}: 0 against ${allowed} baselined`;
|
|
56
|
+
return { kind: "unused", problem: unusedEntryProblem(rules, entry.rule, left) };
|
|
57
|
+
}
|
|
58
|
+
const count = countOf(group);
|
|
59
|
+
if (count > allowed) {
|
|
60
|
+
return { kind: "regression", regression: { ...(share === "" ? {} : { allowed }), count, entry } };
|
|
61
|
+
}
|
|
62
|
+
return count < allowed && exact
|
|
63
|
+
? { kind: "covered", loose: `allows more than is left: ${count} against ${allowed} baselined${share}` }
|
|
64
|
+
: { kind: "covered" };
|
|
65
|
+
}
|
|
66
|
+
|
|
26
67
|
export function applyBaseline(violations: readonly Violation[], entries: readonly BaselineEntry[], rules: RuleIndex): BaselineCheck {
|
|
27
68
|
const groups = groupBy(violations, (violation) => keyOf(violation.rule, violation.file));
|
|
28
69
|
const covered = new Set<string>();
|
|
29
70
|
const regressions: Regression[] = [];
|
|
30
71
|
const stale: StaleBaselineEntry[] = [];
|
|
31
72
|
const loose: StaleBaselineEntry[] = [];
|
|
32
|
-
for (const entry of entries) {
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (count > entry.count) {
|
|
44
|
-
regressions.push({ count, entry });
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
covered.add(keyOf(entry.rule, entry.file));
|
|
48
|
-
if (count < entry.count) {
|
|
49
|
-
loose.push({ entry, problem: `allows more than is left: ${count} against ${entry.count} baselined` });
|
|
73
|
+
for (const entry of entries.filter((candidate) => !skipped(rules, candidate.rule))) {
|
|
74
|
+
const judged = verdict(entry, groups.get(keyOf(entry.rule, entry.file)) ?? [], rules);
|
|
75
|
+
if (judged.kind === "unused") {
|
|
76
|
+
(levelOf(rules, entry.rule) === undefined ? stale : loose).push({ entry, problem: judged.problem });
|
|
77
|
+
} else if (judged.kind === "regression") {
|
|
78
|
+
regressions.push(judged.regression);
|
|
79
|
+
} else if (judged.kind === "covered") {
|
|
80
|
+
covered.add(keyOf(entry.rule, entry.file));
|
|
81
|
+
if (judged.loose !== undefined) {
|
|
82
|
+
loose.push({ entry, problem: judged.loose });
|
|
83
|
+
}
|
|
50
84
|
}
|
|
51
85
|
}
|
|
52
86
|
const kept = violations.filter((violation) => !covered.has(keyOf(violation.rule, violation.file)));
|
|
53
87
|
return { baselined: violations.length - kept.length, kept, loose, regressions, stale };
|
|
54
88
|
}
|
|
89
|
+
|
|
90
|
+
export function unsplitEntries(entries: readonly BaselineEntry[], rules: RuleIndex): readonly StaleBaselineEntry[] {
|
|
91
|
+
return entries
|
|
92
|
+
.filter((entry) => entry.deep === undefined && isSplit(rules, entry.rule) && !halfSkipped(rules, entry.rule))
|
|
93
|
+
.map((entry) => ({ entry, problem: "does not record how many of its findings the deep half reports" }));
|
|
94
|
+
}
|
package/src/baseline/format.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { keyOf } from "#engine/violation.ts";
|
|
|
4
4
|
|
|
5
5
|
const Line = Schema.Struct({
|
|
6
6
|
count: Schema.Int.check(Schema.isGreaterThan(0)),
|
|
7
|
+
deep: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),
|
|
7
8
|
path: Schema.NonEmptyString,
|
|
8
9
|
reason: Schema.optionalKey(Schema.NonEmptyString),
|
|
9
10
|
rule: Schema.NonEmptyString,
|
|
@@ -13,6 +14,7 @@ const BaselineLine = Schema.fromJsonString(Line);
|
|
|
13
14
|
|
|
14
15
|
export interface BaselineEntry {
|
|
15
16
|
readonly count: number;
|
|
17
|
+
readonly deep?: number;
|
|
16
18
|
readonly file: string;
|
|
17
19
|
readonly reason?: string;
|
|
18
20
|
readonly rule: string;
|
|
@@ -44,6 +46,9 @@ export function decodeBaseline(raw: string | undefined): Decoded<readonly Baseli
|
|
|
44
46
|
continue;
|
|
45
47
|
}
|
|
46
48
|
const { path, ...stored } = decoded.value;
|
|
49
|
+
if (stored.deep !== undefined && stored.deep > stored.count) {
|
|
50
|
+
issues.push(`line ${line}: records ${stored.deep} deep findings of a count of ${stored.count}`);
|
|
51
|
+
}
|
|
47
52
|
if (seen.has(keyOf(stored.rule, path))) {
|
|
48
53
|
issues.push(`line ${line}: repeats the entry for ${stored.rule} in ${path}`);
|
|
49
54
|
}
|
|
@@ -53,10 +58,10 @@ export function decodeBaseline(raw: string | undefined): Decoded<readonly Baseli
|
|
|
53
58
|
return issues.length === 0 ? { _tag: "Valid", value: entries } : { _tag: "Invalid", issues };
|
|
54
59
|
}
|
|
55
60
|
|
|
56
|
-
const LINE_KEYS = ["path", "rule", "count", "reason"];
|
|
61
|
+
const LINE_KEYS = ["path", "rule", "count", "deep", "reason"];
|
|
57
62
|
|
|
58
63
|
export function encodeEntry(entry: BaselineEntry): string {
|
|
59
|
-
return JSON.stringify({ count: entry.count, path: entry.file, reason: entry.reason, rule: entry.rule }, LINE_KEYS);
|
|
64
|
+
return JSON.stringify({ count: entry.count, deep: entry.deep, path: entry.file, reason: entry.reason, rule: entry.rule }, LINE_KEYS);
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
export function encodeBaseline(entries: readonly BaselineEntry[]): string {
|
package/src/baseline/merge.ts
CHANGED
|
@@ -4,6 +4,17 @@ import { validOrFail } from "#decoded.ts";
|
|
|
4
4
|
import { keyOf } from "#engine/violation.ts";
|
|
5
5
|
import { SetupFailure } from "#failure.ts";
|
|
6
6
|
|
|
7
|
+
// A split entry merges each half on its own; when either side has not recorded the split, the totals merge as before.
|
|
8
|
+
function merged(a: BaselineEntry, b: BaselineEntry): readonly BaselineEntry[] {
|
|
9
|
+
const { deep: _recorded, ...entry } = a;
|
|
10
|
+
if (a.deep === undefined || b.deep === undefined) {
|
|
11
|
+
return [{ ...entry, count: Math.min(a.count, b.count) }];
|
|
12
|
+
}
|
|
13
|
+
const deep = Math.min(a.deep, b.deep);
|
|
14
|
+
const count = Math.min(a.count - a.deep, b.count - b.deep) + deep;
|
|
15
|
+
return count === 0 ? [] : [{ ...entry, count, deep }];
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
function mergeEntries(base: readonly BaselineEntry[], ours: readonly BaselineEntry[], theirs: readonly BaselineEntry[]): readonly BaselineEntry[] {
|
|
8
19
|
const original = new Set(base.map((entry) => keyOf(entry.rule, entry.file)));
|
|
9
20
|
const left = new Map(ours.map((entry) => [keyOf(entry.rule, entry.file), entry]));
|
|
@@ -14,8 +25,11 @@ function mergeEntries(base: readonly BaselineEntry[], ours: readonly BaselineEnt
|
|
|
14
25
|
if (original.has(key) && (a === undefined || b === undefined)) {
|
|
15
26
|
return [];
|
|
16
27
|
}
|
|
28
|
+
if (a !== undefined && b !== undefined) {
|
|
29
|
+
return merged(a, b);
|
|
30
|
+
}
|
|
17
31
|
const entry = a ?? b;
|
|
18
|
-
return entry === undefined ? [] : [
|
|
32
|
+
return entry === undefined ? [] : [entry];
|
|
19
33
|
});
|
|
20
34
|
}
|
|
21
35
|
|
package/src/baseline/rewrite.ts
CHANGED
|
@@ -13,7 +13,9 @@ export function rewriteBaseline(raw: string | undefined, before: readonly Baseli
|
|
|
13
13
|
const entry = wanted.get(keyOf(old.rule, old.file));
|
|
14
14
|
const line = lines[index];
|
|
15
15
|
wanted.delete(keyOf(old.rule, old.file));
|
|
16
|
-
return entry === undefined
|
|
16
|
+
return entry === undefined
|
|
17
|
+
? []
|
|
18
|
+
: [{ entry, text: line !== undefined && old.count === entry.count && old.deep === entry.deep ? line.text : encodeEntry(entry) }];
|
|
17
19
|
});
|
|
18
20
|
for (const entry of [...wanted.values()].sort(byPathAndRule)) {
|
|
19
21
|
const at = rows.findIndex((row) => byPathAndRule(row.entry, entry) > 0);
|
package/src/baseline/update.ts
CHANGED
|
@@ -1,29 +1,52 @@
|
|
|
1
1
|
import { countOf } from "#baseline/compare.ts";
|
|
2
2
|
import type { BaselineEntry } from "#baseline/format.ts";
|
|
3
|
-
import { covers, groupBy, keyOf, levelOf, type RuleIndex, type Violation } from "#engine/violation.ts";
|
|
3
|
+
import { covers, groupBy, isSplit, keyOf, levelOf, type RuleIndex, type Violation } from "#engine/violation.ts";
|
|
4
4
|
|
|
5
5
|
export type Adoption =
|
|
6
6
|
| { readonly _tag: "Refused"; readonly reasons: readonly string[] }
|
|
7
7
|
| { readonly _tag: "Adopted"; readonly entries: readonly BaselineEntry[]; readonly added: number; readonly replaced: number };
|
|
8
8
|
|
|
9
|
+
export interface Growth {
|
|
10
|
+
readonly by: number;
|
|
11
|
+
readonly file: string;
|
|
12
|
+
readonly rule: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
export interface Pruned {
|
|
10
16
|
readonly entries: readonly BaselineEntry[];
|
|
17
|
+
readonly grown: readonly Growth[];
|
|
11
18
|
readonly lowered: number;
|
|
12
19
|
readonly moved: number;
|
|
13
20
|
readonly removed: number;
|
|
21
|
+
readonly split: number;
|
|
14
22
|
}
|
|
15
23
|
|
|
16
|
-
function record(violations: readonly Violation[]): readonly BaselineEntry[] {
|
|
24
|
+
function record(violations: readonly Violation[], index: RuleIndex): readonly BaselineEntry[] {
|
|
17
25
|
return [...groupBy(violations, (violation) => keyOf(violation.rule, violation.file)).values()].flatMap((group) => {
|
|
18
26
|
const first = group[0];
|
|
19
27
|
if (first === undefined) {
|
|
20
28
|
return [];
|
|
21
29
|
}
|
|
22
30
|
const count = countOf(group);
|
|
23
|
-
|
|
31
|
+
const deep = isSplit(index, first.rule) ? { deep: countOf(group.filter((violation) => violation.deep === true)) } : {};
|
|
32
|
+
return count > 0 ? [{ count, ...deep, file: first.file, rule: first.rule }] : [];
|
|
24
33
|
});
|
|
25
34
|
}
|
|
26
35
|
|
|
36
|
+
// Each half only ever lowers its own share, so a split entry keeps the smaller fast share and the smaller deep share.
|
|
37
|
+
function lowered(before: BaselineEntry, now: BaselineEntry): BaselineEntry | undefined {
|
|
38
|
+
const { deep: _recorded, ...kept } = before;
|
|
39
|
+
if (now.deep === undefined) {
|
|
40
|
+
return { ...kept, count: Math.min(before.count, now.count), file: now.file };
|
|
41
|
+
}
|
|
42
|
+
if (before.deep === undefined) {
|
|
43
|
+
return now.count > before.count ? { ...kept, file: now.file } : { ...kept, count: now.count, deep: now.deep, file: now.file };
|
|
44
|
+
}
|
|
45
|
+
const deep = Math.min(before.deep, now.deep);
|
|
46
|
+
const count = Math.min(before.count - before.deep, now.count - now.deep) + deep;
|
|
47
|
+
return count === 0 ? undefined : { ...kept, count, deep, file: now.file };
|
|
48
|
+
}
|
|
49
|
+
|
|
27
50
|
function refusal(id: string, index: RuleIndex): readonly string[] {
|
|
28
51
|
const level = levelOf(index, id);
|
|
29
52
|
if (level === undefined) {
|
|
@@ -47,7 +70,7 @@ export function adopt(
|
|
|
47
70
|
}
|
|
48
71
|
const kept = (existing ?? []).filter((entry) => !named(entry.rule));
|
|
49
72
|
const adopted = violations.filter((violation) => named(violation.rule));
|
|
50
|
-
const added = record(adopted);
|
|
73
|
+
const added = record(adopted, index);
|
|
51
74
|
return { _tag: "Adopted", added: added.length, entries: [...kept, ...added], replaced: (existing ?? []).length - kept.length };
|
|
52
75
|
}
|
|
53
76
|
|
|
@@ -77,25 +100,32 @@ export function prune(
|
|
|
77
100
|
index: RuleIndex,
|
|
78
101
|
scope: Scope = { moves: new Map() },
|
|
79
102
|
): Pruned {
|
|
80
|
-
const current = new Map(record(violations).map((entry) => [keyOf(entry.rule, entry.file), entry]));
|
|
103
|
+
const current = new Map(record(violations, index).map((entry) => [keyOf(entry.rule, entry.file), entry]));
|
|
81
104
|
const taken = new Set(existing.map((entry) => keyOf(entry.rule, entry.file)));
|
|
82
105
|
let moved = 0;
|
|
106
|
+
const grown: Growth[] = [];
|
|
83
107
|
const kept = existing.flatMap((before) => {
|
|
84
108
|
if (!inScope(before, scope)) {
|
|
85
109
|
return [{ after: before, before }];
|
|
86
110
|
}
|
|
87
111
|
const level = levelOf(index, before.rule);
|
|
88
112
|
const now = current.get(keyOf(before.rule, before.file)) ?? destination(before, current, scope.moves, taken);
|
|
89
|
-
if (now
|
|
113
|
+
if (now?.deep !== undefined && before.deep !== undefined && now.deep > before.deep) {
|
|
114
|
+
grown.push({ by: now.deep - before.deep, file: now.file, rule: before.rule });
|
|
115
|
+
}
|
|
116
|
+
const after = now === undefined || level === undefined ? undefined : lowered(before, now);
|
|
117
|
+
if (after === undefined) {
|
|
90
118
|
return [];
|
|
91
119
|
}
|
|
92
|
-
moved += Number(
|
|
93
|
-
return [{ after
|
|
120
|
+
moved += Number(after.file !== before.file);
|
|
121
|
+
return [{ after, before }];
|
|
94
122
|
});
|
|
95
123
|
return {
|
|
96
124
|
entries: kept.map(({ after }) => after),
|
|
125
|
+
grown,
|
|
97
126
|
lowered: kept.filter(({ after, before }) => after.count !== before.count).length,
|
|
98
127
|
moved,
|
|
99
128
|
removed: existing.length - kept.length,
|
|
129
|
+
split: kept.filter(({ after, before }) => after.count === before.count && after.deep !== before.deep).length,
|
|
100
130
|
};
|
|
101
131
|
}
|
|
@@ -7,15 +7,36 @@ function nativeOverride(files: readonly string[], rule: string): unknown {
|
|
|
7
7
|
return { includes: files, [key]: { [settings]: { [group]: { [name]: "off" } } } };
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export function fileExclusions(declarations: readonly ExceptionDeclaration[]): readonly ExceptionDeclaration[] {
|
|
11
|
+
return declarations.flatMap((entry) =>
|
|
12
|
+
entry.rules.includes("biome/files/includes") ? [{ ...entry, rules: ["biome/files/includes"] as const }] : [],
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type RulesOff = Readonly<Record<string, Readonly<Record<string, "off">>>>;
|
|
17
|
+
|
|
18
|
+
function everywhere({ files, rule }: { readonly files: readonly string[]; readonly rule: string }): boolean {
|
|
19
|
+
return rule.startsWith("biome/lint/") && files.length === 1 && files[0] === "**";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// A lint rule excepted for every file is turned off at the top level: an override that sets lint rules turns the linter back on where an earlier override disabled it.
|
|
10
23
|
export function exceptionConfig(declarations: readonly ExceptionDeclaration[]): {
|
|
11
24
|
readonly includes: readonly string[];
|
|
12
25
|
readonly overrides: readonly unknown[];
|
|
26
|
+
readonly rules: RulesOff;
|
|
13
27
|
} {
|
|
14
28
|
const includes = declarations.filter((entry) => entry.rules.includes("biome/files/includes")).flatMap((entry) => entry.files);
|
|
29
|
+
const native = declarations.flatMap((entry) =>
|
|
30
|
+
entry.rules.filter((rule) => /^biome\/(?:lint|assist)\//u.test(rule)).map((rule) => ({ files: entry.files, rule })),
|
|
31
|
+
);
|
|
32
|
+
const rules: Record<string, Record<string, "off">> = {};
|
|
33
|
+
for (const { rule } of native.filter(everywhere)) {
|
|
34
|
+
const [, , group = "", name = ""] = rule.split("/");
|
|
35
|
+
rules[group] = { ...rules[group], [name]: "off" };
|
|
36
|
+
}
|
|
15
37
|
return {
|
|
16
38
|
includes: includes.length === 0 ? [] : ["**", ...includes.filter((pattern) => pattern !== "**")],
|
|
17
|
-
overrides:
|
|
18
|
-
|
|
19
|
-
),
|
|
39
|
+
overrides: native.filter((entry) => !everywhere(entry)).map(({ files, rule }) => nativeOverride(files, rule)),
|
|
40
|
+
rules,
|
|
20
41
|
};
|
|
21
42
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Biome names a rule's domains only in `biome explain`, one rule per process, so the list is kept here and scannerDomains.heavy.spec.ts compares it with the installed Biome.
|
|
2
|
+
export const SCANNER_RULES: ReadonlySet<string> = new Set([
|
|
3
|
+
"lint/complexity/useArrayFind",
|
|
4
|
+
"lint/correctness/noPrivateImports",
|
|
5
|
+
"lint/correctness/noUndeclaredDependencies",
|
|
6
|
+
"lint/correctness/noUnresolvedImports",
|
|
7
|
+
"lint/correctness/useImportExtensions",
|
|
8
|
+
"lint/correctness/useJsonImportAttributes",
|
|
9
|
+
"lint/nursery/noBaseToString",
|
|
10
|
+
"lint/nursery/noFloatingPromises",
|
|
11
|
+
"lint/nursery/noMeaninglessVoidOperator",
|
|
12
|
+
"lint/nursery/noMisleadingReturnType",
|
|
13
|
+
"lint/nursery/noMisusedPromises",
|
|
14
|
+
"lint/nursery/noSelfImport",
|
|
15
|
+
"lint/nursery/noTailwindRawColors",
|
|
16
|
+
"lint/nursery/noUndeclaredClasses",
|
|
17
|
+
"lint/nursery/noUndeclaredCustomProperties",
|
|
18
|
+
"lint/nursery/noUnsafePlusOperands",
|
|
19
|
+
"lint/nursery/noUnsafeReturn",
|
|
20
|
+
"lint/nursery/noUnsafeUnaryMinus",
|
|
21
|
+
"lint/nursery/noUnusedClasses",
|
|
22
|
+
"lint/nursery/noUselessTypeConversion",
|
|
23
|
+
"lint/nursery/useAwaitThenable",
|
|
24
|
+
"lint/nursery/useDisposables",
|
|
25
|
+
"lint/nursery/useExhaustiveSwitchCases",
|
|
26
|
+
"lint/nursery/useIncludes",
|
|
27
|
+
"lint/nursery/useNullishCoalescing",
|
|
28
|
+
"lint/nursery/useRegexpExec",
|
|
29
|
+
"lint/nursery/useStrictBooleanExpressions",
|
|
30
|
+
"lint/nursery/useStringStartsEndsWith",
|
|
31
|
+
"lint/nursery/useTailwindSortedClasses",
|
|
32
|
+
"lint/style/useConsistentEnumValueType",
|
|
33
|
+
"lint/suspicious/noDeprecatedImports",
|
|
34
|
+
"lint/suspicious/noImportCycles",
|
|
35
|
+
"lint/suspicious/noUnnecessaryConditions",
|
|
36
|
+
"lint/suspicious/noUntrustedLicenses",
|
|
37
|
+
"lint/suspicious/useArraySortCompare",
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
export function needsScanner(category: string | undefined): boolean {
|
|
41
|
+
return category !== undefined && SCANNER_RULES.has(category);
|
|
42
|
+
}
|