@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
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
1
|
import { Effect } from "effect";
|
|
3
2
|
import ts from "typescript";
|
|
4
3
|
import { changeKeyApi } from "#adapters/changeKeyApi.ts";
|
|
5
4
|
import { changeKeyLiterals } from "#adapters/changeKeyLiterals.ts";
|
|
6
|
-
import type { Finding,
|
|
7
|
-
import { effectProgram } from "#rules/effect/program.ts";
|
|
5
|
+
import type { Finding, SourceFile, TypeScriptProgram } from "#rule.ts";
|
|
8
6
|
import { parse } from "#rules/parse.ts";
|
|
9
7
|
import { importBindings } from "#rules/stories/importBindings.ts";
|
|
10
8
|
import { memberName, nodesWhere, unwrapped } from "#rules/stories/syntax.ts";
|
|
@@ -44,7 +42,7 @@ function candidate(node: ts.Node, aliases: ReadonlySet<string>): node is ts.Call
|
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
function hasCandidates(file: SourceFile): boolean {
|
|
47
|
-
const source = parse(file);
|
|
45
|
+
const source = [...APIS].some((name) => file.text.includes(name)) ? parse(file) : undefined;
|
|
48
46
|
if (source === undefined) {
|
|
49
47
|
return false;
|
|
50
48
|
}
|
|
@@ -52,11 +50,9 @@ function hasCandidates(file: SourceFile): boolean {
|
|
|
52
50
|
return nodesWhere(source, (node) => candidate(node, aliases)).length > 0;
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
function findingsIn(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return inputs.sources.flatMap((file) => {
|
|
59
|
-
const source = program.getSourceFile(join(inputs.root, file.path));
|
|
53
|
+
function findingsIn(sources: readonly SourceFile[], { checker, sourceFile }: TypeScriptProgram): readonly Finding[] {
|
|
54
|
+
return sources.flatMap((file) => {
|
|
55
|
+
const source = sourceFile(file.path);
|
|
60
56
|
if (source === undefined) {
|
|
61
57
|
return [];
|
|
62
58
|
}
|
|
@@ -79,18 +75,6 @@ function findingsIn(inputs: RuleInputs): readonly Finding[] {
|
|
|
79
75
|
});
|
|
80
76
|
}
|
|
81
77
|
|
|
82
|
-
export
|
|
83
|
-
Effect.
|
|
84
|
-
|
|
85
|
-
for (const source of inputs.sources) {
|
|
86
|
-
if (!hasCandidates(source)) {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
const group = /^(?:packages|examples)\/[^/]+/u.exec(source.path)?.[0] ?? ".";
|
|
90
|
-
const sources = groups.get(group) ?? [];
|
|
91
|
-
sources.push(source);
|
|
92
|
-
groups.set(group, sources);
|
|
93
|
-
}
|
|
94
|
-
return [...groups.values()].flatMap((sources) => findingsIn({ ...inputs, sources }));
|
|
95
|
-
}),
|
|
96
|
-
);
|
|
78
|
+
export function changeKeyCheck() {
|
|
79
|
+
return Effect.succeed({ checks: hasCandidates, findings: findingsIn });
|
|
80
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { composedContext } from "#adapters/composedContext.ts";
|
|
3
|
+
import { effectApi } from "#adapters/serviceModelSyntax.ts";
|
|
4
|
+
import type { Finding, SourceFile, TypeScriptProgram } from "#rule.ts";
|
|
5
|
+
import { parse } from "#rules/parse.ts";
|
|
6
|
+
import { importBindings } from "#rules/stories/importBindings.ts";
|
|
7
|
+
import { memberName, nodesWhere, unwrapped } from "#rules/stories/syntax.ts";
|
|
8
|
+
|
|
9
|
+
const RUNNERS = ["provideContext", "runPromiseWith", "runForkWith"];
|
|
10
|
+
const PROVIDERS = [...RUNNERS, "provide"];
|
|
11
|
+
|
|
12
|
+
function context(type: ts.Type): boolean {
|
|
13
|
+
return type.isUnionOrIntersection() ? type.types.some(context) : type.getProperty("~effect/Context") !== undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function reprovides(checker: ts.TypeChecker, call: ts.CallExpression): boolean {
|
|
17
|
+
if (RUNNERS.some((name) => effectApi(checker, call.expression, name))) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
if (!effectApi(checker, call.expression, "provide")) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const environment = call.arguments.at(-1);
|
|
24
|
+
return environment !== undefined && context(checker.getTypeAtLocation(environment));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const LAYER_NAME = /(?:Layer|Live)$|^layer$/u;
|
|
28
|
+
|
|
29
|
+
function aliasesIn(source: ts.SourceFile): ReadonlyMap<string, string> {
|
|
30
|
+
const aliases = new Map(
|
|
31
|
+
[...importBindings(source)].flatMap(([local, { imported }]) => (PROVIDERS.includes(imported) ? [[local, imported] as const] : [])),
|
|
32
|
+
);
|
|
33
|
+
for (const node of nodesWhere(source, (child) => ts.isBindingElement(child) || ts.isVariableDeclaration(child))) {
|
|
34
|
+
if (ts.isBindingElement(node) && ts.isIdentifier(node.name)) {
|
|
35
|
+
const property = node.propertyName ?? node.name;
|
|
36
|
+
if (ts.isIdentifier(property) && PROVIDERS.includes(property.text)) {
|
|
37
|
+
aliases.set(node.name.text, property.text);
|
|
38
|
+
}
|
|
39
|
+
} else if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer !== undefined) {
|
|
40
|
+
const api = apiOf(node.initializer, aliases);
|
|
41
|
+
if (api !== undefined) {
|
|
42
|
+
aliases.set(node.name.text, api);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return aliases;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function apiOf(callee: ts.Expression, aliases: ReadonlyMap<string, string>): string | undefined {
|
|
50
|
+
const value = unwrapped(callee);
|
|
51
|
+
const name = ts.isIdentifier(value) ? (aliases.get(value.text) ?? value.text) : memberName(value);
|
|
52
|
+
return name !== undefined && PROVIDERS.includes(name) ? name : undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function layerShaped(argument: ts.Expression): boolean {
|
|
56
|
+
let root = unwrapped(argument);
|
|
57
|
+
const name = ts.isIdentifier(root) ? root.text : memberName(root);
|
|
58
|
+
while (ts.isCallExpression(root) || ts.isPropertyAccessExpression(root)) {
|
|
59
|
+
root = unwrapped(root.expression);
|
|
60
|
+
}
|
|
61
|
+
return LAYER_NAME.test(name ?? "") || (ts.isIdentifier(root) && root.text === "Layer");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Only these call shapes can re-provide a context, so a file without one never enters the type-checked program.
|
|
65
|
+
function candidate(file: SourceFile): boolean {
|
|
66
|
+
const source =
|
|
67
|
+
/(?:^|\/)(?:adapters|test-support)\//u.test(file.path) || !PROVIDERS.some((name) => file.text.includes(name)) ? undefined : parse(file);
|
|
68
|
+
if (source === undefined) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const aliases = aliasesIn(source);
|
|
72
|
+
return (
|
|
73
|
+
nodesWhere(source, (node) => {
|
|
74
|
+
const api = ts.isCallExpression(node) ? apiOf(node.expression, aliases) : undefined;
|
|
75
|
+
const environment = ts.isCallExpression(node) ? node.arguments.at(-1) : undefined;
|
|
76
|
+
return api !== undefined && (api !== "provide" || (environment !== undefined && !layerShaped(environment)));
|
|
77
|
+
}).length > 0
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function findingsIn(sources: readonly SourceFile[], { checker, sourceFile }: TypeScriptProgram): readonly Finding[] {
|
|
82
|
+
return sources.flatMap((file): readonly Finding[] => {
|
|
83
|
+
const source = sourceFile(file.path);
|
|
84
|
+
if (source === undefined) {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
const syntax = source;
|
|
88
|
+
const findings: Finding[] = [];
|
|
89
|
+
function visit(node: ts.Node): void {
|
|
90
|
+
const environment = ts.isCallExpression(node) ? node.arguments.at(-1) : undefined;
|
|
91
|
+
if (ts.isCallExpression(node) && reprovides(checker, node) && !(environment !== undefined && composedContext(checker, environment))) {
|
|
92
|
+
findings.push({
|
|
93
|
+
file: file.path,
|
|
94
|
+
line: syntax.getLineAndCharacterOfPosition(node.getStart(syntax)).line + 1,
|
|
95
|
+
message:
|
|
96
|
+
"Do not re-provide a captured Effect context in core code. Declare service requirements once and yield dependencies and the caller from the environment. Register the Layer at the host; put runtime bridges in adapters/ or test-support/.",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
ts.forEachChild(node, visit);
|
|
100
|
+
}
|
|
101
|
+
visit(source);
|
|
102
|
+
return findings;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const contextCaptureCheck = { checks: candidate, findings: findingsIn };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import type { initializeDeclarationFiles } from "#adapters/declaration-files/initialize.ts";
|
|
4
|
+
|
|
5
|
+
export function parse(state: Effect.Success<typeof initializeDeclarationFiles>) {
|
|
6
|
+
return Effect.fn("DeclarationFiles.parse")((fileName: string, text: string, options: ts.CompilerOptions) =>
|
|
7
|
+
Effect.sync(() => state.registry.acquireDocument(fileName, options, ts.ScriptSnapshot.fromString(text), text)),
|
|
8
|
+
);
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import type { initializeDeclarationFiles } from "#adapters/declaration-files/initialize.ts";
|
|
5
|
+
|
|
6
|
+
const LIBRARY = `${dirname(ts.getDefaultLibFilePath({}))}/`;
|
|
7
|
+
const DECLARATION = /\.d\.[cm]?ts$/u;
|
|
8
|
+
|
|
9
|
+
// Workspace and fixture files can differ between programs through a rule's own sources, so only installed and library declarations are shared.
|
|
10
|
+
function shareable(fileName: string): boolean {
|
|
11
|
+
return DECLARATION.test(fileName) && (fileName.startsWith(LIBRARY) || fileName.includes("/node_modules/"));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function reader(state: Effect.Success<typeof initializeDeclarationFiles>) {
|
|
15
|
+
return Effect.fn("DeclarationFiles.reader")((host: ts.CompilerHost, options: ts.CompilerOptions) =>
|
|
16
|
+
Effect.sync((): ts.CompilerHost["getSourceFile"] => {
|
|
17
|
+
const read = host.getSourceFile.bind(host);
|
|
18
|
+
return (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) => {
|
|
19
|
+
const text = shouldCreateNewSourceFile || !shareable(fileName) ? undefined : host.readFile(fileName);
|
|
20
|
+
// The registry binds a file once for every program in its bucket, so it keys buckets by the options that change parsing and
|
|
21
|
+
// binding; the text is the version, so a file whose text changed is parsed again.
|
|
22
|
+
return text === undefined
|
|
23
|
+
? read(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile)
|
|
24
|
+
: state.registry.acquireDocument(fileName, options, ts.ScriptSnapshot.fromString(text), text, undefined, languageVersionOrOptions);
|
|
25
|
+
};
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Effect } from "effect";
|
|
2
|
+
import type ts from "typescript";
|
|
3
|
+
import { defineService } from "@shivaedev/service/defineService.ts";
|
|
4
|
+
import { initializeDeclarationFiles } from "#adapters/declaration-files/initialize.ts";
|
|
5
|
+
import { parse } from "#adapters/declaration-files/parse.ts";
|
|
6
|
+
import { reader } from "#adapters/declaration-files/reader.ts";
|
|
7
|
+
|
|
8
|
+
export const DeclarationFiles = defineService({
|
|
9
|
+
id: "@shivaedev/quality/DeclarationFiles",
|
|
10
|
+
initialize: initializeDeclarationFiles,
|
|
11
|
+
methods: (state) => ({
|
|
12
|
+
parse: parse(state) satisfies (fileName: string, text: string, options: ts.CompilerOptions) => Effect.Effect<ts.SourceFile>,
|
|
13
|
+
reader: reader(state) satisfies (host: ts.CompilerHost, options: ts.CompilerOptions) => Effect.Effect<ts.CompilerHost["getSourceFile"]>,
|
|
14
|
+
}),
|
|
15
|
+
requires: [],
|
|
16
|
+
});
|
|
@@ -47,10 +47,6 @@ function acquisition(checker: ts.TypeChecker, node: ts.CallExpression | ts.NewEx
|
|
|
47
47
|
export function foreignResources(checker: ts.TypeChecker, sources: readonly ts.SourceFile[]) {
|
|
48
48
|
const originates = parameterOrigins(checker, sources);
|
|
49
49
|
return (parameter: ts.ParameterDeclaration): boolean => {
|
|
50
|
-
const source = parameter.getSourceFile();
|
|
51
|
-
if (!/(?:^|\/)adapters\//u.test(source.fileName)) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
50
|
const type = checker.getTypeAtLocation(parameter);
|
|
55
51
|
if (!(type.getSymbol()?.declarations ?? []).some(foreignDeclaration) || type.getProperty("~effect/Context/Service") !== undefined) {
|
|
56
52
|
return false;
|
|
@@ -2,8 +2,13 @@ import { realpathSync } from "node:fs";
|
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
import { analysisFailure } from "#adapters/imports/analysisFailure.ts";
|
|
4
4
|
import { graph as buildGraph } from "#adapters/imports/graph.ts";
|
|
5
|
-
import type { RuleInputs } from "#rule.ts";
|
|
5
|
+
import type { RuleInputs, SourceFile } from "#rule.ts";
|
|
6
6
|
|
|
7
7
|
export const graph = Effect.fn("ImportCompiler.graph")((inputs: RuleInputs) =>
|
|
8
|
-
Effect.try({ catch: (cause) => analysisFailure(inputs.root, cause), try: () => buildGraph(inputs, realpathSync(inputs.root)) })
|
|
8
|
+
Effect.try({ catch: (cause) => analysisFailure(inputs.root, cause), try: () => buildGraph(inputs, realpathSync(inputs.root)) }).pipe(
|
|
9
|
+
Effect.map(({ follow, ...walked }) => ({
|
|
10
|
+
...walked,
|
|
11
|
+
follow: (files: readonly SourceFile[]) => Effect.try({ catch: (cause) => analysisFailure(inputs.root, cause), try: () => follow(files) }),
|
|
12
|
+
})),
|
|
13
|
+
),
|
|
9
14
|
);
|
|
@@ -5,7 +5,7 @@ import { isDeclarationFile, presumedTarget, resolveImport } from "#adapters/impo
|
|
|
5
5
|
import { ambientModules } from "#imports/ambient.ts";
|
|
6
6
|
import { type ImportRequest, importsOf } from "#imports/extract.ts";
|
|
7
7
|
import type { ImportEdge, ImportGraph, UnresolvedImport } from "#imports/graph.ts";
|
|
8
|
-
import type { RuleInputs } from "#rule.ts";
|
|
8
|
+
import type { RuleInputs, SourceFile } from "#rule.ts";
|
|
9
9
|
import { parse } from "#rules/parse.ts";
|
|
10
10
|
|
|
11
11
|
const QUERY = /\?.*$/u;
|
|
@@ -21,28 +21,53 @@ function missingTarget(root: string, from: string, request: ImportRequest, proje
|
|
|
21
21
|
return target === undefined || target.startsWith("../") ? undefined : target;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
interface Parsed {
|
|
25
|
+
readonly file: SourceFile;
|
|
26
|
+
readonly path: string;
|
|
27
|
+
readonly syntax: ts.SourceFile;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function parsedIn(root: string, files: readonly SourceFile[]): readonly Parsed[] {
|
|
31
|
+
return files.flatMap((file) => {
|
|
27
32
|
const syntax = parse(file);
|
|
28
33
|
return syntax === undefined ? [] : [{ file, path: join(root, file.path), syntax }];
|
|
29
34
|
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type SourceGraph = Pick<ImportGraph, "configFindings" | "edges" | "modules" | "unresolved"> & {
|
|
38
|
+
// Files the sources reach outside the inventory resolve with the sources' projects and ambient modules.
|
|
39
|
+
readonly follow: (files: readonly SourceFile[]) => readonly ImportEdge[];
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export function graph(inputs: RuleInputs, root: string): SourceGraph {
|
|
43
|
+
const projectOf = projectsFor(root);
|
|
44
|
+
const parsed = parsedIn(root, inputs.sources);
|
|
30
45
|
const ambient = ambientModules(parsed);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
function walk(files: readonly Parsed[]): Pick<ImportGraph, "edges" | "unresolved"> {
|
|
47
|
+
const edges: ImportEdge[] = [];
|
|
48
|
+
const unresolved: UnresolvedImport[] = [];
|
|
49
|
+
for (const { file, path, syntax } of files) {
|
|
50
|
+
const project = projectOf(path);
|
|
51
|
+
syntax.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, undefined, ts.sys, project.options);
|
|
52
|
+
for (const request of importsOf(syntax, isDeclarationFile(file.path), project.options)) {
|
|
53
|
+
const to = resolveImport(root, ambient, request, path, project);
|
|
54
|
+
if (to === undefined) {
|
|
55
|
+
const missing = missingTarget(root, file.path, request, project);
|
|
56
|
+
unresolved.push({ ...request, from: file.path, missing });
|
|
57
|
+
edges.push(...(missing === undefined ? [] : [{ ...request, from: file.path, to: { kind: "file" as const, path: missing } }]));
|
|
58
|
+
} else {
|
|
59
|
+
edges.push({ ...request, from: file.path, to });
|
|
60
|
+
}
|
|
44
61
|
}
|
|
45
62
|
}
|
|
63
|
+
return { edges, unresolved };
|
|
46
64
|
}
|
|
47
|
-
|
|
65
|
+
const { edges, unresolved } = walk(parsed);
|
|
66
|
+
return {
|
|
67
|
+
configFindings: projectOf.findings,
|
|
68
|
+
edges,
|
|
69
|
+
follow: (files) => walk(parsedIn(root, files)).edges,
|
|
70
|
+
modules: parsed.map(({ file }) => file.path),
|
|
71
|
+
unresolved,
|
|
72
|
+
};
|
|
48
73
|
}
|
|
@@ -9,6 +9,7 @@ import type { ReachableBuilds } from "#adapters/reachableBuilds.ts";
|
|
|
9
9
|
import { scriptPaths } from "#adapters/scriptPaths.ts";
|
|
10
10
|
import { exportedModule, exportTargets } from "#imports/packageExports.ts";
|
|
11
11
|
import { packageOf, workspacePackages } from "#imports/workspace.ts";
|
|
12
|
+
import { deliveredDependencies } from "#manifests/deliveredDependencies.ts";
|
|
12
13
|
import type { PackageManifest } from "#PackageManifest.ts";
|
|
13
14
|
import type { RuleInputs } from "#rule.ts";
|
|
14
15
|
|
|
@@ -50,7 +51,7 @@ function externalDependencies(manifest: PackageManifest, externals: ReadonlySet<
|
|
|
50
51
|
|
|
51
52
|
export const knipConfiguration = Effect.fn("Knip.knipConfiguration")(function* (
|
|
52
53
|
inputs: RuleInputs,
|
|
53
|
-
|
|
54
|
+
unchecked: readonly string[] = [],
|
|
54
55
|
builds: ReachableBuilds = { entries: new Set(), externals: new Map() },
|
|
55
56
|
declared: readonly string[] = declaredEntries(inputs),
|
|
56
57
|
) {
|
|
@@ -80,7 +81,9 @@ export const knipConfiguration = Effect.fn("Knip.knipConfiguration")(function* (
|
|
|
80
81
|
const configs = sources.filter(isToolConfig);
|
|
81
82
|
// Migration runners load these files from their directory, so no import reaches them.
|
|
82
83
|
const migrations = sources.filter((path) => /(?:^|\/)server\/migrations\//u.test(path));
|
|
83
|
-
const
|
|
84
|
+
const followed = unchecked
|
|
85
|
+
.filter((file) => (packageOf(packages, file)?.directory ?? ".") === directory)
|
|
86
|
+
.map((file) => posix.relative(directory, file));
|
|
84
87
|
const workspaceEntries = declared
|
|
85
88
|
.filter((file) => (packageOf(packages, file)?.directory ?? ".") === directory)
|
|
86
89
|
.map((file) => posix.relative(directory, file));
|
|
@@ -99,14 +102,17 @@ export const knipConfiguration = Effect.fn("Knip.knipConfiguration")(function* (
|
|
|
99
102
|
...binaries,
|
|
100
103
|
...scriptEntries,
|
|
101
104
|
...bundled,
|
|
102
|
-
...
|
|
105
|
+
...followed,
|
|
103
106
|
...styles,
|
|
104
107
|
...workspaceEntries,
|
|
105
108
|
],
|
|
106
109
|
// A bundle leaves its externals as runtime imports, which the bundling package's own dependencies satisfy.
|
|
107
|
-
ignoreDependencies:
|
|
110
|
+
ignoreDependencies: [
|
|
111
|
+
...externalDependencies(manifest, builds.externals.get(directory === "." ? "" : directory) ?? new Set()),
|
|
112
|
+
...deliveredDependencies(manifest, sources),
|
|
113
|
+
],
|
|
108
114
|
paths: importPaths(manifest.imports ?? {}),
|
|
109
|
-
project: [...sources, ...
|
|
115
|
+
project: [...sources, ...followed, ...styles, ...workspaceEntries],
|
|
110
116
|
vitest: { config: ["vitest*.config.{ts,mts,cts,js,mjs,cjs}", "vitest.{workspace,projects}.{ts,mts,cts,js,mjs,cjs,json}"] },
|
|
111
117
|
},
|
|
112
118
|
] as const;
|
package/src/adapters/knip/run.ts
CHANGED
|
@@ -10,6 +10,8 @@ import { KNIP_ISSUES } from "#adapters/knip/findings.ts";
|
|
|
10
10
|
import { knipReport } from "#adapters/knip/report.ts";
|
|
11
11
|
import { sourceConfig } from "#adapters/knip/sourceConfig.ts";
|
|
12
12
|
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
13
|
+
import { childStarted } from "#engine/childStarted.ts";
|
|
14
|
+
import { ignoredModules } from "#imports/graph.ts";
|
|
13
15
|
import { programmaticBuilds } from "#inventory/programmaticBuilds.ts";
|
|
14
16
|
import { toolOwnedFiles } from "#inventory/toolOwnedFiles.ts";
|
|
15
17
|
import type { RuleInputs } from "#rule.ts";
|
|
@@ -26,7 +28,7 @@ export const runKnip = Effect.fn("Knip.runKnip")(function* (inputs: RuleInputs)
|
|
|
26
28
|
if ((yield* readPackageManifest(inputs.readText, "package.json")) === undefined) {
|
|
27
29
|
return [];
|
|
28
30
|
}
|
|
29
|
-
const files = yield* toolOwnedFiles(inputs.root);
|
|
31
|
+
const files = [...(yield* toolOwnedFiles(inputs.root)), ...(yield* ignoredModules(inputs))];
|
|
30
32
|
const builds = yield* programmaticBuilds(inputs);
|
|
31
33
|
const declared = declaredEntries(inputs);
|
|
32
34
|
const configuration = yield* knipConfiguration(inputs, files, builds, declared);
|
|
@@ -69,6 +71,7 @@ export const runKnip = Effect.fn("Knip.runKnip")(function* (inputs: RuleInputs)
|
|
|
69
71
|
{ cwd, env: { "JITI_TRY_NATIVE": "true" }, extendEnv: true, stdin: "ignore" },
|
|
70
72
|
),
|
|
71
73
|
);
|
|
74
|
+
yield* childStarted();
|
|
72
75
|
const [stdout, stderr, code] = yield* Effect.all(
|
|
73
76
|
[Stream.mkString(Stream.decodeText(child.stdout)), Stream.mkString(Stream.decodeText(child.stderr)), child.exitCode],
|
|
74
77
|
{ concurrency: "unbounded" },
|
|
@@ -1,88 +1,45 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
+
import type { ChildProcessSpawner } from "effect/process";
|
|
2
3
|
import type { ImportAnalysisFailure } from "#adapters/ImportAnalysisFailure.ts";
|
|
3
|
-
import {
|
|
4
|
+
import type { ManifestReadFailure } from "#adapters/manifestInventory.ts";
|
|
5
|
+
import type { SetupFailure } from "#failure.ts";
|
|
4
6
|
import type { GlobFailure } from "#imports/globMatcher.ts";
|
|
5
7
|
import { importGraph } from "#imports/graph.ts";
|
|
6
8
|
import { isPackageRootConfig } from "#imports/isTooling.ts";
|
|
7
|
-
import {
|
|
9
|
+
import type { PnpmWorkspaceFailure } from "#imports/pnpmWorkspacePatterns.ts";
|
|
8
10
|
import { packageOf } from "#imports/workspace.ts";
|
|
9
|
-
import { testName } from "#naming/testName.ts";
|
|
10
11
|
import type { Finding, RuleInputs } from "#rule.ts";
|
|
11
12
|
import { entryModules } from "#rules/effect/boundaryReference.ts";
|
|
12
13
|
|
|
13
|
-
const CLIENT_RENDERING_LIBRARIES = new Set([
|
|
14
|
-
"react",
|
|
15
|
-
"react-dom",
|
|
16
|
-
"recharts",
|
|
17
|
-
"lucide-react",
|
|
18
|
-
"@base-ui/react",
|
|
19
|
-
"@tanstack/react-router",
|
|
20
|
-
"@tanstack/react-table",
|
|
21
|
-
"class-variance-authority",
|
|
22
|
-
"cn",
|
|
23
|
-
"clsx",
|
|
24
|
-
"tailwind-merge",
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
14
|
// Path functions compute strings and touch no file system or process state, so they need no adapter.
|
|
28
15
|
const PURE_BUILTINS = new Set(["node:path", "node:path/posix", "node:path/win32"]);
|
|
29
16
|
|
|
30
|
-
function exempt(directory: string, path: string, name: string): boolean {
|
|
31
|
-
return (
|
|
32
|
-
/(?:^|\/)(?:adapters|test-support)\//u.test(path)
|
|
33
|
-
|| PURE_BUILTINS.has(name)
|
|
34
|
-
|| isPackageRootConfig(directory, path)
|
|
35
|
-
|| (name === "vitest" && testName(path) !== undefined)
|
|
36
|
-
|| name === "effect"
|
|
37
|
-
|| name.startsWith("@effect/")
|
|
38
|
-
|| name.startsWith("@shivaedev/")
|
|
39
|
-
|| (CLIENT_RENDERING_LIBRARIES.has(name) && /(?:^|\/)client\//u.test(path))
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
17
|
export const outsideImportFindings = Effect.fn("Imports.outsideImportFindings")(function* (
|
|
44
18
|
inputs: RuleInputs,
|
|
45
|
-
): Effect.fn.Return<
|
|
19
|
+
): Effect.fn.Return<
|
|
20
|
+
readonly Finding[],
|
|
21
|
+
GlobFailure | ImportAnalysisFailure | ManifestReadFailure | PnpmWorkspaceFailure | SetupFailure,
|
|
22
|
+
ChildProcessSpawner.ChildProcessSpawner
|
|
23
|
+
> {
|
|
46
24
|
const graph = yield* importGraph(inputs);
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
] as const;
|
|
58
|
-
}),
|
|
59
|
-
{ concurrency: "unbounded" },
|
|
60
|
-
),
|
|
25
|
+
const builtins = graph.edges.flatMap((edge) =>
|
|
26
|
+
edge.to.kind === "external"
|
|
27
|
+
&& edge.to.package.startsWith("node:")
|
|
28
|
+
&& !PURE_BUILTINS.has(edge.to.package)
|
|
29
|
+
&& edge.kind === "import"
|
|
30
|
+
&& !edge.type
|
|
31
|
+
&& !/(?:^|\/)(?:adapters|test-support)\//u.test(edge.from)
|
|
32
|
+
&& !isPackageRootConfig(packageOf(graph.packages, edge.from)?.directory ?? ".", edge.from)
|
|
33
|
+
? [{ ...edge, name: edge.to.package }]
|
|
34
|
+
: [],
|
|
61
35
|
);
|
|
62
|
-
const
|
|
63
|
-
const sites = [
|
|
64
|
-
...graph.edges.flatMap((edge) => (edge.to.kind === "external" ? [{ ...edge, name: edge.to.package }] : [])),
|
|
65
|
-
...graph.unresolved
|
|
66
|
-
.filter((edge) => edge.missing === undefined && !/^[.#/]/u.test(edge.specifier))
|
|
67
|
-
.map((edge) => ({ ...edge, name: packageNameOf(edge.specifier) })),
|
|
68
|
-
];
|
|
69
|
-
const outside = sites.filter((site) => {
|
|
70
|
-
const directory = packageOf(graph.packages, site.from)?.directory ?? ".";
|
|
71
|
-
return !(
|
|
72
|
-
workspace.has(site.name)
|
|
73
|
-
|| site.type
|
|
74
|
-
|| site.kind !== "import"
|
|
75
|
-
|| exempt(directory, site.from, site.name)
|
|
76
|
-
|| !(site.name.startsWith("node:") || runtime.get(directory)?.has(site.name))
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
const processImporters = new Set(outside.flatMap((site) => (site.name === "node:process" ? [site.from] : [])));
|
|
36
|
+
const processImporters = new Set(builtins.flatMap((site) => (site.name === "node:process" ? [site.from] : [])));
|
|
80
37
|
const entries = entryModules(inputs.sources.filter((file) => processImporters.has(file.path)));
|
|
81
|
-
return
|
|
38
|
+
return builtins
|
|
82
39
|
.filter((site) => !(site.name === "node:process" && entries.has(site.from)))
|
|
83
40
|
.map((site) => ({
|
|
84
41
|
file: site.from,
|
|
85
42
|
line: site.line,
|
|
86
|
-
message: `Imports
|
|
43
|
+
message: `Imports Node builtin "${site.specifier}" as a value. Use Effect's FileSystem, ChildProcessSpawner, Config and other platform services, or bridge it in an adapters/ module with explicit imports that exposes Effect values; use import type for types. Read environment variables with Config instead of process.env, including in adapters/.`,
|
|
87
44
|
}));
|
|
88
45
|
});
|
package/src/adapters/rule.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
+
import { DeclarationFiles } from "#adapters/declaration-files/service.ts";
|
|
2
3
|
import { describeIssue, type StandardSchemaV1 } from "#adapters/standardSchema.ts";
|
|
4
|
+
import { typeScriptProgram } from "#adapters/typeScriptProgram.ts";
|
|
3
5
|
import { validOrFail } from "#decoded.ts";
|
|
4
|
-
import type { Configured, Findings, RegisteredRule, RuleContext } from "#rule.ts";
|
|
6
|
+
import type { Configured, Findings, RegisteredRule, RuleCheck, RuleContext } from "#rule.ts";
|
|
5
7
|
|
|
6
8
|
export type RuleCheckResult<TServices> = Findings | Effect.Effect<Findings, unknown, TServices>;
|
|
7
9
|
|
|
@@ -19,9 +21,14 @@ export function configureRegistered<TServices>(rule: RegisteredRule<TServices>,
|
|
|
19
21
|
return rule[ruleConfiguration](options);
|
|
20
22
|
}
|
|
21
23
|
|
|
24
|
+
type ContextCheck<TOptions, TServices> = (context: RuleContext<TOptions>) => RuleCheckResult<TServices>;
|
|
25
|
+
|
|
22
26
|
export function configureWith<TInput, TOptions, TServices>(
|
|
23
27
|
schema: StandardSchemaV1<TInput, TOptions>,
|
|
24
|
-
|
|
28
|
+
checks: {
|
|
29
|
+
readonly check: ContextCheck<TOptions, TServices>;
|
|
30
|
+
readonly deepHalf?: { readonly check: ContextCheck<TOptions, TServices>; readonly name: string } | undefined;
|
|
31
|
+
},
|
|
25
32
|
id: string,
|
|
26
33
|
absent: unknown,
|
|
27
34
|
validate?: (context: RuleContext<TOptions>) => readonly string[],
|
|
@@ -32,12 +39,15 @@ export function configureWith<TInput, TOptions, TServices>(
|
|
|
32
39
|
return { _tag: "Invalid", issues: result.issues.map(describeIssue) };
|
|
33
40
|
}
|
|
34
41
|
const value = result.value;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
check: (inputs) =>
|
|
42
|
+
function ready(check: ContextCheck<TOptions, TServices>): RuleCheck<TServices> {
|
|
43
|
+
return (inputs) =>
|
|
38
44
|
Effect.scoped(
|
|
39
45
|
Effect.gen(function* () {
|
|
40
|
-
const context = {
|
|
46
|
+
const context = {
|
|
47
|
+
...inputs,
|
|
48
|
+
options: value,
|
|
49
|
+
typeScript: inputs.typeScript ?? (yield* typeScriptProgram(inputs.root, inputs.sources).pipe(Effect.provide(DeclarationFiles.layer))),
|
|
50
|
+
};
|
|
41
51
|
const issues = validate?.(context).map((issue) => `rules.${id}.options: ${issue}`) ?? [];
|
|
42
52
|
yield* validOrFail(
|
|
43
53
|
inputs.configFile ?? "quality.config.ts",
|
|
@@ -46,7 +56,20 @@ export function configureWith<TInput, TOptions, TServices>(
|
|
|
46
56
|
const checked = check(context);
|
|
47
57
|
return Effect.isEffect(checked) ? yield* checked : checked;
|
|
48
58
|
}),
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
const fast = ready(checks.check);
|
|
62
|
+
if (checks.deepHalf === undefined) {
|
|
63
|
+
return { _tag: "Ready", check: fast };
|
|
64
|
+
}
|
|
65
|
+
const deep = ready(checks.deepHalf.check);
|
|
66
|
+
return {
|
|
67
|
+
_tag: "Ready",
|
|
68
|
+
check: (inputs) =>
|
|
69
|
+
Effect.map(Effect.all([fast(inputs), deep(inputs)]), ([found, typed]) =>
|
|
70
|
+
[...found, ...typed].sort((left, right) => left.file.localeCompare(right.file) || (left.line ?? 0) - (right.line ?? 0)),
|
|
49
71
|
),
|
|
72
|
+
halves: { deep, fast, name: checks.deepHalf.name },
|
|
50
73
|
};
|
|
51
74
|
};
|
|
52
75
|
}
|
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 });
|