@shivaedev/quality 0.45.0 → 0.46.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 +36 -0
- package/README.md +13 -7
- package/dist/PackageManifest.d.ts +25 -0
- package/dist/PackageManifest.d.ts.map +1 -0
- package/dist/PackageManifest.js +21 -0
- package/dist/PackageManifest.js.map +1 -0
- package/dist/adapters/TestOutput.d.ts +8 -0
- package/dist/adapters/TestOutput.d.ts.map +1 -0
- package/dist/adapters/TestOutput.js +5 -0
- package/dist/adapters/TestOutput.js.map +1 -0
- package/dist/adapters/knip/configuration.d.ts.map +1 -1
- package/dist/adapters/knip/configuration.js +2 -9
- package/dist/adapters/knip/configuration.js.map +1 -1
- package/dist/adapters/knip/entryPointFindings.d.ts.map +1 -1
- package/dist/adapters/knip/entryPointFindings.js +2 -1
- package/dist/adapters/knip/entryPointFindings.js.map +1 -1
- package/dist/adapters/knip/run.d.ts +3 -1
- package/dist/adapters/knip/run.d.ts.map +1 -1
- package/dist/adapters/knip/run.js +8 -8
- package/dist/adapters/knip/run.js.map +1 -1
- package/dist/adapters/manifestInventory.d.ts +23 -0
- package/dist/adapters/manifestInventory.d.ts.map +1 -0
- package/dist/adapters/manifestInventory.js +63 -0
- package/dist/adapters/manifestInventory.js.map +1 -0
- package/dist/adapters/manifestReader.d.ts +3 -0
- package/dist/adapters/manifestReader.d.ts.map +1 -0
- package/dist/adapters/manifestReader.js +8 -0
- package/dist/adapters/manifestReader.js.map +1 -0
- package/dist/adapters/testProjects.d.ts.map +1 -0
- package/dist/{testProjects.js → adapters/testProjects.js} +4 -3
- package/dist/adapters/testProjects.js.map +1 -0
- package/dist/appTestConfig.d.ts +1 -1
- package/dist/appTestConfig.d.ts.map +1 -1
- package/dist/appTestConfig.js +1 -1
- package/dist/appTestConfig.js.map +1 -1
- package/dist/baseline/format.js +2 -2
- package/dist/baseline/format.js.map +1 -1
- package/dist/baseline/legacy.js +2 -2
- package/dist/baseline/legacy.js.map +1 -1
- package/dist/baseline/merge.js +1 -1
- package/dist/baseline/merge.js.map +1 -1
- package/dist/baseline/shards.js +1 -1
- package/dist/baseline/shards.js.map +1 -1
- package/dist/biome/exceptionConfig.d.ts +7 -1
- package/dist/biome/exceptionConfig.d.ts.map +1 -1
- package/dist/biome/exceptionConfig.js +11 -25
- package/dist/biome/exceptionConfig.js.map +1 -1
- package/dist/biome/recommendedRules.d.ts +2 -1
- package/dist/biome/recommendedRules.d.ts.map +1 -1
- package/dist/biome/recommendedRules.js +10 -13
- package/dist/biome/recommendedRules.js.map +1 -1
- package/dist/biome/relocateConfig.d.ts +6 -0
- package/dist/biome/relocateConfig.d.ts.map +1 -0
- package/dist/biome/relocateConfig.js +49 -0
- package/dist/biome/relocateConfig.js.map +1 -0
- package/dist/biome/report.d.ts +27 -3
- package/dist/biome/report.d.ts.map +1 -1
- package/dist/biome/report.js +12 -10
- package/dist/biome/report.js.map +1 -1
- package/dist/biome/run.d.ts +12 -2
- package/dist/biome/run.d.ts.map +1 -1
- package/dist/biome/run.js +11 -15
- package/dist/biome/run.js.map +1 -1
- package/dist/biome/withoutEntryPointImports.d.ts.map +1 -1
- package/dist/biome/withoutEntryPointImports.js +2 -12
- package/dist/biome/withoutEntryPointImports.js.map +1 -1
- package/dist/cli/baseline.d.ts +4 -3
- package/dist/cli/baseline.d.ts.map +1 -1
- package/dist/cli/baseline.js.map +1 -1
- package/dist/cli/fix.d.ts +2 -1
- package/dist/cli/fix.d.ts.map +1 -1
- package/dist/cli/fix.js +3 -9
- package/dist/cli/fix.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.map +1 -1
- package/dist/cli/migrateBaseline.d.ts +3 -2
- package/dist/cli/migrateBaseline.d.ts.map +1 -1
- package/dist/cli/migrateBaseline.js +2 -2
- package/dist/cli/migrateBaseline.js.map +1 -1
- package/dist/cli/migrateExceptions.d.ts.map +1 -1
- package/dist/cli/migrateExceptions.js +6 -4
- package/dist/cli/migrateExceptions.js.map +1 -1
- package/dist/cli/program.d.ts +1 -1
- package/dist/cli/program.d.ts.map +1 -1
- package/dist/config/decode.d.ts +1 -1
- package/dist/config/decode.d.ts.map +1 -1
- package/dist/config/decode.js +1 -2
- package/dist/config/decode.js.map +1 -1
- package/dist/config/load.js +2 -2
- package/dist/config/load.js.map +1 -1
- package/dist/config/resolve.d.ts +1 -1
- package/dist/decoded.d.ts +2 -3
- package/dist/decoded.d.ts.map +1 -1
- package/dist/decoded.js +6 -4
- package/dist/decoded.js.map +1 -1
- package/dist/docs/documentedModule.d.ts +0 -2
- package/dist/docs/documentedModule.d.ts.map +1 -1
- package/dist/docs/documentedModule.js +0 -3
- package/dist/docs/documentedModule.js.map +1 -1
- package/dist/docs/importFindings.d.ts.map +1 -1
- package/dist/docs/importFindings.js +0 -3
- package/dist/docs/importFindings.js.map +1 -1
- package/dist/engine/baselineFile.js +2 -2
- package/dist/engine/baselineFile.js.map +1 -1
- package/dist/engine/runRules.d.ts +3 -4
- package/dist/engine/runRules.d.ts.map +1 -1
- package/dist/engine/runRules.js +23 -8
- package/dist/engine/runRules.js.map +1 -1
- package/dist/engine/session.d.ts +4 -3
- package/dist/engine/session.d.ts.map +1 -1
- package/dist/engine/session.js +6 -7
- package/dist/engine/session.js.map +1 -1
- package/dist/exceptions/declaration.js +2 -2
- package/dist/exceptions/declaration.js.map +1 -1
- package/dist/exceptions/registry.d.ts.map +1 -1
- package/dist/exceptions/registry.js +2 -4
- package/dist/exceptions/registry.js.map +1 -1
- package/dist/failure.d.ts +5 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +4 -0
- package/dist/failure.js.map +1 -1
- package/dist/git/command.js +1 -1
- package/dist/git/command.js.map +1 -1
- package/dist/hooks/install.js +2 -2
- package/dist/hooks/install.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 +10 -11
- package/dist/hooks/preCommit.js.map +1 -1
- package/dist/hooks/status.js +1 -1
- package/dist/hooks/status.js.map +1 -1
- package/dist/hooks/uninstall.js +3 -3
- package/dist/hooks/uninstall.js.map +1 -1
- package/dist/imports/classifyRuntime.d.ts +10 -0
- package/dist/imports/classifyRuntime.d.ts.map +1 -0
- package/dist/imports/classifyRuntime.js +22 -0
- package/dist/imports/classifyRuntime.js.map +1 -0
- package/dist/imports/fences/declarations.d.ts.map +1 -1
- package/dist/imports/fences/declarations.js +1 -2
- package/dist/imports/fences/declarations.js.map +1 -1
- package/dist/imports/pnpmWorkspacePatterns.d.ts.map +1 -1
- package/dist/imports/pnpmWorkspacePatterns.js +2 -1
- package/dist/imports/pnpmWorkspacePatterns.js.map +1 -1
- package/dist/imports/runtime.d.ts +4 -3
- package/dist/imports/runtime.d.ts.map +1 -1
- package/dist/imports/runtime.js +35 -64
- package/dist/imports/runtime.js.map +1 -1
- package/dist/imports/workspace.d.ts.map +1 -1
- package/dist/imports/workspace.js +9 -19
- package/dist/imports/workspace.js.map +1 -1
- package/dist/inventory/collect.d.ts +1 -0
- package/dist/inventory/collect.d.ts.map +1 -1
- package/dist/inventory/collect.js +2 -1
- package/dist/inventory/collect.js.map +1 -1
- package/dist/inventory/filesystem.d.ts.map +1 -1
- package/dist/inventory/filesystem.js +2 -8
- package/dist/inventory/filesystem.js.map +1 -1
- package/dist/manifests/entryPoints.d.ts.map +1 -1
- package/dist/manifests/entryPoints.js +2 -12
- package/dist/manifests/entryPoints.js.map +1 -1
- package/dist/manifests/sorted.d.ts +2 -3
- package/dist/manifests/sorted.d.ts.map +1 -1
- package/dist/manifests/sorted.js +14 -8
- package/dist/manifests/sorted.js.map +1 -1
- package/dist/naming/packageLayout.d.ts.map +1 -1
- package/dist/naming/packageLayout.js +2 -12
- package/dist/naming/packageLayout.js.map +1 -1
- package/dist/rule.d.ts +15 -10
- package/dist/rule.d.ts.map +1 -1
- package/dist/rule.js +9 -1
- package/dist/rule.js.map +1 -1
- package/dist/rules/biome.d.ts.map +1 -1
- package/dist/rules/biome.js +7 -4
- package/dist/rules/biome.js.map +1 -1
- package/dist/rules/builtIn.d.ts +14 -14
- package/dist/rules/builtIn.d.ts.map +1 -1
- package/dist/rules/builtIn.js +2 -0
- package/dist/rules/builtIn.js.map +1 -1
- package/dist/rules/comments/maxPerFile.d.ts +1 -1
- package/dist/rules/comments/maxPerFile.d.ts.map +1 -1
- package/dist/rules/comments/noBanner.d.ts +1 -1
- package/dist/rules/comments/noBanner.d.ts.map +1 -1
- package/dist/rules/comments/noEnvironmentPragma.d.ts +1 -1
- package/dist/rules/comments/noEnvironmentPragma.d.ts.map +1 -1
- package/dist/rules/comments/noEnvironmentPragma.js +1 -1
- package/dist/rules/comments/noEnvironmentPragma.js.map +1 -1
- package/dist/rules/comments/noJsdoc.d.ts +1 -1
- package/dist/rules/comments/noJsdoc.d.ts.map +1 -1
- package/dist/rules/comments/noLineReference.d.ts +1 -1
- package/dist/rules/comments/noLineReference.d.ts.map +1 -1
- package/dist/rules/comments/noPrReference.d.ts +1 -1
- package/dist/rules/comments/noPrReference.d.ts.map +1 -1
- package/dist/rules/comments/noTodo.d.ts +1 -1
- package/dist/rules/comments/noTodo.d.ts.map +1 -1
- package/dist/rules/docs/references.d.ts +1 -1
- package/dist/rules/docs/references.d.ts.map +1 -1
- package/dist/rules/docs/references.js +5 -8
- package/dist/rules/docs/references.js.map +1 -1
- package/dist/rules/docs/unversionedInstalls.d.ts +1 -1
- package/dist/rules/docs/unversionedInstalls.d.ts.map +1 -1
- package/dist/rules/docs/unversionedInstalls.js +1 -1
- package/dist/rules/docs/unversionedInstalls.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/serviceParameters.d.ts +1 -1
- package/dist/rules/effect/serviceParameters.d.ts.map +1 -1
- package/dist/rules/effect/serviceTypes.d.ts.map +1 -1
- package/dist/rules/effect/serviceTypes.js +10 -0
- package/dist/rules/effect/serviceTypes.js.map +1 -1
- package/dist/rules/files/distinctCase.d.ts +1 -1
- package/dist/rules/files/distinctCase.d.ts.map +1 -1
- package/dist/rules/files/folderNames.d.ts +1 -1
- package/dist/rules/files/folderNames.d.ts.map +1 -1
- package/dist/rules/files/namedAfterExport.d.ts +1 -1
- package/dist/rules/files/namedAfterExport.d.ts.map +1 -1
- package/dist/rules/files/otherNames.d.ts +1 -1
- package/dist/rules/files/otherNames.d.ts.map +1 -1
- package/dist/rules/files/packageImports.d.ts.map +1 -1
- package/dist/rules/files/packageImports.js +2 -13
- package/dist/rules/files/packageImports.js.map +1 -1
- package/dist/rules/imports/aliased.d.ts +1 -1
- package/dist/rules/imports/aliased.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/manifest.js +14 -32
- package/dist/rules/imports/manifest.js.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 -1
- package/dist/rules/imports/resolvable.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 +29 -25
- package/dist/rules/imports/runtime.js.map +1 -1
- package/dist/rules/manifestsApplication.d.ts +1 -1
- package/dist/rules/manifestsApplication.d.ts.map +1 -1
- package/dist/rules/manifestsApplication.js +2 -12
- package/dist/rules/manifestsApplication.js.map +1 -1
- package/dist/rules/manifestsExportsShape.d.ts +1 -1
- package/dist/rules/manifestsExportsShape.d.ts.map +1 -1
- package/dist/rules/manifestsExportsShape.js +12 -7
- package/dist/rules/manifestsExportsShape.js.map +1 -1
- package/dist/rules/manifestsSorted.d.ts +1 -1
- package/dist/rules/manifestsSorted.d.ts.map +1 -1
- package/dist/rules/manifestsSorted.js +10 -14
- package/dist/rules/manifestsSorted.js.map +1 -1
- package/dist/rules/manifestsSourceFirst.d.ts +1 -1
- package/dist/rules/manifestsSourceFirst.d.ts.map +1 -1
- package/dist/rules/manifestsSourceFirst.js +20 -23
- package/dist/rules/manifestsSourceFirst.js.map +1 -1
- package/dist/rules/manifestsValid.d.ts +2 -0
- package/dist/rules/manifestsValid.d.ts.map +1 -0
- package/dist/rules/manifestsValid.js +10 -0
- package/dist/rules/manifestsValid.js.map +1 -0
- package/dist/rules/maxDepth.d.ts +1 -1
- package/dist/rules/maxDepth.d.ts.map +1 -1
- package/dist/rules/maxLines.d.ts +1 -1
- package/dist/rules/maxLines.d.ts.map +1 -1
- package/dist/rules/noBarrel.d.ts +1 -1
- package/dist/rules/noBarrel.d.ts.map +1 -1
- package/dist/rules/react/jsxConditionals.d.ts +1 -1
- package/dist/rules/react/jsxConditionals.d.ts.map +1 -1
- package/dist/rules/stories/authSql.d.ts +1 -1
- package/dist/rules/stories/authSql.d.ts.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 +3 -3
- 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/groupedOutcomes.d.ts +1 -1
- package/dist/rules/stories/groupedOutcomes.d.ts.map +1 -1
- package/dist/rules/stories/groupedOutcomes.js +2 -2
- package/dist/rules/stories/groupedOutcomes.js.map +1 -1
- package/dist/rules/stories/httpStatus.d.ts +1 -1
- package/dist/rules/stories/httpStatus.d.ts.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/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/prerequisites.d.ts.map +1 -1
- package/dist/rules/stories/prerequisites.js +3 -6
- package/dist/rules/stories/prerequisites.js.map +1 -1
- package/dist/rules/stories/queueSql.d.ts +1 -1
- package/dist/rules/stories/queueSql.d.ts.map +1 -1
- package/dist/rules/stories/setup.d.ts +1 -1
- package/dist/rules/stories/setup.d.ts.map +1 -1
- package/dist/rules/stories/sources.d.ts +4 -0
- package/dist/rules/stories/sources.d.ts.map +1 -0
- package/dist/rules/stories/{specSources.js → sources.js} +6 -6
- package/dist/rules/stories/sources.js.map +1 -0
- package/dist/rules/stories/specHelpers.d.ts +1 -1
- package/dist/rules/stories/specHelpers.d.ts.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/waitOnEvents.d.ts +1 -1
- package/dist/rules/stories/waitOnEvents.d.ts.map +1 -1
- package/dist/rules/stories/waitOnEvents.js +4 -4
- package/dist/rules/stories/waitOnEvents.js.map +1 -1
- package/dist/rules/suppressions/biome/declarations.d.ts.map +1 -1
- package/dist/rules/suppressions/biome/declarations.js +2 -4
- package/dist/rules/suppressions/biome/declarations.js.map +1 -1
- package/dist/rules/suppressions/biome/resolvePackage.d.ts.map +1 -1
- package/dist/rules/suppressions/biome/resolvePackage.js +3 -15
- package/dist/rules/suppressions/biome/resolvePackage.js.map +1 -1
- package/dist/rules/suppressions/biomeOverrides.d.ts +1 -1
- package/dist/rules/suppressions/biomeOverrides.d.ts.map +1 -1
- package/dist/rules/suppressions/biomeRecommended.d.ts +6 -3
- package/dist/rules/suppressions/biomeRecommended.d.ts.map +1 -1
- package/dist/rules/suppressions/biomeRecommended.js +10 -7
- package/dist/rules/suppressions/biomeRecommended.js.map +1 -1
- package/dist/rules/suppressions/noDoubleCast.d.ts +1 -1
- package/dist/rules/suppressions/noDoubleCast.d.ts.map +1 -1
- package/dist/rules/suppressions/noIgnoreDeprecations.d.ts +1 -1
- package/dist/rules/suppressions/noIgnoreDeprecations.d.ts.map +1 -1
- package/dist/rules/suppressions/noIgnoreDeprecations.js +7 -7
- package/dist/rules/suppressions/noIgnoreDeprecations.js.map +1 -1
- package/dist/rules/suppressions/noInline.d.ts +1 -1
- package/dist/rules/suppressions/noInline.d.ts.map +1 -1
- package/dist/rules/test-names/colocated.d.ts +1 -1
- package/dist/rules/test-names/colocated.d.ts.map +1 -1
- package/dist/rules/test-names/follow.d.ts +1 -1
- package/dist/rules/test-names/follow.d.ts.map +1 -1
- package/dist/rules/unusedCode.d.ts +1 -1
- package/dist/rules/unusedCode.d.ts.map +1 -1
- package/package.json +2 -9
- package/src/PackageManifest.ts +24 -0
- package/src/adapters/TestOutput.ts +9 -0
- package/src/adapters/knip/configuration.ts +2 -10
- package/src/adapters/knip/entryPointFindings.ts +2 -1
- package/src/adapters/knip/run.ts +42 -44
- package/src/adapters/manifestInventory.ts +87 -0
- package/src/adapters/manifestReader.ts +11 -0
- package/src/{testProjects.ts → adapters/testProjects.ts} +4 -3
- package/src/appTestConfig.ts +1 -1
- package/src/baseline/format.ts +2 -2
- package/src/baseline/legacy.ts +2 -2
- package/src/baseline/merge.ts +1 -1
- package/src/baseline/shards.ts +1 -1
- package/src/biome/exceptionConfig.ts +19 -34
- package/src/biome/recommendedRules.ts +18 -16
- package/src/biome/relocateConfig.ts +59 -0
- package/src/biome/report.ts +17 -11
- package/src/biome/run.ts +22 -18
- package/src/biome/withoutEntryPointImports.ts +2 -12
- package/src/cli/baseline.ts +3 -2
- package/src/cli/fix.ts +15 -17
- package/src/cli/lint.ts +3 -2
- package/src/cli/migrateBaseline.ts +4 -3
- package/src/cli/migrateExceptions.ts +6 -4
- package/src/config/decode.ts +1 -3
- package/src/config/load.ts +2 -2
- package/src/decoded.ts +9 -5
- package/src/docs/documentedModule.ts +1 -4
- package/src/docs/importFindings.ts +0 -5
- package/src/engine/baselineFile.ts +2 -2
- package/src/engine/runRules.ts +34 -15
- package/src/engine/session.ts +11 -10
- package/src/exceptions/declaration.ts +2 -2
- package/src/exceptions/registry.ts +2 -4
- package/src/failure.ts +6 -1
- package/src/git/command.ts +1 -1
- package/src/hooks/install.ts +2 -2
- package/src/hooks/preCommit.ts +10 -16
- package/src/hooks/status.ts +1 -1
- package/src/hooks/uninstall.ts +3 -3
- package/src/imports/classifyRuntime.ts +30 -0
- package/src/imports/fences/declarations.ts +1 -3
- package/src/imports/pnpmWorkspacePatterns.ts +3 -1
- package/src/imports/runtime.ts +48 -60
- package/src/imports/workspace.ts +9 -20
- package/src/inventory/collect.ts +3 -1
- package/src/inventory/filesystem.ts +2 -10
- package/src/manifests/entryPoints.ts +2 -12
- package/src/manifests/sorted.ts +21 -9
- package/src/naming/packageLayout.ts +2 -12
- package/src/rule.ts +38 -19
- package/src/rules/biome.ts +9 -5
- package/src/rules/builtIn.ts +2 -0
- package/src/rules/comments/noEnvironmentPragma.ts +1 -1
- package/src/rules/docs/references.ts +8 -10
- package/src/rules/docs/unversionedInstalls.ts +1 -1
- package/src/rules/effect/serviceTypes.ts +13 -0
- package/src/rules/files/packageImports.ts +2 -13
- package/src/rules/imports/manifest.ts +15 -32
- package/src/rules/imports/runtime.ts +41 -35
- package/src/rules/manifestsApplication.ts +2 -12
- package/src/rules/manifestsExportsShape.ts +11 -8
- package/src/rules/manifestsSorted.ts +13 -16
- package/src/rules/manifestsSourceFirst.ts +24 -24
- package/src/rules/manifestsValid.ts +14 -0
- package/src/rules/stories/domainOutcomes.ts +3 -4
- package/src/rules/stories/groupedOutcomes.ts +2 -3
- package/src/rules/stories/prerequisites.ts +4 -8
- package/src/rules/stories/{specSources.ts → sources.ts} +5 -5
- package/src/rules/stories/waitOnEvents.ts +4 -5
- package/src/rules/suppressions/biome/declarations.ts +2 -4
- package/src/rules/suppressions/biome/resolvePackage.ts +5 -21
- package/src/rules/suppressions/biomeRecommended.ts +14 -9
- package/src/rules/suppressions/noIgnoreDeprecations.ts +11 -8
- package/dist/rules/stories/specSources.d.ts +0 -4
- package/dist/rules/stories/specSources.d.ts.map +0 -1
- package/dist/rules/stories/specSources.js.map +0 -1
- package/dist/testProjects.d.ts.map +0 -1
- package/dist/testProjects.js.map +0 -1
- /package/dist/{testProjects.d.ts → adapters/testProjects.d.ts} +0 -0
package/src/engine/runRules.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isAbsolute, relative } from "node:path";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
-
import {
|
|
3
|
+
import { ManifestFailure } from "#adapters/manifestInventory.ts";
|
|
4
4
|
import { posix } from "#inventory/ignoreScope.ts";
|
|
5
|
-
import type { Finding,
|
|
5
|
+
import type { Finding, RuleCheck, RuleInputs, RuleServices } from "#rule.ts";
|
|
6
6
|
import type { ActiveLevel, Violation } from "./violation.ts";
|
|
7
7
|
|
|
8
8
|
export interface ActiveRule {
|
|
9
|
-
readonly check:
|
|
9
|
+
readonly check: RuleCheck;
|
|
10
10
|
readonly description: string;
|
|
11
11
|
readonly family: boolean;
|
|
12
12
|
readonly id: string;
|
|
@@ -48,19 +48,38 @@ function violationOf(rule: ActiveRule, root: string, finding: Finding, exception
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
function runRule(rule: ActiveRule, inputs: RuleInputs, exceptionFile: string): Effect.Effect<readonly Violation[],
|
|
52
|
-
return Effect.
|
|
53
|
-
Effect.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
function runRule(rule: ActiveRule, inputs: RuleInputs, exceptionFile: string): Effect.Effect<readonly Violation[], never, RuleServices> {
|
|
52
|
+
return Effect.suspend(() => rule.check(inputs)).pipe(
|
|
53
|
+
Effect.orDie,
|
|
54
|
+
Effect.map((findings) => findings.map((finding) => violationOf(rule, inputs.root, finding, exceptionFile))),
|
|
55
|
+
Effect.catchDefect((cause) =>
|
|
56
|
+
cause instanceof ManifestFailure
|
|
57
|
+
? Effect.succeed([{ file: cause.path, level: "error" as const, message: cause.message, rule: "manifests/valid" }])
|
|
58
|
+
: Effect.die(new Error(`rule ${rule.id} failed: ${messageOf(cause)}`, { cause })),
|
|
59
|
+
),
|
|
58
60
|
);
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
export
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
(
|
|
63
|
+
export const runRules = Effect.fn("Engine.runRules")(function* (rules: readonly ActiveRule[], inputs: RuleInputs) {
|
|
64
|
+
const validation = rules.find((rule) => rule.id === "manifests/valid");
|
|
65
|
+
if (validation !== undefined) {
|
|
66
|
+
const failures = yield* runRule(validation, inputs, inputs.configFile ?? "quality.config.ts");
|
|
67
|
+
if (failures.length > 0) {
|
|
68
|
+
return failures;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const results = yield* Effect.forEach(
|
|
72
|
+
rules.filter((rule) => rule !== validation),
|
|
73
|
+
(rule) => runRule(rule, inputs, inputs.configFile ?? "quality.config.ts"),
|
|
74
|
+
{ concurrency: "unbounded" },
|
|
65
75
|
);
|
|
66
|
-
|
|
76
|
+
const seen = new Set<string>();
|
|
77
|
+
return results.flat().filter((finding) => {
|
|
78
|
+
if (finding.rule !== "manifests/valid") {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
const duplicate = seen.has(finding.file);
|
|
82
|
+
seen.add(finding.file);
|
|
83
|
+
return !duplicate;
|
|
84
|
+
});
|
|
85
|
+
});
|
package/src/engine/session.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { relative
|
|
2
|
-
import { Effect
|
|
1
|
+
import { relative } from "node:path";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { setManifestFiles } from "#adapters/manifestInventory.ts";
|
|
4
|
+
import { manifestReader } from "#adapters/manifestReader.ts";
|
|
3
5
|
import { loadConfig, type ResolvedConfig } from "#config/load.ts";
|
|
4
6
|
import { validOrFail } from "#decoded.ts";
|
|
5
7
|
import { decodeRegistry, type RegistryEntry } from "#exceptions/registry.ts";
|
|
6
8
|
import { registryEntries } from "#exceptions/registryEntries.ts";
|
|
7
9
|
import { SetupFailure } from "#failure.ts";
|
|
8
10
|
import { collectInventory, type Inventory } from "#inventory/collect.ts";
|
|
9
|
-
import {
|
|
11
|
+
import type { FilesystemFailure } from "#inventory/filesystem.ts";
|
|
12
|
+
import type { RuleServices } from "#rule.ts";
|
|
10
13
|
import { type BaselineFile, readBaseline, readInput } from "./baselineFile.ts";
|
|
11
14
|
import { runRules } from "./runRules.ts";
|
|
12
15
|
import type { Violation } from "./violation.ts";
|
|
@@ -22,17 +25,15 @@ export interface Session {
|
|
|
22
25
|
function setup<TValue, TRequirements>(
|
|
23
26
|
effect: Effect.Effect<TValue, FilesystemFailure, TRequirements>,
|
|
24
27
|
): Effect.Effect<TValue, SetupFailure, TRequirements> {
|
|
25
|
-
return Effect.mapError(effect, (failure) => new SetupFailure({ message: failure.message }));
|
|
28
|
+
return Effect.mapError(effect, (failure) => new SetupFailure({ cause: failure, message: failure.message }));
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
export const scan = Effect.fn("Engine.scan")(function* (
|
|
29
32
|
config: ResolvedConfig,
|
|
30
|
-
): Effect.fn.Return<Pick<Session, "inventory" | "violations">, SetupFailure,
|
|
33
|
+
): Effect.fn.Return<Pick<Session, "inventory" | "violations">, SetupFailure, RuleServices> {
|
|
31
34
|
const inventory = yield* setup(collectInventory(config.root, config));
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
return Effect.runPromiseWith(services)(readOptionalText(resolve(config.root, path)));
|
|
35
|
-
}
|
|
35
|
+
const readText = yield* manifestReader(config.root);
|
|
36
|
+
setManifestFiles(readText, inventory.manifestFiles);
|
|
36
37
|
const violations = yield* runRules(config.active, {
|
|
37
38
|
configFile: relative(config.root, config.file),
|
|
38
39
|
exceptions: config.exceptions,
|
|
@@ -47,7 +48,7 @@ export const scan = Effect.fn("Engine.scan")(function* (
|
|
|
47
48
|
export const openSession = Effect.fn("Engine.openSession")(function* (
|
|
48
49
|
cwd: string,
|
|
49
50
|
configPath: string | undefined,
|
|
50
|
-
): Effect.fn.Return<Session, SetupFailure,
|
|
51
|
+
): Effect.fn.Return<Session, SetupFailure, RuleServices> {
|
|
51
52
|
const config = yield* loadConfig(cwd, configPath);
|
|
52
53
|
const registryRaw = yield* readInput(config.root, config.registry);
|
|
53
54
|
const registry = yield* validOrFail(config.registry, yield* Effect.promise(() => decodeRegistry(registryRaw)));
|
|
@@ -31,8 +31,8 @@ export const ExceptionDeclaration = Schema.Struct({
|
|
|
31
31
|
|
|
32
32
|
export type ExceptionDeclaration = typeof ExceptionDeclaration.Type;
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const ExceptionDeclarations = Schema.Array(ExceptionDeclaration);
|
|
35
35
|
|
|
36
36
|
export function decodeExceptions(value: unknown): Promise<Decoded<readonly ExceptionDeclaration[]>> {
|
|
37
|
-
return decodeWith(
|
|
37
|
+
return decodeWith(ExceptionDeclarations, value);
|
|
38
38
|
}
|
|
@@ -11,12 +11,10 @@ const RegistryEntry = Schema.Struct({
|
|
|
11
11
|
|
|
12
12
|
export type RegistryEntry = typeof RegistryEntry.Type;
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
parseOptions: { errors: "all", onExcessProperty: "error" },
|
|
16
|
-
});
|
|
14
|
+
const RegistryFile = Schema.fromJsonString(Schema.Array(RegistryEntry));
|
|
17
15
|
|
|
18
16
|
export function decodeRegistry(raw: string | undefined): Promise<Decoded<readonly RegistryEntry[]>> {
|
|
19
|
-
return raw === undefined ? Promise.resolve({ _tag: "Valid", value: [] }) : decodeWith(
|
|
17
|
+
return raw === undefined ? Promise.resolve({ _tag: "Valid", value: [] }) : decodeWith(RegistryFile, raw);
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
export interface StaleRegistryEntry {
|
package/src/failure.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Data, Runtime } from "effect";
|
|
2
2
|
|
|
3
|
-
export class SetupFailure extends Data.TaggedError("SetupFailure")<{ readonly message: string }> {
|
|
3
|
+
export class SetupFailure extends Data.TaggedError("SetupFailure")<{ readonly message: string; readonly cause?: unknown }> {
|
|
4
|
+
constructor(options: { readonly message: string; readonly cause?: unknown }) {
|
|
5
|
+
super({ message: options.message });
|
|
6
|
+
Object.defineProperty(this, "cause", { enumerable: false, value: options.cause });
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
override readonly [Runtime.errorReported] = false;
|
|
5
10
|
override readonly [Runtime.errorExitCode] = 2;
|
|
6
11
|
}
|
package/src/git/command.ts
CHANGED
|
@@ -21,7 +21,7 @@ export function git(cwd: string, args: readonly string[]): Effect.Effect<GitResu
|
|
|
21
21
|
);
|
|
22
22
|
return { code: Number(code), stderr, stdout };
|
|
23
23
|
}),
|
|
24
|
-
).pipe(Effect.mapError((error) => new SetupFailure({ message: `cannot run git: ${error.message}` })));
|
|
24
|
+
).pipe(Effect.mapError((error) => new SetupFailure({ cause: error, message: `cannot run git: ${error.message}` })));
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export function gitOrFail(cwd: string, args: readonly string[]): Effect.Effect<string, SetupFailure, Git> {
|
package/src/hooks/install.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface HookInstall {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function failed(error: { readonly message: string }): SetupFailure {
|
|
22
|
-
return new SetupFailure({ message: error.message });
|
|
22
|
+
return new SetupFailure({ cause: error, message: error.message });
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const realPath = Effect.fnUntraced(function* (path: string) {
|
|
@@ -32,7 +32,7 @@ const write = Effect.fnUntraced(function* (file: string, text: string) {
|
|
|
32
32
|
yield* fs.makeDirectory(dirname(file), { recursive: true }).pipe(
|
|
33
33
|
Effect.andThen(fs.writeFileString(file, text)),
|
|
34
34
|
Effect.andThen(fs.chmod(file, 0o755)),
|
|
35
|
-
Effect.mapError((error) => new SetupFailure({ message: `cannot write ${file}: ${error.message}` })),
|
|
35
|
+
Effect.mapError((error) => new SetupFailure({ cause: error, message: `cannot write ${file}: ${error.message}` })),
|
|
36
36
|
);
|
|
37
37
|
});
|
|
38
38
|
|
package/src/hooks/preCommit.ts
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { Console, Effect
|
|
2
|
+
import { Console, Effect } from "effect";
|
|
3
3
|
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
4
|
+
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
5
|
+
import { manifestReader } from "#adapters/manifestReader.ts";
|
|
4
6
|
import { lint } from "#cli/lint.ts";
|
|
5
7
|
import { loadConfig } from "#config/load.ts";
|
|
6
|
-
import { decodeWith, validOrFail } from "#decoded.ts";
|
|
7
8
|
import { GateFailed, SetupFailure } from "#failure.ts";
|
|
8
|
-
import { readOptionalText } from "#inventory/filesystem.ts";
|
|
9
9
|
|
|
10
10
|
const COMMIT_AGAIN =
|
|
11
11
|
"help: fix what the output above reports, then commit again; `quality hooks pre-commit` repeats these checks without committing.";
|
|
12
12
|
|
|
13
|
-
const Manifest = Schema.toStandardSchemaV1(
|
|
14
|
-
Schema.fromJsonString(
|
|
15
|
-
Schema.Struct({
|
|
16
|
-
packageManager: Schema.optionalKey(Schema.String),
|
|
17
|
-
scripts: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
|
|
18
|
-
}),
|
|
19
|
-
),
|
|
20
|
-
);
|
|
21
|
-
|
|
22
13
|
const commitScripts = Effect.fnUntraced(function* (root: string) {
|
|
23
14
|
const file = join(root, "package.json");
|
|
24
|
-
const
|
|
25
|
-
|
|
15
|
+
const readText = yield* manifestReader(root);
|
|
16
|
+
const manifest = yield* Effect.tryPromise({
|
|
17
|
+
catch: (cause) => new SetupFailure({ cause, message: `${file} is invalid: ${cause instanceof Error ? cause.message : String(cause)}` }),
|
|
18
|
+
try: () => readPackageManifest(readText, file),
|
|
19
|
+
});
|
|
20
|
+
if (manifest === undefined) {
|
|
26
21
|
return { manager: "npm", scripts: [] };
|
|
27
22
|
}
|
|
28
|
-
const manifest = yield* validOrFail(file, yield* Effect.promise(() => decodeWith(Manifest, text)));
|
|
29
23
|
const manager = manifest.packageManager?.split("@")[0] ?? "npm";
|
|
30
24
|
if (!["npm", "pnpm", "yarn", "bun"].includes(manager)) {
|
|
31
25
|
return yield* new SetupFailure({ message: `${file}: unsupported packageManager "${manager}". Use npm, pnpm, yarn or bun.` });
|
|
@@ -42,7 +36,7 @@ const runScript = Effect.fnUntraced(
|
|
|
42
36
|
return Number(yield* child.exitCode);
|
|
43
37
|
},
|
|
44
38
|
Effect.scoped,
|
|
45
|
-
Effect.mapError((error) => new SetupFailure({ message: `cannot run a pre-commit script: ${error.message}` })),
|
|
39
|
+
Effect.mapError((error) => new SetupFailure({ cause: error, message: `cannot run a pre-commit script: ${error.message}` })),
|
|
46
40
|
);
|
|
47
41
|
|
|
48
42
|
export const preCommitHook = Effect.fn("Hooks.preCommitHook")(function* (cwd: string, path: string | undefined) {
|
package/src/hooks/status.ts
CHANGED
|
@@ -35,7 +35,7 @@ export const globalHookStatus = Effect.fn("Hooks.globalHookStatus")(function* (l
|
|
|
35
35
|
export const hookStatus = Effect.fn("Hooks.hookStatus")(function* (cwd: string) {
|
|
36
36
|
const location = yield* hookLocation(cwd);
|
|
37
37
|
const path = (yield* gitOrFail(cwd, ["rev-parse", "--path-format=absolute", "--git-path", "hooks/pre-commit"])).trim();
|
|
38
|
-
const text = yield* readOptionalText(path).pipe(Effect.mapError((error) => new SetupFailure({ message: error.message })));
|
|
38
|
+
const text = yield* readOptionalText(path).pipe(Effect.mapError((error) => new SetupFailure({ cause: error, message: error.message })));
|
|
39
39
|
if (text === undefined || !isHookShim(text) || (yield* executable(path)) === undefined) {
|
|
40
40
|
yield* Console.error(
|
|
41
41
|
`quality: the effective hooks path ${dirname(path)} does not run Quality's pre-commit hook.\nhelp: run \`quality hooks install\` to check commits.`,
|
package/src/hooks/uninstall.ts
CHANGED
|
@@ -10,16 +10,16 @@ import { isHookShim } from "./shim.ts";
|
|
|
10
10
|
export const uninstallHook = Effect.fn("Hooks.uninstallHook")(function* (cwd: string) {
|
|
11
11
|
const fs = yield* FileSystem.FileSystem;
|
|
12
12
|
const { file } = yield* hookLocation(cwd);
|
|
13
|
-
const existing = yield* Effect.mapError(readOptionalText(file), (failure) => new SetupFailure({ message: failure.message }));
|
|
13
|
+
const existing = yield* Effect.mapError(readOptionalText(file), (failure) => new SetupFailure({ cause: failure, message: failure.message }));
|
|
14
14
|
if (existing === undefined) {
|
|
15
15
|
return yield* Console.log(`quality: there is no pre-commit hook at ${file}.`);
|
|
16
16
|
}
|
|
17
17
|
if (!isHookShim(existing)) {
|
|
18
18
|
return yield* Console.error(`quality: kept ${file}: it is not quality's pre-commit hook.`);
|
|
19
19
|
}
|
|
20
|
-
yield* Effect.mapError(fs.remove(file), (error) => new SetupFailure({ message: `cannot remove ${file}: ${error.message}` }));
|
|
20
|
+
yield* Effect.mapError(fs.remove(file), (error) => new SetupFailure({ cause: error, message: `cannot remove ${file}: ${error.message}` }));
|
|
21
21
|
const local = yield* git(cwd, ["config", "--local", "--get", "core.hooksPath"]);
|
|
22
|
-
yield* removeForwarding(file).pipe(Effect.mapError((error) => new SetupFailure({ message: error.message })));
|
|
22
|
+
yield* removeForwarding(file).pipe(Effect.mapError((error) => new SetupFailure({ cause: error, message: error.message })));
|
|
23
23
|
if ([dirname(file), forwardingPath(file)].includes(local.stdout.trim())) {
|
|
24
24
|
yield* gitOrFail(cwd, ["config", "--local", "--unset-all", "core.hooksPath"]);
|
|
25
25
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
import { isTooling } from "./isTooling.ts";
|
|
3
|
+
import type { DeclaredRuntime, Runtime } from "./runtime.ts";
|
|
4
|
+
import { packageOf, type WorkspacePackage } from "./workspace.ts";
|
|
5
|
+
|
|
6
|
+
export interface RuntimePolicy {
|
|
7
|
+
readonly adopted: ReadonlySet<string>;
|
|
8
|
+
readonly declared: ReadonlyMap<string, DeclaredRuntime>;
|
|
9
|
+
readonly executable: ReadonlySet<string>;
|
|
10
|
+
readonly packages: readonly WorkspacePackage[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function classifyRuntime(policy: RuntimePolicy, path: string): Runtime | undefined {
|
|
14
|
+
const owner = packageOf(policy.packages, path)?.directory ?? ".";
|
|
15
|
+
if (isTooling(owner, path)) {
|
|
16
|
+
return "server";
|
|
17
|
+
}
|
|
18
|
+
const whole = policy.declared.get(owner);
|
|
19
|
+
if (whole !== undefined) {
|
|
20
|
+
return whole;
|
|
21
|
+
}
|
|
22
|
+
if (!policy.adopted.has(owner)) {
|
|
23
|
+
return policy.executable.has(owner) ? "server" : undefined;
|
|
24
|
+
}
|
|
25
|
+
const local = posix.relative(owner, path).replace(/^src\/modules\/[^/]+\//u, "src/");
|
|
26
|
+
if (local.startsWith("src/client/")) {
|
|
27
|
+
return "client";
|
|
28
|
+
}
|
|
29
|
+
return local.startsWith("src/server/") ? "server" : "shared";
|
|
30
|
+
}
|
|
@@ -31,8 +31,6 @@ const FenceInput: Schema.Codec<Fence> = Schema.Struct({
|
|
|
31
31
|
|
|
32
32
|
export const Declarations = Schema.Array(FenceInput);
|
|
33
33
|
|
|
34
|
-
const standard = Schema.toStandardSchemaV1(Declarations, { parseOptions: { errors: "all", onExcessProperty: "error" } });
|
|
35
|
-
|
|
36
34
|
export function decodeDeclarations(value: unknown) {
|
|
37
|
-
return decodeWith(
|
|
35
|
+
return decodeWith(Declarations, value);
|
|
38
36
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
|
|
1
3
|
function keyPattern(key: string): RegExp {
|
|
2
4
|
return new RegExp(`^(?:${key}|"${key}"|'${key}')\\s*:`, "u");
|
|
3
5
|
}
|
|
@@ -31,7 +33,7 @@ function scalar(raw: string, key: string): string {
|
|
|
31
33
|
const value = raw.trim();
|
|
32
34
|
if (value.startsWith('"') && value.endsWith('"') && value.length > 1) {
|
|
33
35
|
try {
|
|
34
|
-
return
|
|
36
|
+
return Schema.decodeUnknownSync(Schema.fromJsonString(Schema.String))(value);
|
|
35
37
|
} catch (error) {
|
|
36
38
|
throw failure(`cannot read "${value}" in ${key}`, error);
|
|
37
39
|
}
|
package/src/imports/runtime.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { statSync } from "node:fs";
|
|
2
2
|
import { join, posix } from "node:path";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
3
5
|
import type { RuleInputs } from "#rule.ts";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
+
import { classifyRuntime } from "./classifyRuntime.ts";
|
|
7
|
+
import type { WorkspacePackage } from "./workspace.ts";
|
|
6
8
|
|
|
7
9
|
export type Runtime = "client" | "server" | "shared";
|
|
8
10
|
|
|
@@ -12,22 +14,6 @@ function executablePath(value: unknown): boolean {
|
|
|
12
14
|
return typeof value === "string" && value.trim().length > 0;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
function readManifest(root: string, directory: string): object | undefined {
|
|
16
|
-
const path = join(root, directory, "package.json");
|
|
17
|
-
try {
|
|
18
|
-
const manifest: unknown = JSON.parse(readFileSync(path, "utf8"));
|
|
19
|
-
if (typeof manifest !== "object" || manifest === null || Array.isArray(manifest)) {
|
|
20
|
-
throw new Error("the manifest must be an object");
|
|
21
|
-
}
|
|
22
|
-
return manifest;
|
|
23
|
-
} catch (cause) {
|
|
24
|
-
if (cause instanceof Error && "code" in cause && cause.code === "ENOENT") {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
throw new Error(`cannot read runtime policy at ${path}`, { cause });
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
17
|
function hasExecutable(manifest: object | undefined): boolean {
|
|
32
18
|
const bin: unknown = manifest === undefined ? undefined : Reflect.get(manifest, "bin");
|
|
33
19
|
return executablePath(bin) || (typeof bin === "object" && bin !== null && !Array.isArray(bin) && Object.values(bin).some(executablePath));
|
|
@@ -65,35 +51,53 @@ export interface RuntimeDeclarationProblem {
|
|
|
65
51
|
readonly message: string;
|
|
66
52
|
}
|
|
67
53
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
54
|
+
function problemsFor(root: string, owner: Owner, manifest: object | undefined): readonly RuntimeDeclarationProblem[] {
|
|
55
|
+
const value = declaredValue(manifest);
|
|
56
|
+
if (value === undefined) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
if (value !== "client" && value !== "server") {
|
|
60
|
+
return [
|
|
61
|
+
{
|
|
62
|
+
directory: owner.directory,
|
|
63
|
+
message: `"quality.runtime" is ${JSON.stringify(value)}. Declare "client" or "server" for a package whose code runs in one runtime, or remove the field and use src/client/ and src/server/.`,
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
const folders = runtimeFoldersOf(root, owner);
|
|
68
|
+
return folders.length === 0
|
|
69
|
+
? []
|
|
70
|
+
: [
|
|
76
71
|
{
|
|
77
72
|
directory: owner.directory,
|
|
78
|
-
message: `"quality.runtime"
|
|
73
|
+
message: `"quality.runtime" declares the whole package ${value} code, but it also has ${folders.map((folder) => `src/${folder}/`).join(" and ")}. Keep one convention: remove the declaration and classify code by runtime folders, or move the code out of the runtime folders.`,
|
|
79
74
|
},
|
|
80
75
|
];
|
|
81
|
-
}
|
|
82
|
-
const folders = runtimeFoldersOf(inputs.root, owner);
|
|
83
|
-
return folders.length === 0
|
|
84
|
-
? []
|
|
85
|
-
: [
|
|
86
|
-
{
|
|
87
|
-
directory: owner.directory,
|
|
88
|
-
message: `"quality.runtime" declares the whole package ${value} code, but it also has ${folders.map((folder) => `src/${folder}/`).join(" and ")}. Keep one convention: remove the declaration and classify code by runtime folders, or move the code out of the runtime folders.`,
|
|
89
|
-
},
|
|
90
|
-
];
|
|
91
|
-
});
|
|
92
76
|
}
|
|
93
77
|
|
|
94
|
-
export
|
|
78
|
+
export const runtimeDeclarationProblems = Effect.fn("Imports.runtimeDeclarationProblems")(function* (
|
|
79
|
+
inputs: RuleInputs,
|
|
80
|
+
packages: readonly WorkspacePackage[],
|
|
81
|
+
) {
|
|
82
|
+
const problems = yield* Effect.forEach([...packages, { directory: ".", name: "." }], (owner) =>
|
|
83
|
+
Effect.map(
|
|
84
|
+
Effect.promise(() => readPackageManifest(inputs.readText, posix.join(owner.directory, "package.json"))),
|
|
85
|
+
(manifest) => problemsFor(inputs.root, owner, manifest),
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
return problems.flat();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export const runtimeOf = Effect.fn("Imports.runtimeOf")(function* (inputs: RuleInputs, packages: readonly WorkspacePackage[]) {
|
|
95
92
|
const owners = [...packages, { directory: ".", name: "." }];
|
|
96
|
-
const manifests = new Map(
|
|
93
|
+
const manifests = new Map(
|
|
94
|
+
yield* Effect.forEach(owners, (owner) =>
|
|
95
|
+
Effect.map(
|
|
96
|
+
Effect.promise(() => readPackageManifest(inputs.readText, posix.join(owner.directory, "package.json"))),
|
|
97
|
+
(manifest) => [owner.directory, manifest] as const,
|
|
98
|
+
),
|
|
99
|
+
),
|
|
100
|
+
);
|
|
97
101
|
const adopted = new Set(owners.filter((owner) => runtimeFoldersOf(inputs.root, owner).length > 0).map((owner) => owner.directory));
|
|
98
102
|
const declared = new Map(
|
|
99
103
|
owners.flatMap((owner) => {
|
|
@@ -102,22 +106,6 @@ export function runtimeOf(inputs: RuleInputs, packages: readonly WorkspacePackag
|
|
|
102
106
|
}),
|
|
103
107
|
);
|
|
104
108
|
const executable = new Set(owners.filter((owner) => hasExecutable(manifests.get(owner.directory))).map((owner) => owner.directory));
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return "server";
|
|
109
|
-
}
|
|
110
|
-
const whole = declared.get(owner);
|
|
111
|
-
if (whole !== undefined) {
|
|
112
|
-
return whole;
|
|
113
|
-
}
|
|
114
|
-
if (!adopted.has(owner)) {
|
|
115
|
-
return executable.has(owner) ? "server" : undefined;
|
|
116
|
-
}
|
|
117
|
-
const local = posix.relative(owner, path).replace(/^src\/modules\/[^/]+\//u, "src/");
|
|
118
|
-
if (local.startsWith("src/client/")) {
|
|
119
|
-
return "client";
|
|
120
|
-
}
|
|
121
|
-
return local.startsWith("src/server/") ? "server" : "shared";
|
|
122
|
-
};
|
|
123
|
-
}
|
|
109
|
+
const policy = { adopted, declared, executable, packages };
|
|
110
|
+
return (path: string) => classifyRuntime(policy, path);
|
|
111
|
+
});
|
package/src/imports/workspace.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
-
import
|
|
3
|
-
import { Effect } from "effect";
|
|
4
|
-
import { manifestsIn } from "#manifests/sorted.ts";
|
|
2
|
+
import { manifestFiles, readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
5
3
|
import type { RuleInputs } from "#rule.ts";
|
|
6
4
|
import { globMatcher } from "./globMatcher.ts";
|
|
7
5
|
import { pnpmWorkspacePatterns } from "./pnpmWorkspacePatterns.ts";
|
|
@@ -23,17 +21,6 @@ const LEADING_DOT = /^\.\//u;
|
|
|
23
21
|
|
|
24
22
|
const TRAILING_SLASHES = /\/+$/u;
|
|
25
23
|
|
|
26
|
-
function parsed(text: string | undefined): unknown {
|
|
27
|
-
if (text === undefined) {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
try {
|
|
31
|
-
return JSON.parse(text);
|
|
32
|
-
} catch {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
24
|
function field(value: unknown, key: string): unknown {
|
|
38
25
|
return typeof value === "object" && value !== null && key in value ? Reflect.get(value, key) : undefined;
|
|
39
26
|
}
|
|
@@ -42,8 +29,8 @@ function strings(value: unknown): readonly string[] {
|
|
|
42
29
|
return Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === "string") : [];
|
|
43
30
|
}
|
|
44
31
|
|
|
45
|
-
function npmPatterns(
|
|
46
|
-
const workspaces = field(
|
|
32
|
+
function npmPatterns(manifest: unknown): readonly string[] {
|
|
33
|
+
const workspaces = field(manifest, "workspaces");
|
|
47
34
|
return Array.isArray(workspaces) ? strings(workspaces) : strings(field(workspaces, "packages"));
|
|
48
35
|
}
|
|
49
36
|
|
|
@@ -53,7 +40,7 @@ function normalized(pattern: string): string {
|
|
|
53
40
|
|
|
54
41
|
async function memberOf(inputs: Reader): Promise<(directory: string) => boolean> {
|
|
55
42
|
const pnpm = await inputs.readText(PNPM_WORKSPACE);
|
|
56
|
-
const patterns = [...(pnpm === undefined ? [] : pnpmWorkspacePatterns(pnpm)), ...npmPatterns(await inputs.readText
|
|
43
|
+
const patterns = [...(pnpm === undefined ? [] : pnpmWorkspacePatterns(pnpm)), ...npmPatterns(await readPackageManifest(inputs.readText, MANIFEST))];
|
|
57
44
|
const included = patterns.filter((pattern) => !pattern.startsWith(NEGATION)).map((pattern) => globMatcher(normalized(pattern)));
|
|
58
45
|
const excluded = patterns
|
|
59
46
|
.filter((pattern) => pattern.startsWith(NEGATION))
|
|
@@ -63,14 +50,16 @@ async function memberOf(inputs: Reader): Promise<(directory: string) => boolean>
|
|
|
63
50
|
|
|
64
51
|
export async function workspacePackages(inputs: Reader): Promise<readonly WorkspacePackage[]> {
|
|
65
52
|
const member = await memberOf(inputs);
|
|
66
|
-
const manifests =
|
|
67
|
-
inputs.root === undefined ? inputs.files : await Effect.runPromise(manifestsIn(inputs.root).pipe(Effect.provide(NodeFileSystem.layer)));
|
|
53
|
+
const manifests = manifestFiles(inputs);
|
|
68
54
|
const directories = manifests
|
|
69
55
|
.filter((file) => posix.basename(file) === MANIFEST && file !== MANIFEST)
|
|
70
56
|
.map((manifest) => posix.dirname(manifest))
|
|
71
57
|
.filter(member);
|
|
72
58
|
const named = await Promise.all(
|
|
73
|
-
directories.map(async (directory) => ({
|
|
59
|
+
directories.map(async (directory) => ({
|
|
60
|
+
directory,
|
|
61
|
+
name: field(await readPackageManifest(inputs.readText, posix.join(directory, MANIFEST)), "name"),
|
|
62
|
+
})),
|
|
74
63
|
);
|
|
75
64
|
return named.flatMap(({ directory, name }) => (typeof name === "string" ? [{ directory, name }] : []));
|
|
76
65
|
}
|
package/src/inventory/collect.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { join, relative } from "node:path";
|
|
2
2
|
import { Effect, FileSystem } from "effect";
|
|
3
3
|
import ignore from "ignore";
|
|
4
|
+
import { manifestsIn } from "#manifests/sorted.ts";
|
|
4
5
|
import type { SourceFile } from "#rule.ts";
|
|
5
6
|
import { FilesystemFailure, orWhenAbsent, readRequiredText } from "./filesystem.ts";
|
|
6
7
|
import { posix } from "./ignoreScope.ts";
|
|
@@ -16,6 +17,7 @@ export interface InventoryScope {
|
|
|
16
17
|
|
|
17
18
|
export interface Inventory {
|
|
18
19
|
readonly files: readonly string[];
|
|
20
|
+
readonly manifestFiles: readonly string[];
|
|
19
21
|
readonly sources: readonly SourceFile[];
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -60,5 +62,5 @@ export const collectInventory = Effect.fn("Inventory.collectInventory")(function
|
|
|
60
62
|
});
|
|
61
63
|
const sourcePaths = files.filter((path) => scope.extensions.some((extension) => path.endsWith(extension)));
|
|
62
64
|
const sources = yield* Effect.forEach(sourcePaths, (path) => readSource(root, path), { concurrency: READ_CONCURRENCY });
|
|
63
|
-
return { files, sources };
|
|
65
|
+
return { files, manifestFiles: yield* manifestsIn(root), sources };
|
|
64
66
|
});
|
|
@@ -2,19 +2,11 @@ import { dirname } from "node:path";
|
|
|
2
2
|
import { Data, Effect, FileSystem } from "effect";
|
|
3
3
|
import type { PlatformError } from "effect/PlatformError";
|
|
4
4
|
|
|
5
|
-
const ABSENT = new Set(["ENOENT", "ENOTDIR"]);
|
|
6
|
-
|
|
7
5
|
export class FilesystemFailure extends Data.TaggedError("FilesystemFailure")<{
|
|
8
6
|
readonly message: string;
|
|
9
7
|
readonly path: string;
|
|
10
8
|
}> {}
|
|
11
9
|
|
|
12
|
-
// Effect maps ENOTDIR and EISDIR to BadResource; the original errno remains on the cause.
|
|
13
|
-
function errnoOf(error: PlatformError): string {
|
|
14
|
-
const cause: unknown = error.reason.cause;
|
|
15
|
-
return typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
10
|
function failure(path: string, error: PlatformError): FilesystemFailure {
|
|
19
11
|
return new FilesystemFailure({ message: `cannot read ${path}: ${error.message}`, path });
|
|
20
12
|
}
|
|
@@ -25,7 +17,7 @@ export function orWhenAbsent<TValue>(
|
|
|
25
17
|
whenAbsent: TValue,
|
|
26
18
|
): Effect.Effect<TValue, FilesystemFailure, FileSystem.FileSystem> {
|
|
27
19
|
return Effect.catchTag(action, "PlatformError", (error) =>
|
|
28
|
-
|
|
20
|
+
error.reason._tag === "NotFound" ? Effect.succeed(whenAbsent) : Effect.fail(failure(path, error)),
|
|
29
21
|
);
|
|
30
22
|
}
|
|
31
23
|
|
|
@@ -41,7 +33,7 @@ export const readRequiredText = Effect.fn("Inventory.readRequiredText")(function
|
|
|
41
33
|
): Effect.fn.Return<string, FilesystemFailure, FileSystem.FileSystem> {
|
|
42
34
|
const fs = yield* FileSystem.FileSystem;
|
|
43
35
|
return yield* Effect.mapError(fs.readFileString(path), (error) =>
|
|
44
|
-
|
|
36
|
+
error.reason._tag === "NotFound" ? new FilesystemFailure({ message: `required input is missing: ${path}`, path }) : failure(path, error),
|
|
45
37
|
);
|
|
46
38
|
});
|
|
47
39
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
+
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
2
3
|
import type { RuleInputs } from "#rule.ts";
|
|
3
4
|
|
|
4
5
|
export const SHIPPED_FIELDS = ["dependencies", "peerDependencies", "optionalDependencies"] as const;
|
|
@@ -24,17 +25,6 @@ export function dependencyNames(manifest: unknown, field: string): readonly stri
|
|
|
24
25
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? Object.keys(value) : [];
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
function parsed(text: string | undefined): unknown {
|
|
28
|
-
if (text === undefined) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
return JSON.parse(text);
|
|
33
|
-
} catch {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
28
|
async function installedManifest(inputs: Pick<RuleInputs, "readText">, directory: string, name: string, workspace: ReadonlyMap<string, string>) {
|
|
39
29
|
const candidates = [
|
|
40
30
|
...(workspace.has(name) ? [posix.join(workspace.get(name) ?? ".", "package.json")] : []),
|
|
@@ -42,7 +32,7 @@ async function installedManifest(inputs: Pick<RuleInputs, "readText">, directory
|
|
|
42
32
|
posix.join("node_modules", name, "package.json"),
|
|
43
33
|
];
|
|
44
34
|
for (const candidate of candidates) {
|
|
45
|
-
const manifest =
|
|
35
|
+
const manifest = await readPackageManifest(inputs.readText, candidate);
|
|
46
36
|
if (manifest !== undefined) {
|
|
47
37
|
return manifest;
|
|
48
38
|
}
|