@shivaedev/quality 0.76.0 → 0.78.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 +80 -0
- package/README.md +66 -64
- 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/declarationTagParameter.d.ts.map +1 -1
- package/dist/adapters/declarationTagParameter.js +4 -0
- package/dist/adapters/declarationTagParameter.js.map +1 -1
- 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/imports/resolve.d.ts.map +1 -1
- package/dist/adapters/imports/resolve.js +29 -5
- package/dist/adapters/imports/resolve.js.map +1 -1
- package/dist/adapters/knip/configuration.d.ts +1 -1
- package/dist/adapters/knip/configuration.d.ts.map +1 -1
- package/dist/adapters/knip/configuration.js +6 -4
- package/dist/adapters/knip/configuration.js.map +1 -1
- package/dist/adapters/knip/entryPointFindings.d.ts +1 -1
- package/dist/adapters/knip/entryPointFindings.d.ts.map +1 -1
- package/dist/adapters/knip/run.d.ts.map +1 -1
- package/dist/adapters/knip/run.js +4 -1
- package/dist/adapters/knip/run.js.map +1 -1
- package/dist/adapters/outsideImportFindings.d.ts +4 -2
- package/dist/adapters/outsideImportFindings.d.ts.map +1 -1
- package/dist/adapters/outsideImportFindings.js +12 -52
- package/dist/adapters/outsideImportFindings.js.map +1 -1
- package/dist/adapters/presenceCheck.d.ts +3 -0
- package/dist/adapters/presenceCheck.d.ts.map +1 -0
- package/dist/adapters/presenceCheck.js +15 -0
- package/dist/adapters/presenceCheck.js.map +1 -0
- package/dist/adapters/queueReadoutFindings.d.ts +1 -1
- package/dist/adapters/queueReadoutFindings.d.ts.map +1 -1
- package/dist/adapters/rule.d.ts +9 -1
- package/dist/adapters/rule.d.ts.map +1 -1
- package/dist/adapters/rule.js +21 -6
- package/dist/adapters/rule.js.map +1 -1
- package/dist/adapters/runMain.d.ts +3 -4
- package/dist/adapters/runMain.d.ts.map +1 -1
- package/dist/adapters/runMain.js +2 -1
- package/dist/adapters/runMain.js.map +1 -1
- package/dist/adapters/serviceModelCheck.d.ts +9 -0
- package/dist/adapters/serviceModelCheck.d.ts.map +1 -0
- package/dist/adapters/{serviceModelFindings.js → serviceModelCheck.js} +9 -23
- package/dist/adapters/serviceModelCheck.js.map +1 -0
- package/dist/adapters/sharedErrorCatalog.d.ts +13 -0
- package/dist/adapters/sharedErrorCatalog.d.ts.map +1 -0
- package/dist/adapters/sharedErrorCatalog.js +28 -0
- package/dist/adapters/sharedErrorCatalog.js.map +1 -0
- package/dist/adapters/sharedErrorModules.d.ts +1 -1
- package/dist/adapters/sharedErrorModules.d.ts.map +1 -1
- package/dist/adapters/sharedErrorModules.js.map +1 -1
- package/dist/adapters/specReaderSources.d.ts +3 -2
- package/dist/adapters/specReaderSources.d.ts.map +1 -1
- package/dist/adapters/specReaderSources.js +6 -3
- package/dist/adapters/specReaderSources.js.map +1 -1
- package/dist/adapters/storyProgram.d.ts +2 -0
- package/dist/adapters/storyProgram.d.ts.map +1 -1
- package/dist/adapters/storyProgram.js +13 -3
- package/dist/adapters/storyProgram.js.map +1 -1
- package/dist/adapters/typeScriptProgram.d.ts +5 -0
- package/dist/adapters/typeScriptProgram.d.ts.map +1 -0
- package/dist/adapters/typeScriptProgram.js +43 -0
- package/dist/adapters/typeScriptProgram.js.map +1 -0
- package/dist/baseline/compare.d.ts +2 -0
- package/dist/baseline/compare.d.ts.map +1 -1
- package/dist/baseline/compare.js +43 -17
- package/dist/baseline/compare.js.map +1 -1
- package/dist/baseline/format.d.ts +1 -0
- package/dist/baseline/format.d.ts.map +1 -1
- package/dist/baseline/format.js +6 -2
- package/dist/baseline/format.js.map +1 -1
- package/dist/baseline/merge.d.ts.map +1 -1
- package/dist/baseline/merge.js +14 -1
- package/dist/baseline/merge.js.map +1 -1
- package/dist/baseline/rewrite.d.ts.map +1 -1
- package/dist/baseline/rewrite.js +3 -1
- package/dist/baseline/rewrite.js.map +1 -1
- package/dist/baseline/update.d.ts +7 -0
- package/dist/baseline/update.d.ts.map +1 -1
- package/dist/baseline/update.js +29 -8
- package/dist/baseline/update.js.map +1 -1
- package/dist/biome/exceptionConfig.d.ts +3 -0
- package/dist/biome/exceptionConfig.d.ts.map +1 -1
- package/dist/biome/exceptionConfig.js +15 -1
- package/dist/biome/exceptionConfig.js.map +1 -1
- package/dist/biome/scannerRules.d.ts +3 -0
- package/dist/biome/scannerRules.d.ts.map +1 -0
- package/dist/biome/scannerRules.js +42 -0
- package/dist/biome/scannerRules.js.map +1 -0
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +10 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/baseline.d.ts.map +1 -1
- package/dist/cli/baseline.js +5 -1
- package/dist/cli/baseline.js.map +1 -1
- package/dist/cli/lint.d.ts +3 -2
- package/dist/cli/lint.d.ts.map +1 -1
- package/dist/cli/lint.js +13 -5
- package/dist/cli/lint.js.map +1 -1
- package/dist/cli/misplaced.d.ts +6 -0
- package/dist/cli/misplaced.d.ts.map +1 -1
- package/dist/cli/misplaced.js +4 -2
- package/dist/cli/misplaced.js.map +1 -1
- package/dist/cli/program.js +1 -1
- package/dist/cli/program.js.map +1 -1
- package/dist/cli/runSet.d.ts +5 -0
- package/dist/cli/runSet.d.ts.map +1 -0
- package/dist/cli/runSet.js +15 -0
- package/dist/cli/runSet.js.map +1 -0
- package/dist/cli/shrink.d.ts +4 -4
- package/dist/cli/shrink.d.ts.map +1 -1
- package/dist/cli/shrink.js.map +1 -1
- package/dist/cli/usage.d.ts +1 -1
- package/dist/cli/usage.d.ts.map +1 -1
- package/dist/cli/usage.js +7 -2
- package/dist/cli/usage.js.map +1 -1
- package/dist/config/decode.d.ts +1 -0
- package/dist/config/decode.d.ts.map +1 -1
- package/dist/config/decode.js +1 -0
- package/dist/config/decode.js.map +1 -1
- package/dist/config/load.d.ts +2 -0
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +1 -0
- package/dist/config/load.js.map +1 -1
- package/dist/config/resolve.d.ts +2 -1
- package/dist/config/resolve.d.ts.map +1 -1
- package/dist/config/resolve.js +9 -4
- package/dist/config/resolve.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/engine/childStarted.d.ts +4 -0
- package/dist/engine/childStarted.d.ts.map +1 -0
- package/dist/engine/childStarted.js +7 -0
- package/dist/engine/childStarted.js.map +1 -0
- package/dist/engine/evaluate.d.ts +1 -0
- package/dist/engine/evaluate.d.ts.map +1 -1
- package/dist/engine/evaluate.js +2 -1
- package/dist/engine/evaluate.js.map +1 -1
- package/dist/engine/generateFirst.d.ts +5 -0
- package/dist/engine/generateFirst.d.ts.map +1 -0
- package/dist/engine/generateFirst.js +25 -0
- package/dist/engine/generateFirst.js.map +1 -0
- package/dist/engine/projectScripts.d.ts +11 -0
- package/dist/engine/projectScripts.d.ts.map +1 -0
- package/dist/engine/projectScripts.js +18 -0
- package/dist/engine/projectScripts.js.map +1 -0
- 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 +22 -6
- package/dist/engine/session.js.map +1 -1
- package/dist/engine/violation.d.ts +7 -0
- package/dist/engine/violation.d.ts.map +1 -1
- package/dist/engine/violation.js +9 -0
- package/dist/engine/violation.js.map +1 -1
- package/dist/exceptions/biomeFindings.d.ts +5 -1
- package/dist/exceptions/biomeFindings.d.ts.map +1 -1
- package/dist/exceptions/biomeFindings.js +17 -18
- package/dist/exceptions/biomeFindings.js.map +1 -1
- package/dist/exceptions/registry.d.ts.map +1 -1
- package/dist/exceptions/registry.js +2 -2
- package/dist/exceptions/registry.js.map +1 -1
- package/dist/hooks/preCommit.d.ts +1 -2
- package/dist/hooks/preCommit.d.ts.map +1 -1
- package/dist/hooks/preCommit.js +16 -19
- 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/callsDefineModule.d.ts +3 -0
- package/dist/imports/callsDefineModule.d.ts.map +1 -0
- package/dist/imports/callsDefineModule.js +36 -0
- package/dist/imports/callsDefineModule.js.map +1 -0
- 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 +3 -1
- package/dist/imports/fences/check.js.map +1 -1
- package/dist/imports/fences/compilePolicy.js +1 -1
- package/dist/imports/fences/compilePolicy.js.map +1 -1
- package/dist/imports/fences/evaluate.d.ts +1 -1
- package/dist/imports/fences/evaluate.d.ts.map +1 -1
- package/dist/imports/fences/evaluate.js +1 -1
- package/dist/imports/fences/evaluate.js.map +1 -1
- package/dist/imports/generatedFolders.d.ts +7 -0
- package/dist/imports/generatedFolders.d.ts.map +1 -0
- package/dist/imports/generatedFolders.js +21 -0
- package/dist/imports/generatedFolders.js.map +1 -0
- 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/runtime.d.ts +1 -1
- package/dist/imports/runtime.d.ts.map +1 -1
- package/dist/imports/runtime.js +3 -2
- package/dist/imports/runtime.js.map +1 -1
- package/dist/inventory/programmaticBuilds.d.ts +1 -1
- package/dist/inventory/programmaticBuilds.d.ts.map +1 -1
- package/dist/inventory/trackedPaths.d.ts +1 -0
- package/dist/inventory/trackedPaths.d.ts.map +1 -1
- package/dist/inventory/trackedPaths.js +9 -3
- package/dist/inventory/trackedPaths.js.map +1 -1
- package/dist/naming/isOperationFile.d.ts +3 -0
- package/dist/naming/isOperationFile.d.ts.map +1 -0
- package/dist/naming/isOperationFile.js +42 -0
- package/dist/naming/isOperationFile.js.map +1 -0
- package/dist/naming/repeatedFolder.d.ts +2 -0
- package/dist/naming/repeatedFolder.d.ts.map +1 -0
- package/dist/naming/repeatedFolder.js +13 -0
- package/dist/naming/repeatedFolder.js.map +1 -0
- package/dist/naming/testCode.d.ts +1 -1
- package/dist/naming/testCode.d.ts.map +1 -1
- package/dist/report/render.d.ts +1 -0
- package/dist/report/render.d.ts.map +1 -1
- package/dist/report/render.js +10 -3
- package/dist/report/render.js.map +1 -1
- package/dist/report/runSetLine.d.ts +3 -0
- package/dist/report/runSetLine.d.ts.map +1 -0
- package/dist/report/runSetLine.js +13 -0
- package/dist/report/runSetLine.js.map +1 -0
- package/dist/report/staleSections.d.ts.map +1 -1
- package/dist/report/staleSections.js +13 -0
- package/dist/report/staleSections.js.map +1 -1
- package/dist/rule.d.ts +30 -4
- package/dist/rule.d.ts.map +1 -1
- package/dist/rule.js +4 -2
- package/dist/rule.js.map +1 -1
- package/dist/rules/biome.d.ts +18 -1
- package/dist/rules/biome.d.ts.map +1 -1
- package/dist/rules/biome.js +32 -7
- package/dist/rules/biome.js.map +1 -1
- package/dist/rules/builtIn.d.ts +7 -9
- package/dist/rules/builtIn.d.ts.map +1 -1
- package/dist/rules/builtIn.js +2 -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/files/namedAfterExport.d.ts.map +1 -1
- package/dist/rules/files/namedAfterExport.js +11 -12
- package/dist/rules/files/namedAfterExport.js.map +1 -1
- 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/resolvable.d.ts +1 -3
- package/dist/rules/imports/resolvable.d.ts.map +1 -1
- package/dist/rules/imports/resolvable.js +12 -10
- package/dist/rules/imports/resolvable.js.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 +49 -9
- package/dist/rules/imports/runtime.js.map +1 -1
- package/dist/rules/manifestsNoTestKits.js +1 -1
- package/dist/rules/manifestsNoTestKits.js.map +1 -1
- package/dist/rules/maxLines.d.ts +1 -1
- package/dist/rules/maxLines.d.ts.map +1 -1
- package/dist/rules/packageFindings.d.ts +31 -0
- package/dist/rules/packageFindings.d.ts.map +1 -0
- package/dist/rules/packageFindings.js +65 -0
- package/dist/rules/packageFindings.js.map +1 -0
- package/dist/rules/parse.d.ts +4 -1
- package/dist/rules/parse.d.ts.map +1 -1
- package/dist/rules/parse.js +35 -2
- package/dist/rules/parse.js.map +1 -1
- package/dist/rules/rootedFindings.d.ts +5 -0
- package/dist/rules/rootedFindings.d.ts.map +1 -0
- package/dist/rules/rootedFindings.js +16 -0
- package/dist/rules/rootedFindings.js.map +1 -0
- package/dist/rules/stories/adapterOnlyFakes.d.ts +1 -1
- package/dist/rules/stories/adapterOnlyFakes.d.ts.map +1 -1
- package/dist/rules/stories/adapterOnlyFakes.js +1 -0
- package/dist/rules/stories/adapterOnlyFakes.js.map +1 -1
- package/dist/rules/stories/databaseUrl.d.ts +1 -1
- package/dist/rules/stories/databaseUrl.d.ts.map +1 -1
- package/dist/rules/stories/databaseUrl.js +1 -0
- package/dist/rules/stories/databaseUrl.js.map +1 -1
- package/dist/rules/stories/domainOutcomes.d.ts +1 -1
- package/dist/rules/stories/domainOutcomes.d.ts.map +1 -1
- package/dist/rules/stories/domainOutcomes.js +1 -0
- package/dist/rules/stories/domainOutcomes.js.map +1 -1
- package/dist/rules/stories/engine.d.ts +1 -1
- package/dist/rules/stories/engine.d.ts.map +1 -1
- package/dist/rules/stories/engine.js +1 -0
- package/dist/rules/stories/engine.js.map +1 -1
- package/dist/rules/stories/globalRetries.d.ts +1 -1
- package/dist/rules/stories/globalRetries.d.ts.map +1 -1
- package/dist/rules/stories/globalRetries.js +1 -0
- package/dist/rules/stories/globalRetries.js.map +1 -1
- package/dist/rules/stories/groupedOutcomes.d.ts +1 -1
- package/dist/rules/stories/groupedOutcomes.d.ts.map +1 -1
- package/dist/rules/stories/groupedOutcomes.js +1 -0
- package/dist/rules/stories/groupedOutcomes.js.map +1 -1
- package/dist/rules/stories/importedChangeKeys.js +2 -2
- package/dist/rules/stories/importedChangeKeys.js.map +1 -1
- package/dist/rules/stories/namedValues.d.ts +1 -1
- package/dist/rules/stories/namedValues.d.ts.map +1 -1
- package/dist/rules/stories/namedValues.js +1 -0
- package/dist/rules/stories/namedValues.js.map +1 -1
- package/dist/rules/stories/noExpect.d.ts +1 -1
- package/dist/rules/stories/noExpect.d.ts.map +1 -1
- package/dist/rules/stories/noLimitImports.d.ts +1 -1
- package/dist/rules/stories/noLimitImports.d.ts.map +1 -1
- package/dist/rules/stories/noLimitImports.js +1 -0
- package/dist/rules/stories/noLimitImports.js.map +1 -1
- package/dist/rules/stories/positiveRefusals.d.ts +1 -1
- package/dist/rules/stories/positiveRefusals.d.ts.map +1 -1
- package/dist/rules/stories/positiveRefusals.js +1 -0
- package/dist/rules/stories/positiveRefusals.js.map +1 -1
- package/dist/rules/stories/queueReadouts.d.ts +1 -1
- package/dist/rules/stories/queueReadouts.d.ts.map +1 -1
- package/dist/rules/stories/queueReadouts.js +1 -0
- package/dist/rules/stories/queueReadouts.js.map +1 -1
- package/dist/rules/stories/rawServers.d.ts +2 -0
- package/dist/rules/stories/rawServers.d.ts.map +1 -0
- package/dist/rules/stories/rawServers.js +100 -0
- package/dist/rules/stories/rawServers.js.map +1 -0
- package/dist/rules/stories/sources.d.ts +2 -2
- package/dist/rules/stories/sources.d.ts.map +1 -1
- package/dist/rules/stories/specHelpers.d.ts +1 -1
- package/dist/rules/stories/specHelpers.d.ts.map +1 -1
- package/dist/rules/stories/specHelpers.js +3 -2
- package/dist/rules/stories/specHelpers.js.map +1 -1
- package/dist/rules/stories/specs.d.ts +1 -1
- package/dist/rules/stories/specs.d.ts.map +1 -1
- package/dist/rules/stories/specs.js +1 -0
- package/dist/rules/stories/specs.js.map +1 -1
- package/dist/rules/stories/waitOnEvents.d.ts +1 -1
- package/dist/rules/stories/waitOnEvents.d.ts.map +1 -1
- package/dist/rules/stories/waitOnEvents.js +3 -3
- package/dist/rules/stories/waitOnEvents.js.map +1 -1
- package/dist/rules/suppressions/noDoubleCast.d.ts.map +1 -1
- package/dist/rules/suppressions/noDoubleCast.js +4 -49
- package/dist/rules/suppressions/noDoubleCast.js.map +1 -1
- package/dist/rules/suppressions/typedCastCheck.d.ts +10 -0
- package/dist/rules/suppressions/typedCastCheck.d.ts.map +1 -0
- package/dist/rules/suppressions/typedCastCheck.js +48 -0
- package/dist/rules/suppressions/typedCastCheck.js.map +1 -0
- package/dist/rules/unusedCode.d.ts.map +1 -1
- package/dist/rules/unusedCode.js +1 -0
- package/dist/rules/unusedCode.js.map +1 -1
- package/dist/testing/adapters/cli.d.ts +1 -0
- package/dist/testing/adapters/cli.d.ts.map +1 -1
- package/dist/testing/adapters/cli.js +10 -8
- package/dist/testing/adapters/cli.js.map +1 -1
- package/dist/testing/adapters/git.d.ts +1 -16
- package/dist/testing/adapters/git.d.ts.map +1 -1
- package/dist/testing/adapters/git.js +5 -10
- package/dist/testing/adapters/git.js.map +1 -1
- package/dist/testing/adapters/hookRepository.d.ts +3 -2
- package/dist/testing/adapters/hookRepository.d.ts.map +1 -1
- package/dist/testing/adapters/hookRepository.js +11 -8
- package/dist/testing/adapters/hookRepository.js.map +1 -1
- package/dist/testing/adapters/imports.d.ts.map +1 -1
- package/dist/testing/adapters/imports.js +4 -1
- package/dist/testing/adapters/imports.js.map +1 -1
- package/dist/testing/ruleStory.d.ts +1 -1
- package/dist/testing/ruleStory.js +2 -2
- package/dist/testing/ruleStory.js.map +1 -1
- package/docs/debt-and-hooks.md +5 -3
- package/docs/north-star.md +1 -1
- 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/declarationTagParameter.ts +4 -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/imports/resolve.ts +31 -5
- package/src/adapters/knip/configuration.ts +6 -4
- package/src/adapters/knip/run.ts +4 -1
- package/src/adapters/outsideImportFindings.ts +21 -65
- package/src/adapters/presenceCheck.ts +17 -0
- package/src/adapters/rule.ts +29 -6
- package/src/adapters/runMain.ts +7 -6
- package/src/adapters/{serviceModelFindings.ts → serviceModelCheck.ts} +10 -25
- package/src/adapters/sharedErrorCatalog.ts +43 -0
- package/src/adapters/sharedErrorModules.ts +1 -1
- package/src/adapters/specReaderSources.ts +6 -3
- package/src/adapters/storyProgram.ts +20 -3
- package/src/adapters/typeScriptProgram.ts +57 -0
- package/src/baseline/compare.ts +59 -19
- package/src/baseline/format.ts +7 -2
- package/src/baseline/merge.ts +15 -1
- package/src/baseline/rewrite.ts +3 -1
- package/src/baseline/update.ts +38 -8
- package/src/biome/exceptionConfig.ts +24 -3
- package/src/biome/scannerRules.ts +42 -0
- package/src/cli/args.ts +13 -2
- package/src/cli/baseline.ts +7 -1
- package/src/cli/lint.ts +14 -6
- package/src/cli/misplaced.ts +4 -2
- package/src/cli/program.ts +1 -1
- package/src/cli/runSet.ts +17 -0
- package/src/cli/shrink.ts +4 -11
- package/src/cli/usage.ts +7 -2
- package/src/config/decode.ts +1 -0
- package/src/config/load.ts +3 -0
- package/src/config/resolve.ts +11 -6
- package/src/config.ts +3 -0
- package/src/engine/childStarted.ts +8 -0
- package/src/engine/evaluate.ts +3 -1
- package/src/engine/generateFirst.ts +32 -0
- package/src/engine/projectScripts.ts +25 -0
- package/src/engine/runRule.ts +103 -0
- package/src/engine/runRules.ts +64 -86
- package/src/engine/session.ts +25 -5
- package/src/engine/violation.ts +16 -0
- package/src/exceptions/biomeFindings.ts +24 -21
- package/src/exceptions/registry.ts +2 -2
- package/src/hooks/preCommit.ts +24 -24
- package/src/hooks/stagedCheck.ts +54 -0
- package/src/hooks/withStagedContent.ts +111 -0
- package/src/imports/browserNames.ts +7 -5
- package/src/imports/callsDefineModule.ts +43 -0
- package/src/imports/fences/check.ts +3 -1
- package/src/imports/fences/compilePolicy.ts +1 -1
- package/src/imports/fences/evaluate.ts +2 -2
- package/src/imports/generatedFolders.ts +28 -0
- package/src/imports/graph.ts +47 -3
- package/src/imports/runtime.ts +7 -2
- package/src/inventory/trackedPaths.ts +10 -3
- package/src/naming/isOperationFile.ts +52 -0
- package/src/naming/repeatedFolder.ts +14 -0
- package/src/report/render.ts +12 -3
- package/src/report/runSetLine.ts +14 -0
- package/src/report/staleSections.ts +14 -0
- package/src/rule.ts +38 -7
- package/src/rules/biome.ts +53 -7
- package/src/rules/builtIn.ts +2 -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/files/namedAfterExport.ts +14 -13
- package/src/rules/imports/resolvable.ts +13 -11
- package/src/rules/imports/runtime.ts +71 -10
- 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/rawServers.ts +118 -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/imports/withoutGenerated.d.ts +0 -8
- package/dist/imports/withoutGenerated.d.ts.map +0 -1
- package/dist/imports/withoutGenerated.js +0 -65
- package/dist/imports/withoutGenerated.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/imports/withoutGenerated.ts +0 -82
- package/src/rules/effect/program.ts +0 -57
- package/src/rules/effect/sqlTransact.ts +0 -10
- package/src/rules/suppressions/biomeRecommended.ts +0 -60
|
@@ -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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { realpathSync } from "node:fs";
|
|
1
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { dirname, join, relative } from "node:path";
|
|
4
4
|
import ts from "typescript";
|
|
@@ -82,13 +82,39 @@ function resolvedPath(request: ImportRequest, from: string, project: Project): s
|
|
|
82
82
|
return path === undefined ? undefined : fitting(path, request.type);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
// A package import of a missing file names a path in the repository when a workspace link leads there, outside installed packages.
|
|
86
|
+
function linkedTarget(root: string, path: string): string | undefined {
|
|
87
|
+
if (!path.includes(NODE_MODULES)) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
let folder = dirname(path);
|
|
91
|
+
while (!existsSync(folder) && dirname(folder) !== folder) {
|
|
92
|
+
folder = dirname(folder);
|
|
93
|
+
}
|
|
94
|
+
const target = posix(relative(realpathSync(root), join(realpathSync(folder), relative(folder, path))));
|
|
95
|
+
return target.startsWith("../") || target.split("/").includes("node_modules") ? undefined : target;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function workspaceHost(root: string): ts.ModuleResolutionHost {
|
|
99
|
+
return {
|
|
100
|
+
...ts.sys,
|
|
101
|
+
fileExists: (path) => ts.sys.fileExists(path) || (!path.endsWith(`/${PACKAGE_JSON}`) && linkedTarget(root, path) !== undefined),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
85
105
|
export function presumedTarget(root: string, request: ImportRequest, from: string, project: Project): string | undefined {
|
|
86
|
-
|
|
106
|
+
const specifier = request.specifier.replace(QUERY, "");
|
|
107
|
+
if (request.kind !== "import" || specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
87
108
|
return undefined;
|
|
88
109
|
}
|
|
89
|
-
|
|
90
|
-
.resolvedModule
|
|
91
|
-
|
|
110
|
+
if (specifier.startsWith(PACKAGE_IMPORT)) {
|
|
111
|
+
const path = ts.resolveModuleName(specifier, from, project.options, presumingHost, undefined, undefined, request.mode).resolvedModule
|
|
112
|
+
?.resolvedFileName;
|
|
113
|
+
return path === undefined ? undefined : posix(relative(root, path));
|
|
114
|
+
}
|
|
115
|
+
const path = ts.resolveModuleName(specifier, from, project.options, workspaceHost(root), undefined, undefined, request.mode).resolvedModule
|
|
116
|
+
?.resolvedFileName;
|
|
117
|
+
return path === undefined ? undefined : linkedTarget(root, path);
|
|
92
118
|
}
|
|
93
119
|
|
|
94
120
|
function endpointAt(root: string, specifier: string, path: string): Endpoint {
|
|
@@ -51,7 +51,7 @@ function externalDependencies(manifest: PackageManifest, externals: ReadonlySet<
|
|
|
51
51
|
|
|
52
52
|
export const knipConfiguration = Effect.fn("Knip.knipConfiguration")(function* (
|
|
53
53
|
inputs: RuleInputs,
|
|
54
|
-
|
|
54
|
+
unchecked: readonly string[] = [],
|
|
55
55
|
builds: ReachableBuilds = { entries: new Set(), externals: new Map() },
|
|
56
56
|
declared: readonly string[] = declaredEntries(inputs),
|
|
57
57
|
) {
|
|
@@ -81,7 +81,9 @@ export const knipConfiguration = Effect.fn("Knip.knipConfiguration")(function* (
|
|
|
81
81
|
const configs = sources.filter(isToolConfig);
|
|
82
82
|
// Migration runners load these files from their directory, so no import reaches them.
|
|
83
83
|
const migrations = sources.filter((path) => /(?:^|\/)server\/migrations\//u.test(path));
|
|
84
|
-
const
|
|
84
|
+
const followed = unchecked
|
|
85
|
+
.filter((file) => (packageOf(packages, file)?.directory ?? ".") === directory)
|
|
86
|
+
.map((file) => posix.relative(directory, file));
|
|
85
87
|
const workspaceEntries = declared
|
|
86
88
|
.filter((file) => (packageOf(packages, file)?.directory ?? ".") === directory)
|
|
87
89
|
.map((file) => posix.relative(directory, file));
|
|
@@ -100,7 +102,7 @@ export const knipConfiguration = Effect.fn("Knip.knipConfiguration")(function* (
|
|
|
100
102
|
...binaries,
|
|
101
103
|
...scriptEntries,
|
|
102
104
|
...bundled,
|
|
103
|
-
...
|
|
105
|
+
...followed,
|
|
104
106
|
...styles,
|
|
105
107
|
...workspaceEntries,
|
|
106
108
|
],
|
|
@@ -110,7 +112,7 @@ export const knipConfiguration = Effect.fn("Knip.knipConfiguration")(function* (
|
|
|
110
112
|
...deliveredDependencies(manifest, sources),
|
|
111
113
|
],
|
|
112
114
|
paths: importPaths(manifest.imports ?? {}),
|
|
113
|
-
project: [...sources, ...
|
|
115
|
+
project: [...sources, ...followed, ...styles, ...workspaceEntries],
|
|
114
116
|
vitest: { config: ["vitest*.config.{ts,mts,cts,js,mjs,cjs}", "vitest.{workspace,projects}.{ts,mts,cts,js,mjs,cjs,json}"] },
|
|
115
117
|
},
|
|
116
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,89 +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 { packageNameOf } from "#imports/packageName.ts";
|
|
8
9
|
import type { PnpmWorkspaceFailure } from "#imports/pnpmWorkspacePatterns.ts";
|
|
9
10
|
import { packageOf } from "#imports/workspace.ts";
|
|
10
|
-
import { testName } from "#naming/testName.ts";
|
|
11
11
|
import type { Finding, RuleInputs } from "#rule.ts";
|
|
12
12
|
import { entryModules } from "#rules/effect/boundaryReference.ts";
|
|
13
13
|
|
|
14
|
-
const CLIENT_RENDERING_LIBRARIES = new Set([
|
|
15
|
-
"react",
|
|
16
|
-
"react-dom",
|
|
17
|
-
"recharts",
|
|
18
|
-
"lucide-react",
|
|
19
|
-
"@base-ui/react",
|
|
20
|
-
"@tanstack/react-router",
|
|
21
|
-
"@tanstack/react-table",
|
|
22
|
-
"class-variance-authority",
|
|
23
|
-
"cn",
|
|
24
|
-
"clsx",
|
|
25
|
-
"tailwind-merge",
|
|
26
|
-
]);
|
|
27
|
-
|
|
28
14
|
// Path functions compute strings and touch no file system or process state, so they need no adapter.
|
|
29
15
|
const PURE_BUILTINS = new Set(["node:path", "node:path/posix", "node:path/win32"]);
|
|
30
16
|
|
|
31
|
-
function exempt(directory: string, path: string, name: string): boolean {
|
|
32
|
-
return (
|
|
33
|
-
/(?:^|\/)(?:adapters|test-support)\//u.test(path)
|
|
34
|
-
|| PURE_BUILTINS.has(name)
|
|
35
|
-
|| isPackageRootConfig(directory, path)
|
|
36
|
-
|| (name === "vitest" && testName(path) !== undefined)
|
|
37
|
-
|| name === "effect"
|
|
38
|
-
|| name.startsWith("@effect/")
|
|
39
|
-
|| name.startsWith("@shivaedev/")
|
|
40
|
-
|| (CLIENT_RENDERING_LIBRARIES.has(name) && /(?:^|\/)client\//u.test(path))
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
17
|
export const outsideImportFindings = Effect.fn("Imports.outsideImportFindings")(function* (
|
|
45
18
|
inputs: RuleInputs,
|
|
46
|
-
): Effect.fn.Return<
|
|
19
|
+
): Effect.fn.Return<
|
|
20
|
+
readonly Finding[],
|
|
21
|
+
GlobFailure | ImportAnalysisFailure | ManifestReadFailure | PnpmWorkspaceFailure | SetupFailure,
|
|
22
|
+
ChildProcessSpawner.ChildProcessSpawner
|
|
23
|
+
> {
|
|
47
24
|
const graph = yield* importGraph(inputs);
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
] as const;
|
|
59
|
-
}),
|
|
60
|
-
{ concurrency: "unbounded" },
|
|
61
|
-
),
|
|
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
|
+
: [],
|
|
62
35
|
);
|
|
63
|
-
const
|
|
64
|
-
const sites = [
|
|
65
|
-
...graph.edges.flatMap((edge) => (edge.to.kind === "external" ? [{ ...edge, name: edge.to.package }] : [])),
|
|
66
|
-
...graph.unresolved
|
|
67
|
-
.filter((edge) => edge.missing === undefined && !/^[.#/]/u.test(edge.specifier))
|
|
68
|
-
.map((edge) => ({ ...edge, name: packageNameOf(edge.specifier) })),
|
|
69
|
-
];
|
|
70
|
-
const outside = sites.filter((site) => {
|
|
71
|
-
const directory = packageOf(graph.packages, site.from)?.directory ?? ".";
|
|
72
|
-
return !(
|
|
73
|
-
workspace.has(site.name)
|
|
74
|
-
|| site.type
|
|
75
|
-
|| site.kind !== "import"
|
|
76
|
-
|| exempt(directory, site.from, site.name)
|
|
77
|
-
|| !(site.name.startsWith("node:") || runtime.get(directory)?.has(site.name))
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
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] : [])));
|
|
81
37
|
const entries = entryModules(inputs.sources.filter((file) => processImporters.has(file.path)));
|
|
82
|
-
return
|
|
38
|
+
return builtins
|
|
83
39
|
.filter((site) => !(site.name === "node:process" && entries.has(site.from)))
|
|
84
40
|
.map((site) => ({
|
|
85
41
|
file: site.from,
|
|
86
42
|
line: site.line,
|
|
87
|
-
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/.`,
|
|
88
44
|
}));
|
|
89
45
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
export function presenceCheck(checker: ts.TypeChecker, value: ts.Expression): boolean {
|
|
4
|
+
const comparison = value.parent;
|
|
5
|
+
if (!ts.isBinaryExpression(comparison)) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const operator = comparison.operatorToken.kind;
|
|
9
|
+
const other = comparison.left === value ? comparison.right : comparison.left;
|
|
10
|
+
return (
|
|
11
|
+
(operator === ts.SyntaxKind.EqualsEqualsEqualsToken
|
|
12
|
+
|| operator === ts.SyntaxKind.ExclamationEqualsEqualsToken
|
|
13
|
+
|| operator === ts.SyntaxKind.EqualsEqualsToken
|
|
14
|
+
|| operator === ts.SyntaxKind.ExclamationEqualsToken)
|
|
15
|
+
&& (checker.getTypeAtLocation(other).flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Null)) !== 0
|
|
16
|
+
);
|
|
17
|
+
}
|
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 });
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
1
|
import ts from "typescript";
|
|
4
2
|
import { serviceAssemblyImports } from "#adapters/serviceAssemblyImports.ts";
|
|
5
3
|
import { directServiceDefinitions } from "#adapters/serviceAssemblySyntax.ts";
|
|
6
4
|
import { serviceOperationProblems } from "#adapters/serviceOperationProblems.ts";
|
|
7
5
|
import { serviceStateProblems } from "#adapters/serviceStateProblems.ts";
|
|
8
|
-
import type { Finding,
|
|
9
|
-
import { effectProgram } from "#rules/effect/program.ts";
|
|
6
|
+
import type { Finding, SourceFile, TypeScriptProgram } from "#rule.ts";
|
|
10
7
|
import { serviceCatalog } from "#rules/effect/serviceCatalog.ts";
|
|
11
8
|
import { parse } from "#rules/parse.ts";
|
|
12
9
|
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
|
|
10
|
+
function definesServices(file: SourceFile): boolean {
|
|
11
|
+
const source = file.text.includes("defineService") ? parse(file) : undefined;
|
|
12
|
+
return source !== undefined && directServiceDefinitions(source, serviceAssemblyImports(source).definitions).length > 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function checkServices(sources: readonly SourceFile[], { checker, program, sourceFile }: TypeScriptProgram): readonly Finding[] {
|
|
16
16
|
const services = serviceCatalog(program, checker, [], true);
|
|
17
17
|
const found: Finding[] = [];
|
|
18
|
-
for (const file of
|
|
19
|
-
const source =
|
|
18
|
+
for (const file of sources) {
|
|
19
|
+
const source = sourceFile(file.path);
|
|
20
20
|
if (source === undefined) {
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
@@ -34,19 +34,4 @@ function checkServices(inputs: RuleInputs): readonly Finding[] {
|
|
|
34
34
|
return found;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export const
|
|
38
|
-
Effect.sync(() => {
|
|
39
|
-
const groups = new Map<string, RuleInputs["sources"][number][]>();
|
|
40
|
-
for (const file of inputs.sources) {
|
|
41
|
-
const source = parse(file);
|
|
42
|
-
if (source === undefined || directServiceDefinitions(source, serviceAssemblyImports(source).definitions).length === 0) {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
const group = /^(?:packages|examples)\/[^/]+/u.exec(file.path)?.[0] ?? ".";
|
|
46
|
-
const sources = groups.get(group) ?? [];
|
|
47
|
-
sources.push(file);
|
|
48
|
-
groups.set(group, sources);
|
|
49
|
-
}
|
|
50
|
-
return [...groups.values()].flatMap((sources) => checkServices({ ...inputs, sources }));
|
|
51
|
-
}),
|
|
52
|
-
);
|
|
37
|
+
export const serviceModelCheck = { checks: definesServices, findings: checkServices };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import { sharedErrorModules } from "#adapters/sharedErrorModules.ts";
|
|
5
|
+
import type { RuleInputs } from "#rule.ts";
|
|
6
|
+
import { taggedClasses } from "#rules/effect/errorTags.ts";
|
|
7
|
+
|
|
8
|
+
export interface SharedError {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly path: string;
|
|
11
|
+
readonly specifier: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SharedErrorCatalog {
|
|
15
|
+
readonly byTag: ReadonlyMap<string, SharedError>;
|
|
16
|
+
readonly tagOf: (specifier: string, name: string) => string | undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Published packages ship their sources beside the declarations, and a source states each tag as a literal where a declaration buries it in a type.
|
|
20
|
+
function moduleSource(file: string): ts.SourceFile | undefined {
|
|
21
|
+
const published = file.replace(/\/dist\/(?<module>.+)\.d\.(?<kind>[cm]?)ts$/u, "/src/$<module>.$<kind>ts");
|
|
22
|
+
const path = published !== file && ts.sys.fileExists(published) ? published : file;
|
|
23
|
+
const text = ts.sys.readFile(path);
|
|
24
|
+
return text === undefined ? undefined : ts.createSourceFile(ts.sys.realpath?.(path) ?? path, text, ts.ScriptTarget.Latest, true);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const sharedErrorCatalog = Effect.fn("SharedErrors.sharedErrorCatalog")(function* (inputs: Pick<RuleInputs, "readText" | "root" | "sources">) {
|
|
28
|
+
const root = ts.sys.realpath?.(inputs.root) ?? inputs.root;
|
|
29
|
+
const byTag = new Map<string, SharedError>();
|
|
30
|
+
const bySpecifier = new Map<string, Map<string, string>>();
|
|
31
|
+
for (const { file, specifier } of yield* sharedErrorModules(inputs)) {
|
|
32
|
+
const source = moduleSource(file);
|
|
33
|
+
const exported = (source === undefined ? [] : taggedClasses(source, () => undefined)).filter(
|
|
34
|
+
({ name, node }) => name !== undefined && ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export,
|
|
35
|
+
);
|
|
36
|
+
for (const { name = "", tag } of exported) {
|
|
37
|
+
byTag.set(tag, { name, path: relative(root, source?.fileName ?? file).replaceAll("\\", "/"), specifier });
|
|
38
|
+
bySpecifier.set(specifier, new Map([...(bySpecifier.get(specifier) ?? []), [name, tag]]));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const catalog: SharedErrorCatalog = { byTag, tagOf: (specifier, name) => bySpecifier.get(specifier)?.get(name) };
|
|
42
|
+
return catalog;
|
|
43
|
+
});
|
|
@@ -47,7 +47,7 @@ function resolveModules(specifiers: readonly string[], from: string, project: Pr
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export const sharedErrorModules = Effect.fn("SharedErrors.sharedErrorModules")(function* (inputs: RuleInputs) {
|
|
50
|
+
export const sharedErrorModules = Effect.fn("SharedErrors.sharedErrorModules")(function* (inputs: Pick<RuleInputs, "readText" | "root" | "sources">) {
|
|
51
51
|
const projectOf = projectsFor(inputs.root);
|
|
52
52
|
const manifests = new Map<string, string>();
|
|
53
53
|
for (const source of inputs.sources) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
1
2
|
import ts from "typescript";
|
|
2
3
|
import { asymmetricMatcher } from "#adapters/asymmetricMatcher.ts";
|
|
4
|
+
import { DeclarationFiles } from "#adapters/declaration-files/service.ts";
|
|
3
5
|
import type { SourceFile } from "#rule.ts";
|
|
4
6
|
import { parse } from "#rules/parse.ts";
|
|
5
7
|
import { topLevelHelpers, unwrapped } from "#rules/stories/syntax.ts";
|
|
@@ -37,7 +39,7 @@ const READ_METHODS = new Set([
|
|
|
37
39
|
"values",
|
|
38
40
|
]);
|
|
39
41
|
|
|
40
|
-
export
|
|
42
|
+
export const specReaderSources = Effect.fn("SpecHelpers.specReaderSources")(function* (files: readonly SourceFile[]) {
|
|
41
43
|
const sources = files.flatMap((file) => {
|
|
42
44
|
const source = parse(file);
|
|
43
45
|
return source === undefined || topLevelHelpers(source).length === 0 ? [] : [source];
|
|
@@ -47,7 +49,8 @@ export function specReaderSources(files: readonly SourceFile[]) {
|
|
|
47
49
|
}
|
|
48
50
|
const options: ts.CompilerOptions = { allowJs: true, noResolve: true, target: ts.ScriptTarget.ESNext, types: [] };
|
|
49
51
|
const host = ts.createCompilerHost(options);
|
|
50
|
-
const
|
|
52
|
+
const declarations = yield* DeclarationFiles;
|
|
53
|
+
const getSourceFile = yield* declarations.reader(host, options);
|
|
51
54
|
const parsed = new Map(sources.map((source) => [source.fileName, source]));
|
|
52
55
|
host.getSourceFile = (path, ...args) => parsed.get(path) ?? getSourceFile(path, ...args);
|
|
53
56
|
const program = ts.createProgram([...parsed.keys()], options, host);
|
|
@@ -74,4 +77,4 @@ export function specReaderSources(files: readonly SourceFile[]) {
|
|
|
74
77
|
);
|
|
75
78
|
}
|
|
76
79
|
return sources.map((source) => ({ readCall, source }));
|
|
77
|
-
}
|
|
80
|
+
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
+
import { Effect } from "effect";
|
|
2
3
|
import ts from "typescript";
|
|
3
4
|
import { projectsFor } from "#adapters/imports/projects.ts";
|
|
4
5
|
import type { ImportGraph } from "#imports/graph.ts";
|
|
5
6
|
import type { RuleInputs } from "#rule.ts";
|
|
7
|
+
import { parse } from "#rules/parse.ts";
|
|
6
8
|
|
|
7
9
|
const programs = new WeakMap<RuleInputs["sources"], ts.Program>();
|
|
8
10
|
|
|
@@ -11,7 +13,7 @@ export function storyProgram(inputs: RuleInputs, graph: ImportGraph): ts.Program
|
|
|
11
13
|
if (known !== undefined) {
|
|
12
14
|
return known;
|
|
13
15
|
}
|
|
14
|
-
const sources = new Map(inputs.sources.map((file) => [join(inputs.root, file.path), file
|
|
16
|
+
const sources = new Map(inputs.sources.map((file) => [join(inputs.root, file.path), file]));
|
|
15
17
|
const targets = new Map(
|
|
16
18
|
graph.edges.flatMap((edge) =>
|
|
17
19
|
edge.to.kind === "file" ? [[`${join(inputs.root, edge.from)}:${edge.specifier}`, join(inputs.root, edge.to.path)] as const] : [],
|
|
@@ -23,10 +25,15 @@ export function storyProgram(inputs: RuleInputs, graph: ImportGraph): ts.Program
|
|
|
23
25
|
...ts.createCompilerHost(options),
|
|
24
26
|
fileExists: (path) => sources.has(path) || ts.sys.fileExists(path),
|
|
25
27
|
getSourceFile: (path) => {
|
|
26
|
-
const
|
|
28
|
+
const file = sources.get(path);
|
|
29
|
+
const tree = file === undefined ? undefined : parse(file);
|
|
30
|
+
if (tree !== undefined) {
|
|
31
|
+
return tree;
|
|
32
|
+
}
|
|
33
|
+
const text = file?.text ?? ts.sys.readFile(path);
|
|
27
34
|
return text === undefined ? undefined : ts.createSourceFile(path, text, ts.ScriptTarget.Latest, true);
|
|
28
35
|
},
|
|
29
|
-
readFile: (path) => sources.get(path) ?? ts.sys.readFile(path),
|
|
36
|
+
readFile: (path) => sources.get(path)?.text ?? ts.sys.readFile(path),
|
|
30
37
|
resolveModuleNames: (names, from) =>
|
|
31
38
|
names.map((name) => {
|
|
32
39
|
const path = targets.get(`${from}:${name}`);
|
|
@@ -44,3 +51,13 @@ export function storyProgram(inputs: RuleInputs, graph: ImportGraph): ts.Program
|
|
|
44
51
|
programs.set(inputs.sources, program);
|
|
45
52
|
return program;
|
|
46
53
|
}
|
|
54
|
+
|
|
55
|
+
export function withStoryProgram<TValue, TError, TServices>(
|
|
56
|
+
inputs: RuleInputs,
|
|
57
|
+
rules: Effect.Effect<TValue, TError, TServices>,
|
|
58
|
+
): Effect.Effect<TValue, TError, TServices> {
|
|
59
|
+
return Effect.ensuring(
|
|
60
|
+
rules,
|
|
61
|
+
Effect.sync(() => programs.delete(inputs.sources)),
|
|
62
|
+
);
|
|
63
|
+
}
|