@shivaedev/quality 0.44.1 → 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 +66 -0
- package/README.md +23 -12
- package/biome/preset.json +11 -2
- 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 +13 -3
- 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 +2 -1
- package/dist/appTestConfig.d.ts.map +1 -1
- package/dist/appTestConfig.js +3 -3
- package/dist/appTestConfig.js.map +1 -1
- package/dist/appViteConfig.d.ts +1 -1
- package/dist/appViteConfig.d.ts.map +1 -1
- package/dist/appViteConfig.js +2 -2
- package/dist/appViteConfig.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 +20 -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 +18 -24
- 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/args.d.ts +2 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +4 -3
- package/dist/cli/args.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/ci.d.ts +1 -1
- package/dist/cli/ci.d.ts.map +1 -1
- package/dist/cli/ci.js +13 -2
- package/dist/cli/ci.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/messages.d.ts +1 -1
- package/dist/cli/messages.d.ts.map +1 -1
- package/dist/cli/messages.js +2 -1
- package/dist/cli/messages.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/cli/program.js +1 -1
- package/dist/cli/program.js.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 +8 -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/authSql.js +22 -3
- package/dist/rules/stories/authSql.js.map +1 -1
- package/dist/rules/stories/domainOutcomes.d.ts +2 -0
- package/dist/rules/stories/domainOutcomes.d.ts.map +1 -0
- package/dist/rules/stories/domainOutcomes.js +34 -0
- package/dist/rules/stories/domainOutcomes.js.map +1 -0
- 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 +2 -0
- package/dist/rules/stories/groupedOutcomes.d.ts.map +1 -0
- package/dist/rules/stories/groupedOutcomes.js +55 -0
- package/dist/rules/stories/groupedOutcomes.js.map +1 -0
- package/dist/rules/stories/httpStatus.d.ts +1 -1
- package/dist/rules/stories/httpStatus.d.ts.map +1 -1
- package/dist/rules/stories/importBindings.d.ts +8 -0
- package/dist/rules/stories/importBindings.d.ts.map +1 -0
- package/dist/rules/stories/importBindings.js +29 -0
- package/dist/rules/stories/importBindings.js.map +1 -0
- 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/sources.js +17 -0
- 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 +2 -0
- package/dist/rules/stories/waitOnEvents.d.ts.map +1 -0
- package/dist/rules/stories/waitOnEvents.js +52 -0
- package/dist/rules/stories/waitOnEvents.js.map +1 -0
- 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 +10 -15
- 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 +17 -3
- 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 +3 -3
- package/src/appViteConfig.ts +2 -2
- 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 +22 -29
- 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 +29 -28
- package/src/biome/withoutEntryPointImports.ts +2 -12
- package/src/cli/args.ts +5 -4
- package/src/cli/baseline.ts +3 -2
- package/src/cli/ci.ts +14 -2
- package/src/cli/fix.ts +15 -17
- package/src/cli/lint.ts +3 -2
- package/src/cli/messages.ts +2 -1
- package/src/cli/migrateBaseline.ts +4 -3
- package/src/cli/migrateExceptions.ts +6 -4
- package/src/cli/program.ts +1 -1
- 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 +8 -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/authSql.ts +25 -3
- package/src/rules/stories/domainOutcomes.ts +44 -0
- package/src/rules/stories/groupedOutcomes.ts +66 -0
- package/src/rules/stories/importBindings.ts +37 -0
- package/src/rules/stories/prerequisites.ts +4 -8
- package/src/rules/stories/sources.ts +20 -0
- package/src/rules/stories/waitOnEvents.ts +61 -0
- 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/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/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
|
}
|
package/src/manifests/sorted.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { basename, join, relative } from "node:path";
|
|
2
2
|
import { Effect, FileSystem } from "effect";
|
|
3
3
|
import { sortPackageJson } from "sort-package-json";
|
|
4
|
+
import { ManifestFailure, manifestEntry } from "#adapters/manifestInventory.ts";
|
|
5
|
+
import { manifestReader } from "#adapters/manifestReader.ts";
|
|
4
6
|
import { FilesystemFailure } from "#inventory/filesystem.ts";
|
|
5
7
|
import { posix } from "#inventory/ignoreScope.ts";
|
|
6
8
|
import { walk } from "#inventory/walk.ts";
|
|
7
9
|
|
|
8
|
-
export type Sorting = { readonly _tag: "
|
|
10
|
+
export type Sorting = { readonly _tag: "Sorted" } | { readonly _tag: "Unsorted"; readonly sorted: string };
|
|
9
11
|
|
|
10
12
|
export function manifestsIn(root: string): Effect.Effect<readonly string[], FilesystemFailure, FileSystem.FileSystem> {
|
|
11
13
|
return Effect.map(walk(root), (paths) =>
|
|
@@ -17,30 +19,40 @@ export function manifestsIn(root: string): Effect.Effect<readonly string[], File
|
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export function sortingOf(text: string): Sorting {
|
|
20
|
-
try {
|
|
21
|
-
JSON.parse(text);
|
|
22
|
-
} catch {
|
|
23
|
-
return { _tag: "Invalid" };
|
|
24
|
-
}
|
|
25
22
|
const sorted = sortPackageJson(text);
|
|
26
23
|
return sorted === text ? { _tag: "Sorted" } : { _tag: "Unsorted", sorted };
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
export const sortManifests = Effect.fn("Manifests.sortManifests")(function* (
|
|
30
27
|
root: string,
|
|
31
|
-
): Effect.fn.Return<number, FilesystemFailure, FileSystem.FileSystem> {
|
|
28
|
+
): Effect.fn.Return<number, FilesystemFailure | ManifestFailure, FileSystem.FileSystem> {
|
|
32
29
|
const fs = yield* FileSystem.FileSystem;
|
|
33
30
|
const manifests = yield* manifestsIn(root);
|
|
31
|
+
const readText = yield* manifestReader(root);
|
|
34
32
|
const written = yield* Effect.forEach(manifests, (path) =>
|
|
35
33
|
Effect.gen(function* () {
|
|
36
34
|
const absolute = join(root, path);
|
|
37
|
-
const
|
|
35
|
+
const entry = yield* Effect.tryPromise({
|
|
36
|
+
catch: (cause) =>
|
|
37
|
+
cause instanceof ManifestFailure ? cause : new FilesystemFailure({ message: cause instanceof Error ? cause.message : String(cause), path }),
|
|
38
|
+
try: () => manifestEntry(readText, path),
|
|
39
|
+
});
|
|
40
|
+
if (entry === undefined) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const sorting = sortingOf(entry.text);
|
|
38
44
|
if (sorting._tag !== "Unsorted") {
|
|
39
45
|
return false;
|
|
40
46
|
}
|
|
41
47
|
yield* fs.writeFileString(absolute, sorting.sorted);
|
|
42
48
|
return true;
|
|
43
|
-
}).pipe(
|
|
49
|
+
}).pipe(
|
|
50
|
+
Effect.mapError((error) =>
|
|
51
|
+
error instanceof ManifestFailure
|
|
52
|
+
? new ManifestFailure({ message: `cannot sort ${path}: ${error.message}`, path })
|
|
53
|
+
: new FilesystemFailure({ message: `cannot sort ${path}: ${error.message}`, path }),
|
|
54
|
+
),
|
|
55
|
+
),
|
|
44
56
|
);
|
|
45
57
|
return written.filter(Boolean).length;
|
|
46
58
|
});
|
|
@@ -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 interface PackageLayout {
|
|
@@ -15,17 +16,6 @@ const RUNNABLE = /\.[cm]?[jt]sx?$/u;
|
|
|
15
16
|
|
|
16
17
|
const BUILT = /^dist\/(?<entry>.+)\.[cm]?js$/u;
|
|
17
18
|
|
|
18
|
-
function parsed(text: string | undefined): unknown {
|
|
19
|
-
if (text === undefined) {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
return JSON.parse(text);
|
|
24
|
-
} catch {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
19
|
function field(value: unknown, key: string): unknown {
|
|
30
20
|
return typeof value === "object" && value !== null && key in value ? Reflect.get(value, key) : undefined;
|
|
31
21
|
}
|
|
@@ -57,7 +47,7 @@ export async function packageLayout({ files, readText }: Pick<RuleInputs, "files
|
|
|
57
47
|
const manifests = await Promise.all(
|
|
58
48
|
[...new Set(directories)].map(async (directory) => ({
|
|
59
49
|
directory: directory === "." ? "" : directory,
|
|
60
|
-
manifest:
|
|
50
|
+
manifest: await readPackageManifest(readText, directory === "" ? MANIFEST : `${directory}/${MANIFEST}`),
|
|
61
51
|
})),
|
|
62
52
|
);
|
|
63
53
|
const present = manifests.filter((entry) => entry.manifest !== undefined);
|
package/src/rule.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Effect, type FileSystem } from "effect";
|
|
2
|
+
import type { ChildProcessSpawner } from "effect/process";
|
|
1
3
|
import type { Bivariant } from "@shivaedev/types/Bivariant.ts";
|
|
2
4
|
import type { ExceptionDeclaration } from "#exceptions/declaration.ts";
|
|
3
5
|
import { describeIssue, type StandardSchemaV1 } from "./standardSchema.ts";
|
|
@@ -25,6 +27,7 @@ export interface RuleInputs {
|
|
|
25
27
|
readonly files: readonly string[];
|
|
26
28
|
readonly readText: (path: string) => Promise<string | undefined>;
|
|
27
29
|
readonly root: string;
|
|
30
|
+
readonly signal?: AbortSignal;
|
|
28
31
|
readonly sources: readonly SourceFile[];
|
|
29
32
|
}
|
|
30
33
|
|
|
@@ -32,31 +35,35 @@ export interface RuleContext<TOptions> extends RuleInputs {
|
|
|
32
35
|
readonly options: TOptions;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
|
-
export type
|
|
38
|
+
export type RuleServices = FileSystem.FileSystem | ChildProcessSpawner.ChildProcessSpawner;
|
|
39
|
+
|
|
40
|
+
export type RuleCheck<TServices = RuleServices> = (inputs: RuleInputs) => Effect.Effect<Findings, unknown, TServices>;
|
|
41
|
+
|
|
42
|
+
export type Configured<TServices = RuleServices> =
|
|
36
43
|
| { readonly _tag: "Invalid"; readonly issues: readonly string[] }
|
|
37
|
-
| { readonly _tag: "Ready"; readonly check:
|
|
44
|
+
| { readonly _tag: "Ready"; readonly check: RuleCheck<TServices> };
|
|
38
45
|
|
|
39
|
-
export interface Rule<TId extends string = string, TInput = unknown> {
|
|
46
|
+
export interface Rule<TId extends string = string, TInput = unknown, TServices = RuleServices> {
|
|
40
47
|
// Bivariance keeps rules with different options in one list; configure validates its input at runtime.
|
|
41
|
-
configure: Bivariant<(options: TInput | undefined) => Promise<Configured
|
|
48
|
+
configure: Bivariant<(options: TInput | undefined) => Promise<Configured<TServices>>>;
|
|
42
49
|
readonly description: string;
|
|
43
50
|
readonly family?: boolean;
|
|
44
51
|
readonly id: TId;
|
|
45
52
|
readonly registrable?: boolean;
|
|
46
53
|
}
|
|
47
54
|
|
|
48
|
-
interface RuleDefinition<TId extends string, TOptions> {
|
|
49
|
-
readonly check: (context: RuleContext<TOptions>) => Findings | PromiseLike<Findings>;
|
|
55
|
+
interface RuleDefinition<TId extends string, TOptions, TServices> {
|
|
56
|
+
readonly check: (context: RuleContext<TOptions>) => Findings | PromiseLike<Findings> | Effect.Effect<Findings, unknown, TServices>;
|
|
50
57
|
readonly description: string;
|
|
51
58
|
readonly id: TId;
|
|
52
59
|
readonly registrable?: false;
|
|
53
60
|
}
|
|
54
61
|
|
|
55
|
-
interface RuleDefinitionWithOptions<TId extends string, TInput, TOptions> extends RuleDefinition<TId, TOptions> {
|
|
62
|
+
interface RuleDefinitionWithOptions<TId extends string, TInput, TOptions, TServices> extends RuleDefinition<TId, TOptions, TServices> {
|
|
56
63
|
readonly options: StandardSchemaV1<TInput, TOptions>;
|
|
57
64
|
}
|
|
58
65
|
|
|
59
|
-
interface RuleDefinitionWithoutOptions<TId extends string> extends RuleDefinition<TId, undefined> {
|
|
66
|
+
interface RuleDefinitionWithoutOptions<TId extends string, TServices> extends RuleDefinition<TId, undefined, TServices> {
|
|
60
67
|
readonly options?: undefined;
|
|
61
68
|
}
|
|
62
69
|
|
|
@@ -68,28 +75,40 @@ const noOptions: StandardSchemaV1<undefined, undefined> = {
|
|
|
68
75
|
},
|
|
69
76
|
};
|
|
70
77
|
|
|
71
|
-
function configureWith<TInput, TOptions>(
|
|
78
|
+
function configureWith<TInput, TOptions, TServices>(
|
|
72
79
|
schema: StandardSchemaV1<TInput, TOptions>,
|
|
73
|
-
check: RuleDefinition<string, TOptions>["check"],
|
|
80
|
+
check: RuleDefinition<string, TOptions, TServices>["check"],
|
|
74
81
|
absent: unknown,
|
|
75
82
|
) {
|
|
76
|
-
return async (options: unknown): Promise<Configured
|
|
83
|
+
return async (options: unknown): Promise<Configured<TServices>> => {
|
|
77
84
|
const result = await schema["~standard"].validate(options ?? absent);
|
|
78
85
|
if (result.issues !== undefined) {
|
|
79
86
|
return { _tag: "Invalid", issues: result.issues.map(describeIssue) };
|
|
80
87
|
}
|
|
81
88
|
const value = result.value;
|
|
82
|
-
return {
|
|
89
|
+
return {
|
|
90
|
+
_tag: "Ready",
|
|
91
|
+
check: (inputs) =>
|
|
92
|
+
Effect.scoped(
|
|
93
|
+
Effect.gen(function* () {
|
|
94
|
+
const signal = yield* Effect.abortSignal;
|
|
95
|
+
const checked = check({ ...inputs, options: value, signal });
|
|
96
|
+
return yield* Effect.isEffect(checked) ? checked : Effect.promise(() => Promise.resolve(checked));
|
|
97
|
+
}),
|
|
98
|
+
),
|
|
99
|
+
};
|
|
83
100
|
};
|
|
84
101
|
}
|
|
85
102
|
|
|
86
|
-
export function defineRule<const TId extends string, TInput, TOptions>(
|
|
87
|
-
definition: RuleDefinitionWithOptions<TId, TInput, TOptions>,
|
|
88
|
-
): Rule<TId, TInput>;
|
|
89
|
-
export function defineRule<const TId extends string
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
103
|
+
export function defineRule<const TId extends string, TInput, TOptions, TServices = never>(
|
|
104
|
+
definition: RuleDefinitionWithOptions<TId, TInput, TOptions, TServices>,
|
|
105
|
+
): Rule<TId, TInput, TServices>;
|
|
106
|
+
export function defineRule<const TId extends string, TServices = never>(
|
|
107
|
+
definition: RuleDefinitionWithoutOptions<TId, TServices>,
|
|
108
|
+
): Rule<TId, undefined, TServices>;
|
|
109
|
+
export function defineRule<const TId extends string, TInput, TOptions, TServices = never>(
|
|
110
|
+
definition: RuleDefinitionWithOptions<TId, TInput, TOptions, TServices> | RuleDefinitionWithoutOptions<TId, TServices>,
|
|
111
|
+
): Rule<TId, TInput, TServices> | Rule<TId, undefined, TServices> {
|
|
93
112
|
const configure =
|
|
94
113
|
definition.options === undefined
|
|
95
114
|
? configureWith(noOptions, definition.check, undefined)
|
package/src/rules/biome.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
1
2
|
import { biomeReport, type Diagnostic, FAILING } from "#biome/report.ts";
|
|
2
3
|
import { withoutEntryPointImports } from "#biome/withoutEntryPointImports.ts";
|
|
3
4
|
import { defineRule, type Finding, type Rule, type RuleInputs } from "#rule.ts";
|
|
@@ -42,11 +43,14 @@ async function presetFinding(readText: RuleInputs["readText"]): Promise<readonly
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
const bridge = defineRule({
|
|
45
|
-
check:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
check: ({ exceptions, readText, root }) =>
|
|
47
|
+
Effect.gen(function* () {
|
|
48
|
+
const [preset, report] = yield* Effect.all([Effect.promise(() => presetFinding(readText)), biomeReport(root, ["check"], exceptions)], {
|
|
49
|
+
concurrency: "unbounded",
|
|
50
|
+
});
|
|
51
|
+
const failing = report.diagnostics.filter((diagnostic) => FAILING.has(diagnostic.severity));
|
|
52
|
+
return [...preset, ...(yield* Effect.promise(() => withoutEntryPointImports(readText, failing))).map(findingOf)];
|
|
53
|
+
}),
|
|
50
54
|
description:
|
|
51
55
|
"Biome's lint, format and assist findings under the shared preset, except undeclared-dependency findings for a piece that an application's entry point brings. `quality fix` applies Biome's lint fixes, unsafe ones included, its assist actions and formatting.",
|
|
52
56
|
id: "biome",
|
package/src/rules/builtIn.ts
CHANGED
|
@@ -22,7 +22,9 @@ import { importsResolvable } from "#rules/imports/resolvable.ts";
|
|
|
22
22
|
import { importsRuntime } from "#rules/imports/runtime.ts";
|
|
23
23
|
import { jsxConditionals } from "#rules/react/jsxConditionals.ts";
|
|
24
24
|
import { authSql } from "#rules/stories/authSql.ts";
|
|
25
|
+
import { domainOutcomes } from "#rules/stories/domainOutcomes.ts";
|
|
25
26
|
import { storyEngine } from "#rules/stories/engine.ts";
|
|
27
|
+
import { groupedOutcomes } from "#rules/stories/groupedOutcomes.ts";
|
|
26
28
|
import { httpStatus } from "#rules/stories/httpStatus.ts";
|
|
27
29
|
import { namedValues } from "#rules/stories/namedValues.ts";
|
|
28
30
|
import { noExpect } from "#rules/stories/noExpect.ts";
|
|
@@ -31,6 +33,7 @@ import { queueSql } from "#rules/stories/queueSql.ts";
|
|
|
31
33
|
import { storySetup } from "#rules/stories/setup.ts";
|
|
32
34
|
import { specHelpers } from "#rules/stories/specHelpers.ts";
|
|
33
35
|
import { storySpecs } from "#rules/stories/specs.ts";
|
|
36
|
+
import { waitOnEvents } from "#rules/stories/waitOnEvents.ts";
|
|
34
37
|
import { biomeOverrides } from "#rules/suppressions/biomeOverrides.ts";
|
|
35
38
|
import { biomeRecommended } from "#rules/suppressions/biomeRecommended.ts";
|
|
36
39
|
import { noDoubleCast } from "#rules/suppressions/noDoubleCast.ts";
|
|
@@ -43,6 +46,7 @@ import { manifestsApplication } from "./manifestsApplication.ts";
|
|
|
43
46
|
import { manifestsExportsShape } from "./manifestsExportsShape.ts";
|
|
44
47
|
import { manifestsSorted } from "./manifestsSorted.ts";
|
|
45
48
|
import { manifestsSourceFirst } from "./manifestsSourceFirst.ts";
|
|
49
|
+
import { manifestsValid } from "./manifestsValid.ts";
|
|
46
50
|
import { maxDepth } from "./maxDepth.ts";
|
|
47
51
|
import { maxLines } from "./maxLines.ts";
|
|
48
52
|
import { noBarrel } from "./noBarrel.ts";
|
|
@@ -78,6 +82,7 @@ export const builtInRules = [
|
|
|
78
82
|
importsManifest,
|
|
79
83
|
importsAliased,
|
|
80
84
|
noTestCode,
|
|
85
|
+
manifestsValid,
|
|
81
86
|
manifestsSorted,
|
|
82
87
|
manifestsSourceFirst,
|
|
83
88
|
manifestsExportsShape,
|
|
@@ -98,4 +103,7 @@ export const builtInRules = [
|
|
|
98
103
|
httpStatus,
|
|
99
104
|
namedValues,
|
|
100
105
|
noLimitImports,
|
|
106
|
+
domainOutcomes,
|
|
107
|
+
groupedOutcomes,
|
|
108
|
+
waitOnEvents,
|
|
101
109
|
] as const;
|
|
@@ -2,7 +2,7 @@ import { definePatternRule } from "./definePattern.ts";
|
|
|
2
2
|
|
|
3
3
|
export const noEnvironmentPragma = definePatternRule({
|
|
4
4
|
description:
|
|
5
|
-
"A test file gets its environment from its name, not from a pragma: `*.dom.test.ts` runs in a DOM, every other test in Node. `@shivaedev/quality/testProjects.ts` sets up the Vitest projects that read the name.",
|
|
5
|
+
"A test file gets its environment from its name, not from a pragma: `*.dom.test.ts` runs in a DOM, every other test in Node. `@shivaedev/quality/adapters/testProjects.ts` sets up the Vitest projects that read the name.",
|
|
6
6
|
id: "comments/no-environment-pragma",
|
|
7
7
|
message: (match) => `Sets the test environment with "${match}". Name the file *.dom.test.ts or *.dom.test.tsx instead.`,
|
|
8
8
|
patterns: [/^@(?:vitest|jest)-environment(?:-options)?(?=\s|$)/mu],
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { join, posix } from "node:path";
|
|
2
|
-
import { Effect
|
|
2
|
+
import { Effect } from "effect";
|
|
3
3
|
import ts from "typescript";
|
|
4
|
+
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
4
5
|
import { headingAnchors } from "#docs/headingAnchors.ts";
|
|
5
6
|
import { importFindings } from "#docs/importFindings.ts";
|
|
6
7
|
import { isDocument } from "#docs/isDocument.ts";
|
|
@@ -10,8 +11,6 @@ import { repositoryOf } from "#docs/repositoryLink.ts";
|
|
|
10
11
|
import { type WorkspacePackage, workspacePackages } from "#imports/workspace.ts";
|
|
11
12
|
import { defineRule, type Finding, type RuleInputs } from "#rule.ts";
|
|
12
13
|
|
|
13
|
-
const decodeJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown));
|
|
14
|
-
|
|
15
14
|
function field(value: unknown, key: string): unknown {
|
|
16
15
|
return typeof value === "object" && value !== null && key in value ? Reflect.get(value, key) : undefined;
|
|
17
16
|
}
|
|
@@ -26,10 +25,6 @@ function reader(inputs: RuleInputs): (path: string) => Effect.Effect<string | un
|
|
|
26
25
|
return (path) => Effect.promise(() => inputs.readText(path));
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
function jsonAt(read: ReturnType<typeof reader>, path: string): Effect.Effect<unknown> {
|
|
30
|
-
return Effect.map(read(path), (text) => (text === undefined ? undefined : Option.getOrUndefined(decodeJson(text))));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
28
|
function anchorsReader(read: ReturnType<typeof reader>): (path: string) => Effect.Effect<ReadonlySet<string> | undefined> {
|
|
34
29
|
const known = new Map<string, ReadonlySet<string> | undefined>();
|
|
35
30
|
return (path) =>
|
|
@@ -47,7 +42,10 @@ const references = Effect.fn("Docs.references")(function* (inputs: RuleInputs) {
|
|
|
47
42
|
const packages: readonly WorkspacePackage[] = yield* Effect.promise(() => workspacePackages(inputs));
|
|
48
43
|
const manifests = new Map(
|
|
49
44
|
yield* Effect.forEach(packages, (owner) =>
|
|
50
|
-
Effect.map(
|
|
45
|
+
Effect.map(
|
|
46
|
+
Effect.promise(() => readPackageManifest(inputs.readText, posix.join(owner.directory, "package.json"))),
|
|
47
|
+
(manifest) => [owner.name, manifest] as const,
|
|
48
|
+
),
|
|
51
49
|
),
|
|
52
50
|
);
|
|
53
51
|
const shared = {
|
|
@@ -55,7 +53,7 @@ const references = Effect.fn("Docs.references")(function* (inputs: RuleInputs) {
|
|
|
55
53
|
exports: new Map([...manifests].map(([name, manifest]) => [name, field(manifest, "exports")])),
|
|
56
54
|
packages: new Map(packages.map((owner) => [owner.name, owner])),
|
|
57
55
|
readText: read,
|
|
58
|
-
repository: repositoryOf(yield*
|
|
56
|
+
repository: repositoryOf(yield* Effect.promise(() => readPackageManifest(inputs.readText, "package.json"))),
|
|
59
57
|
root: inputs.root,
|
|
60
58
|
};
|
|
61
59
|
const documents = inputs.files.filter((file) => isDocument(file) && !isLink(inputs.root, file));
|
|
@@ -76,7 +74,7 @@ const references = Effect.fn("Docs.references")(function* (inputs: RuleInputs) {
|
|
|
76
74
|
});
|
|
77
75
|
|
|
78
76
|
export const docsReferences = defineRule({
|
|
79
|
-
check:
|
|
77
|
+
check: references,
|
|
80
78
|
description:
|
|
81
79
|
"Links, heading anchors and documented modules and exports in Markdown resolve, so documentation cannot point at a file, a heading or an API that no longer exists.",
|
|
82
80
|
id: "docs/references",
|
|
@@ -46,7 +46,7 @@ const unversionedInstalls = Effect.fn("Docs.unversionedInstalls")(function* (inp
|
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
export const docsUnversionedInstalls = defineRule({
|
|
49
|
-
check:
|
|
49
|
+
check: unversionedInstalls,
|
|
50
50
|
description:
|
|
51
51
|
"Install commands in Markdown name packages without versions, so documentation never tells a reader to install a release it has already left behind.",
|
|
52
52
|
id: "docs/unversioned-installs",
|