@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
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as NodePath from "@effect/platform-node/NodePath";
|
|
2
|
+
import { Console, Effect, FileSystem, Path } from "effect";
|
|
3
|
+
import type { ChildProcessSpawner } from "effect/process";
|
|
4
|
+
import { SetupFailure } from "#failure.ts";
|
|
5
|
+
import { gitOrFail } from "#git/command.ts";
|
|
6
|
+
import { shellWords } from "#hooks/command.ts";
|
|
7
|
+
import { orWhenAbsent } from "#inventory/filesystem.ts";
|
|
8
|
+
|
|
9
|
+
type WorkingCopy =
|
|
10
|
+
| { readonly kind: "absent"; readonly path: string }
|
|
11
|
+
| { readonly blob: string; readonly bytes: Uint8Array; readonly kind: "file"; readonly mode: number; readonly path: string }
|
|
12
|
+
| { readonly kind: "link"; readonly path: string; readonly target: string };
|
|
13
|
+
|
|
14
|
+
function failed(error: { readonly message: string }): SetupFailure {
|
|
15
|
+
return new SetupFailure({ cause: error, message: error.message });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function recovery(copy: WorkingCopy): string {
|
|
19
|
+
const path = shellWords([copy.path]);
|
|
20
|
+
switch (copy.kind) {
|
|
21
|
+
case "absent":
|
|
22
|
+
return `rm -f ${path}`;
|
|
23
|
+
case "file":
|
|
24
|
+
return `git cat-file blob ${copy.blob} > ${path} && chmod ${copy.mode.toString(8)} ${path}`;
|
|
25
|
+
case "link":
|
|
26
|
+
return `ln -sfn ${shellWords([copy.target])} ${path}`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function notice(root: string, copies: readonly WorkingCopy[]): string {
|
|
31
|
+
const [only] = copies;
|
|
32
|
+
const intro =
|
|
33
|
+
copies.length === 1 && only !== undefined
|
|
34
|
+
? `${only.path} changed after staging; Biome checks its staged content in place, then the working copy is put back. If the hook stops first, run this in ${root}:`
|
|
35
|
+
: `${copies.length} files changed after staging; Biome checks their staged content in place, then the working copies are put back. If the hook stops first, run these in ${root}:`;
|
|
36
|
+
return [`quality: ${intro}`, ...copies.map((copy) => ` ${recovery(copy)}`)].join("\n");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// The blob outlives a killed hook, so the printed command still recovers the working copy.
|
|
40
|
+
const setAside = Effect.fn("Hooks.setAside")(function* (
|
|
41
|
+
root: string,
|
|
42
|
+
path: string,
|
|
43
|
+
): Effect.fn.Return<WorkingCopy, SetupFailure, FileSystem.FileSystem | ChildProcessSpawner.ChildProcessSpawner> {
|
|
44
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
45
|
+
|
|
46
|
+
const fs = yield* FileSystem.FileSystem;
|
|
47
|
+
const at = join(root, path);
|
|
48
|
+
const info = yield* orWhenAbsent(at, fs.lstat(at), undefined).pipe(Effect.mapError(failed));
|
|
49
|
+
if (info === undefined) {
|
|
50
|
+
return { kind: "absent", path };
|
|
51
|
+
}
|
|
52
|
+
if (info.type === "SymbolicLink") {
|
|
53
|
+
return { kind: "link", path, target: yield* fs.readLink(at).pipe(Effect.mapError(failed)) };
|
|
54
|
+
}
|
|
55
|
+
if (info.type !== "File") {
|
|
56
|
+
return yield* new SetupFailure({ message: `${path} changed after staging into a ${info.type}, so the staged check cannot set it aside.` });
|
|
57
|
+
}
|
|
58
|
+
const bytes = yield* fs.readFile(at).pipe(Effect.mapError(failed));
|
|
59
|
+
const blob = (yield* gitOrFail(root, ["hash-object", "-w", "--no-filters", "--", path])).trim();
|
|
60
|
+
return { blob, bytes, kind: "file", mode: info.mode & 0o7777, path };
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const setAsideAll = Effect.fn("Hooks.setAsideAll")(function* (root: string, paths: readonly string[]) {
|
|
64
|
+
const copies = yield* Effect.forEach(paths, (path) => setAside(root, path));
|
|
65
|
+
yield* Console.log(notice(root, copies));
|
|
66
|
+
return copies;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const putBack = Effect.fn("Hooks.putBack")(function* (root: string, copy: WorkingCopy) {
|
|
70
|
+
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
71
|
+
|
|
72
|
+
const fs = yield* FileSystem.FileSystem;
|
|
73
|
+
const at = join(root, copy.path);
|
|
74
|
+
yield* fs.remove(at, { force: true });
|
|
75
|
+
if (copy.kind === "file") {
|
|
76
|
+
yield* fs.writeFile(at, copy.bytes);
|
|
77
|
+
yield* fs.chmod(at, copy.mode);
|
|
78
|
+
}
|
|
79
|
+
if (copy.kind === "link") {
|
|
80
|
+
yield* fs.symlink(copy.target, at);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const restore = Effect.fn("Hooks.restore")(function* (root: string, copies: readonly WorkingCopy[]) {
|
|
85
|
+
const [, failures] = yield* Effect.partition(copies, (copy) => Effect.mapError(putBack(root, copy), (error) => ({ copy, error })));
|
|
86
|
+
if (failures.length === 0) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const lines = failures.map(({ copy, error }) => `quality: cannot put back the working copy of ${copy.path}: ${error.message}\n ${recovery(copy)}`);
|
|
90
|
+
yield* Console.error(lines.join("\n"));
|
|
91
|
+
return yield* new SetupFailure({
|
|
92
|
+
message: `${failures.length === 1 ? "a working copy was" : `${failures.length} working copies were`} not put back; run the commands above in ${root}.`,
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Biome reports no diagnostics for content piped to its stdin, so a file edited again after staging shows Biome its staged content
|
|
97
|
+
// on disk until the check ends.
|
|
98
|
+
export const withStagedContent = Effect.fn("Hooks.withStagedContent")(function* <TValue, TError, TRequirements>(
|
|
99
|
+
root: string,
|
|
100
|
+
edited: readonly string[],
|
|
101
|
+
check: Effect.Effect<TValue, TError, TRequirements>,
|
|
102
|
+
) {
|
|
103
|
+
if (edited.length === 0) {
|
|
104
|
+
return yield* check;
|
|
105
|
+
}
|
|
106
|
+
return yield* Effect.acquireUseRelease(
|
|
107
|
+
setAsideAll(root, edited),
|
|
108
|
+
() => Effect.andThen(gitOrFail(root, ["--literal-pathspecs", "checkout-index", "--force", "--", ...edited]), check),
|
|
109
|
+
(copies) => restore(root, copies),
|
|
110
|
+
);
|
|
111
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { dirname, join } from "node:path";
|
|
2
|
-
import { Effect, type FileSystem } from "effect";
|
|
2
|
+
import { type Context, Effect, type FileSystem } from "effect";
|
|
3
3
|
import ts from "typescript";
|
|
4
|
+
import { DeclarationFiles } from "#adapters/declaration-files/service.ts";
|
|
4
5
|
import { type FilesystemFailure, readRequiredText } from "#inventory/filesystem.ts";
|
|
5
6
|
|
|
6
7
|
const portable = new Set([
|
|
@@ -67,8 +68,7 @@ const portable = new Set([
|
|
|
67
68
|
"structuredClone",
|
|
68
69
|
]);
|
|
69
70
|
|
|
70
|
-
function namesInDom(
|
|
71
|
-
const source = ts.createSourceFile(path, text, ts.ScriptTarget.Latest, true);
|
|
71
|
+
function namesInDom(source: ts.SourceFile): readonly string[] {
|
|
72
72
|
return source.statements.flatMap((statement) => {
|
|
73
73
|
if (ts.isVariableStatement(statement)) {
|
|
74
74
|
return statement.declarationList.declarations.flatMap(({ name }) => (ts.isIdentifier(name) ? [name.text] : []));
|
|
@@ -80,9 +80,11 @@ function namesInDom(path: string, text: string): readonly string[] {
|
|
|
80
80
|
export const browserNames = Effect.fn("Imports.browserNames")(function* (): Effect.fn.Return<
|
|
81
81
|
ReadonlySet<string>,
|
|
82
82
|
FilesystemFailure,
|
|
83
|
-
FileSystem.FileSystem
|
|
83
|
+
Context.Service.Identifier<typeof DeclarationFiles> | FileSystem.FileSystem
|
|
84
84
|
> {
|
|
85
85
|
const path = join(dirname(ts.getDefaultLibFilePath({})), "lib.dom.d.ts");
|
|
86
86
|
const text = yield* readRequiredText(path);
|
|
87
|
-
|
|
87
|
+
const declarations = yield* DeclarationFiles;
|
|
88
|
+
const source = yield* declarations.parse(path, text, { target: ts.ScriptTarget.Latest });
|
|
89
|
+
return new Set(namesInDom(source).filter((name) => !portable.has(name)));
|
|
88
90
|
});
|
|
@@ -8,6 +8,6 @@ import type { RuleInputs } from "#rule.ts";
|
|
|
8
8
|
export const checkFences = Effect.fn("Imports.checkFences")(function* (inputs: RuleInputs, configured: readonly Fence[]) {
|
|
9
9
|
const graph = yield* importGraph(inputs);
|
|
10
10
|
const fences = [...configured, ...(yield* discoverFences(inputs, graph.packages))];
|
|
11
|
-
const policy = compilePolicy(fences, { files: inputs.files, packages: graph.packages });
|
|
11
|
+
const policy = yield* Effect.fromResult(compilePolicy(fences, { files: inputs.files, packages: graph.packages }));
|
|
12
12
|
return policy.flatMap((compiled) => compiled.evaluate(graph));
|
|
13
13
|
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Result } from "effect";
|
|
1
2
|
import type { Endpoint } from "#imports/Endpoint.ts";
|
|
3
|
+
import { BoundaryFailure } from "#imports/fences/BoundaryFailure.ts";
|
|
2
4
|
import { type CompiledFence, compileFence, type FenceGraph } from "#imports/fences/evaluate.ts";
|
|
3
5
|
import type { PolicyScope } from "#imports/fences/match.ts";
|
|
4
6
|
import type { Chain, ExampleStep, Fence } from "#imports/fences/model.ts";
|
|
@@ -24,7 +26,7 @@ function graphOf(chain: Chain): FenceGraph | undefined {
|
|
|
24
26
|
const edges = files.map(
|
|
25
27
|
(from, index): ImportEdge => ({ from, kind: "import", line: 1, specifier: "", to: endpointOf(chain[index + 1] ?? from), type: false }),
|
|
26
28
|
);
|
|
27
|
-
return { edges, modules: files };
|
|
29
|
+
return { edges, ignoredEdges: [], modules: files };
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
function crossedBy(policy: readonly CompiledFence[], graph: FenceGraph): readonly string[] {
|
|
@@ -66,14 +68,14 @@ function declarationIssues(fences: readonly Fence[]): readonly string[] {
|
|
|
66
68
|
]);
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
export function compilePolicy(fences: readonly Fence[], scope: PolicyScope): readonly CompiledFence[] {
|
|
71
|
+
export function compilePolicy(fences: readonly Fence[], scope: PolicyScope): Result.Result<readonly CompiledFence[], BoundaryFailure> {
|
|
70
72
|
const issues = [...declarationIssues(fences)];
|
|
71
73
|
const policy = fences.map((fence) => compileFence({ issues, scope }, fence));
|
|
72
74
|
if (issues.length === 0) {
|
|
73
75
|
issues.push(...fences.flatMap((fence) => exampleIssues(policy, fence, scope)));
|
|
74
76
|
}
|
|
75
77
|
if (issues.length > 0) {
|
|
76
|
-
|
|
78
|
+
return Result.fail(new BoundaryFailure({ message: `the fence policy is invalid:\n${issues.map((issue) => ` - ${issue}`).join("\n")}` }));
|
|
77
79
|
}
|
|
78
|
-
return policy;
|
|
80
|
+
return Result.succeed(policy);
|
|
79
81
|
}
|
|
@@ -6,7 +6,7 @@ import type { ImportEdge, ImportGraph } from "#imports/graph.ts";
|
|
|
6
6
|
import { isTestCode } from "#naming/testName.ts";
|
|
7
7
|
import type { Finding } from "#rule.ts";
|
|
8
8
|
|
|
9
|
-
export type FenceGraph = Pick<ImportGraph, "edges" | "modules">;
|
|
9
|
+
export type FenceGraph = Pick<ImportGraph, "edges" | "ignoredEdges" | "modules">;
|
|
10
10
|
|
|
11
11
|
export type Evaluate = (graph: FenceGraph) => readonly Finding[];
|
|
12
12
|
|
|
@@ -49,7 +49,7 @@ function importFindings(fence: Fence, importer: (path: string) => boolean, to: M
|
|
|
49
49
|
|
|
50
50
|
function reachFindings(fence: Fence, importer: (path: string) => boolean, to: Matcher): Evaluate {
|
|
51
51
|
return (graph) => {
|
|
52
|
-
const edgesFrom = outgoing(graph.edges);
|
|
52
|
+
const edgesFrom = outgoing([...graph.edges, ...graph.ignoredEdges]);
|
|
53
53
|
return graph.modules.filter(importer).flatMap((module) =>
|
|
54
54
|
reachedFrom(module, edgesFrom, to).map((reached) => ({
|
|
55
55
|
file: module,
|
|
@@ -36,8 +36,8 @@ function charSource(char: string): string {
|
|
|
36
36
|
return REGEX_SYNTAX.test(char) ? `\\${char}` : char;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
function unreadable(pattern: string, problem: string):
|
|
40
|
-
return new
|
|
39
|
+
function unreadable(pattern: string, problem: string): GlobFailure {
|
|
40
|
+
return new GlobFailure({ message: `cannot read the workspace pattern "${pattern}": ${problem}` });
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function closingBrace(text: string, open: number): number {
|
|
@@ -65,72 +65,79 @@ function choices(body: string): readonly string[] {
|
|
|
65
65
|
return parts;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function expanded(pattern: string, whole: string): readonly string[] {
|
|
68
|
+
function expanded(pattern: string, whole: string): Result.Result<readonly string[], GlobFailure> {
|
|
69
69
|
const open = pattern.indexOf("{");
|
|
70
70
|
if (open === -1) {
|
|
71
|
-
return [pattern];
|
|
71
|
+
return Result.succeed([pattern]);
|
|
72
72
|
}
|
|
73
73
|
const close = closingBrace(pattern, open);
|
|
74
74
|
if (close === -1) {
|
|
75
|
-
|
|
75
|
+
return Result.fail(unreadable(whole, "a { never closes"));
|
|
76
76
|
}
|
|
77
77
|
const body = pattern.slice(open + 1, close);
|
|
78
78
|
if (BRACE_RANGE.test(body)) {
|
|
79
|
-
|
|
79
|
+
return Result.fail(unreadable(whole, "brace ranges are not supported"));
|
|
80
80
|
}
|
|
81
81
|
const options = choices(body);
|
|
82
82
|
if (options.length < 2) {
|
|
83
|
-
|
|
83
|
+
return Result.fail(unreadable(whole, "a { } needs two or more choices"));
|
|
84
84
|
}
|
|
85
|
-
return options.
|
|
85
|
+
return Result.map(Result.all(options.map((option) => expanded(`${pattern.slice(0, open)}${option}${pattern.slice(close + 1)}`, whole))), (found) =>
|
|
86
|
+
found.flat(),
|
|
87
|
+
);
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
function characterClass(
|
|
90
|
+
function characterClass(
|
|
91
|
+
segment: string,
|
|
92
|
+
start: number,
|
|
93
|
+
whole: string,
|
|
94
|
+
): Result.Result<{ readonly end: number; readonly source: string }, GlobFailure> {
|
|
89
95
|
const negated = segment[start + 1] === "!" || segment[start + 1] === "^";
|
|
90
96
|
const first = start + (negated ? 2 : 1);
|
|
91
97
|
const end = segment.indexOf("]", segment[first] === "]" ? first + 1 : first);
|
|
92
98
|
if (end === -1) {
|
|
93
|
-
|
|
99
|
+
return Result.fail(unreadable(whole, "a [ never closes"));
|
|
94
100
|
}
|
|
95
101
|
const body = segment.slice(first, end);
|
|
96
102
|
if (body.includes("[:")) {
|
|
97
|
-
|
|
103
|
+
return Result.fail(unreadable(whole, "character class names are not supported"));
|
|
98
104
|
}
|
|
99
|
-
return { end, source: `[${negated ? "^" : ""}${body.replace(CLASS_SYNTAX, "\\$&")}]` };
|
|
105
|
+
return Result.succeed({ end, source: `[${negated ? "^" : ""}${body.replace(CLASS_SYNTAX, "\\$&")}]` });
|
|
100
106
|
}
|
|
101
107
|
|
|
102
|
-
function segmentOf(segment: string, whole: string): Segment {
|
|
108
|
+
function segmentOf(segment: string, whole: string): Result.Result<Segment, GlobFailure> {
|
|
103
109
|
if (segment === GLOBSTAR) {
|
|
104
|
-
return GLOBSTAR;
|
|
110
|
+
return Result.succeed(GLOBSTAR);
|
|
105
111
|
}
|
|
106
112
|
if (EXTGLOB.test(segment)) {
|
|
107
|
-
|
|
113
|
+
return Result.fail(unreadable(whole, "extended globs are not supported"));
|
|
108
114
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
return Result.gen(function* () {
|
|
116
|
+
let source = "";
|
|
117
|
+
for (let index = 0; index < segment.length; index += 1) {
|
|
118
|
+
const char = segment[index] ?? "";
|
|
119
|
+
if (char === "[") {
|
|
120
|
+
const found = yield* characterClass(segment, index, whole);
|
|
121
|
+
source += found.source;
|
|
122
|
+
index = found.end;
|
|
123
|
+
} else {
|
|
124
|
+
source += charSource(char);
|
|
125
|
+
}
|
|
118
126
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const alternatives = expanded(pattern, pattern).map((alternative) => alternative.split("/").map((segment) => segmentOf(segment, pattern)));
|
|
125
|
-
return (path) => alternatives.some((segments) => segmentsMatch(segments, path.split("/")));
|
|
127
|
+
return yield* Result.try({
|
|
128
|
+
catch: (cause) => new GlobFailure({ message: cause instanceof Error ? cause.message : String(cause) }),
|
|
129
|
+
try: (): Segment => new RegExp(`^${segment.startsWith(DOT) ? "" : NO_DOT}${source}$`, "u"),
|
|
130
|
+
});
|
|
131
|
+
});
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
export function globMatcher(pattern: string): Result.Result<(path: string) => boolean, GlobFailure> {
|
|
129
135
|
if (pattern.includes("\\")) {
|
|
130
|
-
return Result.fail(
|
|
136
|
+
return Result.fail(unreadable(pattern, "escapes are not supported"));
|
|
131
137
|
}
|
|
132
|
-
return Result.
|
|
133
|
-
|
|
134
|
-
|
|
138
|
+
return Result.gen(function* () {
|
|
139
|
+
const options = yield* expanded(pattern, pattern);
|
|
140
|
+
const alternatives = yield* Result.all(options.map((option) => Result.all(option.split("/").map((segment) => segmentOf(segment, pattern)))));
|
|
141
|
+
return (path: string) => alternatives.some((segments) => segmentsMatch(segments, path.split("/")));
|
|
135
142
|
});
|
|
136
143
|
}
|
package/src/imports/graph.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
1
2
|
import { Effect } from "effect";
|
|
3
|
+
import type { ChildProcessSpawner } from "effect/process";
|
|
4
|
+
import type { ImportAnalysisFailure } from "#adapters/ImportAnalysisFailure.ts";
|
|
2
5
|
import { ImportCompiler } from "#adapters/import-compiler/service.ts";
|
|
3
6
|
import type { Endpoint } from "#imports/Endpoint.ts";
|
|
4
7
|
import type { ImportKind } from "#imports/extract.ts";
|
|
5
8
|
import { type WorkspacePackage, workspacePackages } from "#imports/workspace.ts";
|
|
9
|
+
import { posix } from "#inventory/ignoreScope.ts";
|
|
10
|
+
import { linesOf } from "#inventory/linesOf.ts";
|
|
11
|
+
import { ignoredAmong } from "#inventory/trackedPaths.ts";
|
|
6
12
|
import type { Findings, RuleInputs, SourceFile } from "#rule.ts";
|
|
7
13
|
|
|
8
14
|
export interface ImportEdge {
|
|
@@ -19,14 +25,48 @@ export type UnresolvedImport = Omit<ImportEdge, "to"> & { readonly missing: stri
|
|
|
19
25
|
export interface ImportGraph {
|
|
20
26
|
readonly configFindings: Findings;
|
|
21
27
|
readonly edges: readonly ImportEdge[];
|
|
28
|
+
// Imports of the modules git ignores that the sources reach, such as generated output: rules follow them but never report them.
|
|
29
|
+
readonly ignoredEdges: readonly ImportEdge[];
|
|
30
|
+
readonly ignoredModules: readonly string[];
|
|
22
31
|
readonly modules: readonly string[];
|
|
23
32
|
readonly packages: readonly WorkspacePackage[];
|
|
24
33
|
readonly unresolved: readonly UnresolvedImport[];
|
|
25
34
|
}
|
|
26
35
|
|
|
36
|
+
const MODULE = /\.[cm]?[jt]sx?$/u;
|
|
37
|
+
|
|
38
|
+
const NODE_MODULES = /(?:^|\/)node_modules\//u;
|
|
39
|
+
|
|
40
|
+
function unlisted(listed: ReadonlySet<string>, edges: readonly ImportEdge[]): readonly string[] {
|
|
41
|
+
const paths = edges.flatMap((edge) => (edge.to.kind === "file" ? [edge.to.path] : []));
|
|
42
|
+
return [...new Set(paths)].filter((path) => !listed.has(path) && MODULE.test(path) && !NODE_MODULES.test(path) && !path.startsWith("../"));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const ignoredReach = Effect.fn("Imports.ignoredReach")(function* (
|
|
46
|
+
inputs: RuleInputs,
|
|
47
|
+
edges: readonly ImportEdge[],
|
|
48
|
+
follow: (files: readonly SourceFile[]) => Effect.Effect<readonly ImportEdge[], ImportAnalysisFailure>,
|
|
49
|
+
) {
|
|
50
|
+
const listed = new Set(inputs.files);
|
|
51
|
+
const modules: string[] = [];
|
|
52
|
+
const followed: ImportEdge[] = [];
|
|
53
|
+
for (let frontier = unlisted(listed, edges); frontier.length > 0; frontier = unlisted(listed, followed)) {
|
|
54
|
+
const ignored = (yield* ignoredAmong(inputs.root, frontier)).map((path) => posix(relative(inputs.root, path)));
|
|
55
|
+
for (const path of frontier) {
|
|
56
|
+
listed.add(path);
|
|
57
|
+
}
|
|
58
|
+
const files = yield* Effect.forEach(ignored, (path) =>
|
|
59
|
+
Effect.map(inputs.readText(path), (text) => (text === undefined ? [] : [{ lines: linesOf(text), path, text }])),
|
|
60
|
+
);
|
|
61
|
+
modules.push(...ignored);
|
|
62
|
+
followed.push(...(yield* follow(files.flat())));
|
|
63
|
+
}
|
|
64
|
+
return { ignoredEdges: followed, ignoredModules: modules };
|
|
65
|
+
});
|
|
66
|
+
|
|
27
67
|
const build = Effect.fn("Imports.build")(function* (inputs: RuleInputs) {
|
|
28
68
|
const compiler = yield* ImportCompiler;
|
|
29
|
-
const walked = yield* compiler.graph(inputs);
|
|
69
|
+
const { follow, ...walked } = yield* compiler.graph(inputs);
|
|
30
70
|
if (walked.modules.length === 0) {
|
|
31
71
|
return yield* Effect.die(
|
|
32
72
|
new Error(
|
|
@@ -34,11 +74,11 @@ const build = Effect.fn("Imports.build")(function* (inputs: RuleInputs) {
|
|
|
34
74
|
),
|
|
35
75
|
);
|
|
36
76
|
}
|
|
37
|
-
return { ...walked, packages: yield* workspacePackages(inputs) };
|
|
77
|
+
return { ...walked, ...(yield* ignoredReach(inputs, walked.edges, follow)), packages: yield* workspacePackages(inputs) };
|
|
38
78
|
});
|
|
39
79
|
|
|
40
80
|
type Graph = ReturnType<typeof build>;
|
|
41
|
-
const graphs = new WeakMap<readonly SourceFile[], Effect.Effect<ImportGraph, Effect.Error<Graph
|
|
81
|
+
const graphs = new WeakMap<readonly SourceFile[], Effect.Effect<ImportGraph, Effect.Error<Graph>, ChildProcessSpawner.ChildProcessSpawner>>();
|
|
42
82
|
|
|
43
83
|
// Import rules run on one scan, so they share the graph built from its sources.
|
|
44
84
|
export const importGraph = Effect.fn("Imports.importGraph")(function* (inputs: RuleInputs) {
|
|
@@ -50,3 +90,7 @@ export const importGraph = Effect.fn("Imports.importGraph")(function* (inputs: R
|
|
|
50
90
|
graphs.set(inputs.sources, graph);
|
|
51
91
|
return yield* graph;
|
|
52
92
|
});
|
|
93
|
+
|
|
94
|
+
export const ignoredModules = Effect.fn("Imports.ignoredModules")(function* (inputs: RuleInputs) {
|
|
95
|
+
return inputs.sources.some((file) => MODULE.test(file.path)) ? (yield* importGraph(inputs)).ignoredModules : [];
|
|
96
|
+
});
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
1
|
+
import { Data, Result, Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
export class PnpmWorkspaceFailure extends Data.TaggedError("PnpmWorkspaceFailure")<{
|
|
4
|
+
readonly cause?: unknown;
|
|
5
|
+
readonly message: string;
|
|
6
|
+
}> {}
|
|
2
7
|
|
|
3
8
|
function keyPattern(key: string): RegExp {
|
|
4
9
|
return new RegExp(`^(?:${key}|"${key}"|'${key}')\\s*:`, "u");
|
|
@@ -10,8 +15,8 @@ const SPACE = /\s/u;
|
|
|
10
15
|
|
|
11
16
|
const LINE_BREAK = /\r?\n/u;
|
|
12
17
|
|
|
13
|
-
function failure(problem: string, cause?: unknown):
|
|
14
|
-
return new
|
|
18
|
+
function failure(problem: string, cause?: unknown): PnpmWorkspaceFailure {
|
|
19
|
+
return new PnpmWorkspaceFailure({ cause, message: `pnpm-workspace.yaml: ${problem}` });
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
function withoutComment(line: string): string {
|
|
@@ -29,22 +34,20 @@ function withoutComment(line: string): string {
|
|
|
29
34
|
return line.trimEnd();
|
|
30
35
|
}
|
|
31
36
|
|
|
32
|
-
function scalar(raw: string, key: string): string {
|
|
37
|
+
function scalar(raw: string, key: string): Result.Result<string, PnpmWorkspaceFailure> {
|
|
33
38
|
const value = raw.trim();
|
|
34
39
|
if (value.startsWith('"') && value.endsWith('"') && value.length > 1) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
throw failure(`cannot read "${value}" in ${key}`, error);
|
|
39
|
-
}
|
|
40
|
+
return Result.mapError(Schema.decodeUnknownResult(Schema.fromJsonString(Schema.String))(value), (error) =>
|
|
41
|
+
failure(`cannot read "${value}" in ${key}`, error),
|
|
42
|
+
);
|
|
40
43
|
}
|
|
41
44
|
if (value.startsWith("'") && value.endsWith("'") && value.length > 1) {
|
|
42
|
-
return value.slice(1, -1).replaceAll("''", "'");
|
|
45
|
+
return Result.succeed(value.slice(1, -1).replaceAll("''", "'"));
|
|
43
46
|
}
|
|
44
47
|
if (value === "" || value.includes(": ") || value.endsWith(":") || ["[", "{", "'", '"'].some((opening) => value.startsWith(opening))) {
|
|
45
|
-
|
|
48
|
+
return Result.fail(failure(`cannot read "${value}" in ${key}`));
|
|
46
49
|
}
|
|
47
|
-
return value;
|
|
50
|
+
return Result.succeed(value);
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
const FLOW_INDICATOR = /[{}[\]]/u;
|
|
@@ -55,20 +58,20 @@ interface FlowScan {
|
|
|
55
58
|
quote: string | undefined;
|
|
56
59
|
}
|
|
57
60
|
|
|
58
|
-
function flowScalar(raw: string, key: string): string {
|
|
61
|
+
function flowScalar(raw: string, key: string): Result.Result<string, PnpmWorkspaceFailure> {
|
|
59
62
|
const value = raw.trim();
|
|
60
63
|
const quoted = value.startsWith('"') || value.startsWith("'");
|
|
61
64
|
if (!quoted && FLOW_INDICATOR.test(value)) {
|
|
62
|
-
|
|
65
|
+
return Result.fail(failure(`cannot read "${value}" in ${key}; quote a pattern that holds { } [ ] or ,`));
|
|
63
66
|
}
|
|
64
67
|
return scalar(value, key);
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
function closed(scan: FlowScan, rest: string, key: string): readonly string[] {
|
|
70
|
+
function closed(scan: FlowScan, rest: string, key: string): Result.Result<readonly string[], PnpmWorkspaceFailure> {
|
|
68
71
|
if (rest.trim() !== "") {
|
|
69
|
-
|
|
72
|
+
return Result.fail(failure(`cannot read "${rest.trim()}" after the ${key} list`));
|
|
70
73
|
}
|
|
71
|
-
return [...scan.entries, scan.current].filter((entry) => entry.trim() !== "").map((entry) => flowScalar(entry, key));
|
|
74
|
+
return Result.all([...scan.entries, scan.current].filter((entry) => entry.trim() !== "").map((entry) => flowScalar(entry, key)));
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
function scanned(scan: FlowScan, char: string): "close" | undefined {
|
|
@@ -87,7 +90,7 @@ function scanned(scan: FlowScan, char: string): "close" | undefined {
|
|
|
87
90
|
return undefined;
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
function flowList(lines: readonly string[], key: string): readonly string[] {
|
|
93
|
+
function flowList(lines: readonly string[], key: string): Result.Result<readonly string[], PnpmWorkspaceFailure> {
|
|
91
94
|
const scan: FlowScan = { current: "", entries: [], quote: undefined };
|
|
92
95
|
for (const [number, line] of lines.map(withoutComment).entries()) {
|
|
93
96
|
for (let index = number === 0 ? 1 : 0; index < line.length; index += 1) {
|
|
@@ -97,34 +100,36 @@ function flowList(lines: readonly string[], key: string): readonly string[] {
|
|
|
97
100
|
}
|
|
98
101
|
scan.current += " ";
|
|
99
102
|
}
|
|
100
|
-
|
|
103
|
+
return Result.fail(failure(`the ${key} list never closes`));
|
|
101
104
|
}
|
|
102
105
|
|
|
103
|
-
function blockList(lines: readonly string[], key: string): readonly string[] {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
106
|
+
function blockList(lines: readonly string[], key: string): Result.Result<readonly string[], PnpmWorkspaceFailure> {
|
|
107
|
+
return Result.gen(function* () {
|
|
108
|
+
const patterns: string[] = [];
|
|
109
|
+
for (const line of lines.map(withoutComment)) {
|
|
110
|
+
const trimmed = line.trim();
|
|
111
|
+
if (trimmed === "") {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const item = trimmed === ITEM || trimmed.startsWith(`${ITEM} `);
|
|
115
|
+
if (!(item || line.startsWith(" ") || line.startsWith("\t"))) {
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
if (!item) {
|
|
119
|
+
return yield* Result.fail(failure(`cannot read "${trimmed}" in ${key}`));
|
|
120
|
+
}
|
|
121
|
+
patterns.push(yield* scalar(trimmed.slice(ITEM.length), key));
|
|
116
122
|
}
|
|
117
|
-
patterns
|
|
118
|
-
}
|
|
119
|
-
return patterns;
|
|
123
|
+
return patterns;
|
|
124
|
+
});
|
|
120
125
|
}
|
|
121
126
|
|
|
122
|
-
export function pnpmWorkspaceList(text: string, key: string): readonly string[] {
|
|
127
|
+
export function pnpmWorkspaceList(text: string, key: string): Result.Result<readonly string[], PnpmWorkspaceFailure> {
|
|
123
128
|
const pattern = keyPattern(key);
|
|
124
129
|
const lines = text.split(LINE_BREAK);
|
|
125
130
|
const start = lines.findIndex((line) => pattern.test(line));
|
|
126
131
|
if (start === -1) {
|
|
127
|
-
return [];
|
|
132
|
+
return Result.succeed([]);
|
|
128
133
|
}
|
|
129
134
|
const rest = withoutComment(lines[start] ?? "")
|
|
130
135
|
.replace(pattern, "")
|
|
@@ -133,11 +138,11 @@ export function pnpmWorkspaceList(text: string, key: string): readonly string[]
|
|
|
133
138
|
return flowList([rest, ...lines.slice(start + 1)], key);
|
|
134
139
|
}
|
|
135
140
|
if (rest !== "") {
|
|
136
|
-
|
|
141
|
+
return Result.fail(failure(`cannot read "${rest}" in ${key}`));
|
|
137
142
|
}
|
|
138
143
|
return blockList(lines.slice(start + 1), key);
|
|
139
144
|
}
|
|
140
145
|
|
|
141
|
-
export function pnpmWorkspacePatterns(text: string): readonly string[] {
|
|
146
|
+
export function pnpmWorkspacePatterns(text: string): Result.Result<readonly string[], PnpmWorkspaceFailure> {
|
|
142
147
|
return pnpmWorkspaceList(text, "packages");
|
|
143
148
|
}
|
|
@@ -16,7 +16,7 @@ const TRAILING_SLASHES = /\/+$/u;
|
|
|
16
16
|
|
|
17
17
|
const NODE_MODULES = "node_modules";
|
|
18
18
|
|
|
19
|
-
const PLACEHOLDERS = new Set([".gitkeep", ".keep"]);
|
|
19
|
+
const PLACEHOLDERS = new Set([".gitkeep", ".keep", "README.md"]);
|
|
20
20
|
|
|
21
21
|
const withIgnoreFileIn = Effect.fn("Imports.withIgnoreFileIn")(function* (reader: Reader, scope: IgnoreScope, directory: string) {
|
|
22
22
|
const contents = yield* reader.readText(posix.join(directory, IGNORE_FILE));
|
package/src/imports/workspace.ts
CHANGED
|
@@ -46,7 +46,7 @@ function matchers(patterns: readonly string[]) {
|
|
|
46
46
|
const memberOf = Effect.fn("Imports.memberOf")(function* (inputs: Reader) {
|
|
47
47
|
const pnpm = yield* inputs.readText(PNPM_WORKSPACE);
|
|
48
48
|
const patterns = [
|
|
49
|
-
...(pnpm === undefined ? [] : pnpmWorkspacePatterns(pnpm)),
|
|
49
|
+
...(pnpm === undefined ? [] : yield* Effect.fromResult(pnpmWorkspacePatterns(pnpm))),
|
|
50
50
|
...npmPatterns(yield* readPackageManifest(inputs.readText, MANIFEST)),
|
|
51
51
|
];
|
|
52
52
|
const included = yield* matchers(patterns.filter((pattern) => !pattern.startsWith(NEGATION)).map(normalized));
|
|
@@ -3,10 +3,10 @@ import { Effect, Path } from "effect";
|
|
|
3
3
|
import { SetupFailure } from "#failure.ts";
|
|
4
4
|
import { run } from "#git/command.ts";
|
|
5
5
|
|
|
6
|
-
const listedPaths = Effect.fn("Inventory.listedPaths")(function* (directory: string, options: readonly string[],
|
|
6
|
+
const listedPaths = Effect.fn("Inventory.listedPaths")(function* (directory: string, options: readonly string[], paths: readonly string[] = ["."]) {
|
|
7
7
|
const { join } = yield* Path.Path.pipe(Effect.provide(NodePath.layer));
|
|
8
8
|
|
|
9
|
-
const result = yield* run(directory, ["ls-files", "-z", ...options, "--",
|
|
9
|
+
const result = yield* run(directory, ["ls-files", "-z", ...options, "--", ...paths]);
|
|
10
10
|
if (result.code !== 0) {
|
|
11
11
|
if (result.stderr.includes("not a git repository")) {
|
|
12
12
|
return undefined;
|
|
@@ -20,7 +20,7 @@ const listedPaths = Effect.fn("Inventory.listedPaths")(function* (directory: str
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
export const trackedPaths = Effect.fn("Inventory.trackedPaths")(function* (directory: string, path = ".") {
|
|
23
|
-
return (yield* listedPaths(directory, [], path)) ?? [];
|
|
23
|
+
return (yield* listedPaths(directory, [], [path])) ?? [];
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
export const ignoredTrackedPaths = Effect.fn("Inventory.ignoredTrackedPaths")(function* (directory: string) {
|
|
@@ -33,3 +33,10 @@ export const ignoredPaths = Effect.fn("Inventory.ignoredPaths")(function* (direc
|
|
|
33
33
|
const paths = yield* listedPaths(directory, ["--others", "--ignored", "--exclude-standard", "--directory"]);
|
|
34
34
|
return paths?.map((path) => resolve(path));
|
|
35
35
|
});
|
|
36
|
+
|
|
37
|
+
export const ignoredAmong = Effect.fn("Inventory.ignoredAmong")(function* (directory: string, paths: readonly string[]) {
|
|
38
|
+
if (paths.length === 0) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
return (yield* listedPaths(directory, ["--others", "--ignored", "--exclude-standard"], paths)) ?? [];
|
|
42
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PackageManifest } from "#PackageManifest.ts";
|
|
2
|
+
|
|
3
|
+
const MANIFEST_EXPORT = "./package.json";
|
|
4
|
+
|
|
5
|
+
// A package that exports only its manifest and holds no sources ships no code: the dependencies it installs are what it delivers.
|
|
6
|
+
export function deliveredDependencies(manifest: PackageManifest, sources: readonly string[]): readonly string[] {
|
|
7
|
+
const exported = typeof manifest.exports === "object" && manifest.exports !== null ? Object.keys(manifest.exports) : [];
|
|
8
|
+
const shell =
|
|
9
|
+
sources.length === 0 && manifest.bin === undefined && manifest.main === undefined && exported.length === 1 && exported[0] === MANIFEST_EXPORT;
|
|
10
|
+
return shell ? Object.keys(manifest.dependencies ?? {}) : [];
|
|
11
|
+
}
|