@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
|
@@ -10,6 +10,18 @@ export function serviceTypes(checker: ts.TypeChecker) {
|
|
|
10
10
|
const property = type.getProperty(name);
|
|
11
11
|
return property === undefined ? undefined : checker.getTypeOfSymbol(property);
|
|
12
12
|
}
|
|
13
|
+
function options(type: ts.Type): boolean {
|
|
14
|
+
if (type.getCallSignatures().length > 0) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return type
|
|
18
|
+
.getProperties()
|
|
19
|
+
.every(
|
|
20
|
+
(property) =>
|
|
21
|
+
(property.flags & ts.SymbolFlags.Optional) !== 0
|
|
22
|
+
&& checker.getNonNullableType(checker.getTypeOfSymbol(property)).getCallSignatures().length === 0,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
13
25
|
function remember(type: ts.Type): void {
|
|
14
26
|
if (type.getProperty(SERVICE) === undefined) {
|
|
15
27
|
return;
|
|
@@ -20,6 +32,7 @@ export function serviceTypes(checker: ts.TypeChecker) {
|
|
|
20
32
|
&& shape.flags & ts.TypeFlags.Object
|
|
21
33
|
&& (shape.getProperties().length > 0 || shape.getCallSignatures().length > 0)
|
|
22
34
|
&& checker.getIndexInfosOfType(shape).length === 0
|
|
35
|
+
&& !options(shape)
|
|
23
36
|
&& (shape.getCallSignatures().length === 0 || type.getProperty("~effect/Context/Reference") === undefined)
|
|
24
37
|
) {
|
|
25
38
|
shapes.add(shape);
|
|
@@ -1,22 +1,11 @@
|
|
|
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 type PackageImports = (importer: string, specifier: string) => string | undefined;
|
|
5
6
|
|
|
6
7
|
const MANIFEST = "package.json";
|
|
7
8
|
|
|
8
|
-
function importsField(text: string | undefined): unknown {
|
|
9
|
-
if (text === undefined) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
try {
|
|
13
|
-
const manifest: unknown = JSON.parse(text);
|
|
14
|
-
return typeof manifest === "object" && manifest !== null ? Reflect.get(manifest, "imports") : undefined;
|
|
15
|
-
} catch {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
9
|
function targetsIn(value: unknown): readonly string[] {
|
|
21
10
|
if (typeof value === "string") {
|
|
22
11
|
return [value];
|
|
@@ -52,7 +41,7 @@ function matched(imports: unknown, specifier: string): readonly string[] {
|
|
|
52
41
|
export async function packageImports({ files, readText }: Pick<RuleInputs, "files" | "readText">): Promise<PackageImports> {
|
|
53
42
|
const directories = files.filter((path) => posix.basename(path) === MANIFEST).map((path) => posix.dirname(path));
|
|
54
43
|
const manifests = await Promise.all(
|
|
55
|
-
directories.map(async (directory) => ({ directory, imports:
|
|
44
|
+
directories.map(async (directory) => ({ directory, imports: (await readPackageManifest(readText, posix.join(directory, MANIFEST)))?.imports })),
|
|
56
45
|
);
|
|
57
46
|
const deepestFirst = manifests.toSorted((left, right) => right.directory.length - left.directory.length);
|
|
58
47
|
const present = new Set(files);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
+
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
2
3
|
import { type ImportGraph, importGraph } from "#imports/graph.ts";
|
|
3
4
|
import { isTooling } from "#imports/isTooling.ts";
|
|
4
5
|
import { builtinName } from "#imports/packageName.ts";
|
|
5
6
|
import { packageOf, type WorkspacePackage } from "#imports/workspace.ts";
|
|
6
|
-
import { type EntryPoint, entryPointsOf, isApplication, provider, SHIPPED_FIELDS } from "#manifests/entryPoints.ts";
|
|
7
|
+
import { dependencyNames, type EntryPoint, entryPointsOf, isApplication, provider, SHIPPED_FIELDS } from "#manifests/entryPoints.ts";
|
|
7
8
|
import { isTestCode } from "#naming/testName.ts";
|
|
8
9
|
import { defineRule, type RuleInputs } from "#rule.ts";
|
|
9
10
|
import { bundleInputs } from "./bundleInputs.ts";
|
|
@@ -31,17 +32,6 @@ interface ManifestDependencies {
|
|
|
31
32
|
readonly shipped: ReadonlySet<string>;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
function names(manifest: object, field: string): readonly string[] {
|
|
35
|
-
const value: unknown = Reflect.get(manifest, field);
|
|
36
|
-
if (value === undefined) {
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
40
|
-
throw new Error(`${field} must be an object`);
|
|
41
|
-
}
|
|
42
|
-
return Object.keys(value);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
35
|
async function manifestDependencies(
|
|
46
36
|
inputs: RuleInputs,
|
|
47
37
|
owner: WorkspacePackage,
|
|
@@ -49,26 +39,18 @@ async function manifestDependencies(
|
|
|
49
39
|
workspace: ReadonlyMap<string, string>,
|
|
50
40
|
): Promise<ManifestDependencies> {
|
|
51
41
|
const path = posix.join(owner.directory, "package.json");
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
throw new Error("the manifest is missing");
|
|
56
|
-
}
|
|
57
|
-
const manifest: unknown = JSON.parse(text);
|
|
58
|
-
if (typeof manifest !== "object" || manifest === null || Array.isArray(manifest)) {
|
|
59
|
-
throw new Error("the manifest must be an object");
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
...bundleInputs(graph, owner, manifest, (candidate) => developmentFile(owner, candidate)),
|
|
63
|
-
application: isApplication(manifest),
|
|
64
|
-
development: new Set(names(manifest, "devDependencies")),
|
|
65
|
-
entryPoints: await entryPointsOf(inputs, owner.directory, manifest, workspace),
|
|
66
|
-
private: Reflect.get(manifest, "private") === true,
|
|
67
|
-
shipped: new Set(SHIPPED_FIELDS.flatMap((field) => names(manifest, field))),
|
|
68
|
-
};
|
|
69
|
-
} catch (cause) {
|
|
70
|
-
throw new Error(`cannot read dependency policy at ${path}: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
42
|
+
const manifest = await readPackageManifest(inputs.readText, path);
|
|
43
|
+
if (manifest === undefined) {
|
|
44
|
+
throw new Error("the manifest is missing");
|
|
71
45
|
}
|
|
46
|
+
return {
|
|
47
|
+
...bundleInputs(graph, owner, manifest, (candidate) => developmentFile(owner, candidate)),
|
|
48
|
+
application: isApplication(manifest),
|
|
49
|
+
development: new Set(dependencyNames(manifest, "devDependencies")),
|
|
50
|
+
entryPoints: await entryPointsOf(inputs, owner.directory, manifest, workspace),
|
|
51
|
+
private: Reflect.get(manifest, "private") === true,
|
|
52
|
+
shipped: new Set(SHIPPED_FIELDS.flatMap((field) => dependencyNames(manifest, field))),
|
|
53
|
+
};
|
|
72
54
|
}
|
|
73
55
|
|
|
74
56
|
function developmentFile(owner: WorkspacePackage, path: string): boolean {
|
|
@@ -105,7 +87,8 @@ function undeclared(owner: WorkspacePackage, policy: ManifestDependencies | unde
|
|
|
105
87
|
export const importsManifest = defineRule({
|
|
106
88
|
check: async (inputs) => {
|
|
107
89
|
const graph = await importGraph(inputs);
|
|
108
|
-
const root: WorkspacePackage | undefined =
|
|
90
|
+
const root: WorkspacePackage | undefined =
|
|
91
|
+
(await readPackageManifest(inputs.readText, "package.json")) === undefined ? undefined : { directory: ".", name: "." };
|
|
109
92
|
const owners = [...graph.packages, ...(root === undefined ? [] : [root])];
|
|
110
93
|
const workspace = new Map(graph.packages.map((owner) => [owner.name, owner.directory]));
|
|
111
94
|
const policies = new Map(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { type ImportGraph, importGraph } from "#imports/graph.ts";
|
|
2
3
|
import { builtinName } from "#imports/packageName.ts";
|
|
3
4
|
import { type Runtime, runtimeDeclarationProblems, runtimeOf } from "#imports/runtime.ts";
|
|
4
5
|
import { isTestCode } from "#naming/testName.ts";
|
|
@@ -11,42 +12,47 @@ function forbiddenImport(from: Runtime, to: Runtime | undefined, builtin: boolea
|
|
|
11
12
|
return from === "client" && (to === "server" || builtin);
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
function runtimeFindings(graph: ImportGraph, runtime: (path: string) => Runtime | undefined) {
|
|
16
|
+
return graph.edges.flatMap((edge) => {
|
|
17
|
+
const from = runtime(edge.from);
|
|
18
|
+
if (from === undefined || isTestCode(edge.from)) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
const to = edge.to.kind === "file" ? runtime(edge.to.path) : undefined;
|
|
22
|
+
const builtin = edge.to.kind === "external" && builtinName(edge.to.specifier) !== undefined;
|
|
23
|
+
if (!forbiddenImport(from, to, builtin)) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
file: edge.from,
|
|
29
|
+
line: edge.line,
|
|
30
|
+
message: `${from === "client" ? "Client" : "Shared"} code imports ${builtin ? "Node built-in" : `${to} code`} through "${edge.specifier}". Move runtime-dependent code into src/client/ or src/server/ and keep shared code independent of both runtimes.`,
|
|
31
|
+
subject: edge.specifier,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
14
37
|
export const importsRuntime = defineRule({
|
|
15
|
-
check:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
38
|
+
check: (inputs) =>
|
|
39
|
+
Effect.gen(function* () {
|
|
40
|
+
const graph = yield* Effect.promise(() => importGraph(inputs));
|
|
41
|
+
const runtime = yield* runtimeOf(inputs, graph.packages);
|
|
42
|
+
const imports = runtimeFindings(graph, runtime);
|
|
43
|
+
const declarations = (yield* runtimeDeclarationProblems(inputs, graph.packages)).map(({ directory, message }) => ({
|
|
44
|
+
file: directory === "." ? "package.json" : `${directory}/package.json`,
|
|
45
|
+
line: 1,
|
|
46
|
+
message,
|
|
47
|
+
subject: "quality.runtime",
|
|
48
|
+
}));
|
|
49
|
+
const shared = inputs.sources.filter((file) => !isTestCode(file.path) && runtime(file.path) === "shared");
|
|
50
|
+
if (shared.length === 0) {
|
|
51
|
+
return [...imports, ...declarations];
|
|
27
52
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
line: edge.line,
|
|
32
|
-
message: `${from === "client" ? "Client" : "Shared"} code imports ${builtin ? "Node built-in" : `${to} code`} through "${edge.specifier}". Move runtime-dependent code into src/client/ or src/server/ and keep shared code independent of both runtimes.`,
|
|
33
|
-
subject: edge.specifier,
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
});
|
|
37
|
-
const declarations = runtimeDeclarationProblems(inputs, graph.packages).map(({ directory, message }) => ({
|
|
38
|
-
file: directory === "." ? "package.json" : `${directory}/package.json`,
|
|
39
|
-
line: 1,
|
|
40
|
-
message,
|
|
41
|
-
subject: "quality.runtime",
|
|
42
|
-
}));
|
|
43
|
-
const shared = inputs.sources.filter((file) => !isTestCode(file.path) && runtime(file.path) === "shared");
|
|
44
|
-
if (shared.length === 0) {
|
|
45
|
-
return [...imports, ...declarations];
|
|
46
|
-
}
|
|
47
|
-
const { browserGlobals } = await import("#imports/browserGlobals.ts");
|
|
48
|
-
return [...imports, ...declarations, ...shared.flatMap(browserGlobals)];
|
|
49
|
-
},
|
|
53
|
+
const { browserGlobals } = yield* Effect.promise(() => import("#imports/browserGlobals.ts"));
|
|
54
|
+
return [...imports, ...declarations, ...shared.flatMap(browserGlobals)];
|
|
55
|
+
}),
|
|
50
56
|
description:
|
|
51
57
|
"Runtime folders define client, server and shared code. A manifest's quality.runtime declares a single-runtime package whole; executable packages without runtime folders and package-root tooling are server code.",
|
|
52
58
|
id: "imports/runtime",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { dirname, posix, relative, resolve, sep } from "node:path";
|
|
2
|
+
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
2
3
|
import { pnpmWorkspaceList } from "#imports/pnpmWorkspacePatterns.ts";
|
|
3
4
|
import { workspacePackages } from "#imports/workspace.ts";
|
|
4
5
|
import { DEPENDENCY_FIELDS, dependencyNames, entryPointsOf, isApplication, PLATFORM } from "#manifests/entryPoints.ts";
|
|
@@ -17,17 +18,6 @@ function hoists(pattern: string): boolean {
|
|
|
17
18
|
return new RegExp(`^${source}$`, "u").test(PROBE);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
function parsed(text: string | undefined): unknown {
|
|
21
|
-
if (text === undefined) {
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
return JSON.parse(text);
|
|
26
|
-
} catch {
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
21
|
function ancestors(root: string, directory: string): readonly string[] {
|
|
32
22
|
const start = resolve(root, directory);
|
|
33
23
|
const parent = dirname(start);
|
|
@@ -100,7 +90,7 @@ export const manifestsApplication = defineRule({
|
|
|
100
90
|
const findings = await Promise.all(
|
|
101
91
|
directories.map(async (directory) => {
|
|
102
92
|
const manifestPath = posix.join(directory, "package.json");
|
|
103
|
-
const manifest =
|
|
93
|
+
const manifest = await readPackageManifest(inputs.readText, manifestPath);
|
|
104
94
|
if (!isApplication(manifest)) {
|
|
105
95
|
return [];
|
|
106
96
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
+
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
2
3
|
import { workspacePackages } from "#imports/workspace.ts";
|
|
3
4
|
import { defineRule, type Finding } from "#rule.ts";
|
|
4
5
|
|
|
@@ -52,11 +53,14 @@ function findingsIn(file: string, exports: unknown): readonly Finding[] {
|
|
|
52
53
|
: [finding(file, "exports", `The exports field needs exactly one non-null wildcard; found ${patterns.length}.`)];
|
|
53
54
|
return [
|
|
54
55
|
...count,
|
|
55
|
-
...entries.flatMap(([key, value]) =>
|
|
56
|
-
value === null
|
|
56
|
+
...entries.flatMap(([key, value]) => {
|
|
57
|
+
if (value === null) {
|
|
58
|
+
return [finding(file, key, `Export "${key}" blocks module imports with null. Remove the null entry so callers can import each module.`)];
|
|
59
|
+
}
|
|
60
|
+
return key === "." || exactAsset(key, value) || standardPattern(key, value)
|
|
57
61
|
? []
|
|
58
|
-
: [finding(file, key, `Export "${key}" does not preserve the module's file path.`)]
|
|
59
|
-
),
|
|
62
|
+
: [finding(file, key, `Export "${key}" does not preserve the module's file path.`)];
|
|
63
|
+
}),
|
|
60
64
|
];
|
|
61
65
|
}
|
|
62
66
|
|
|
@@ -66,18 +70,17 @@ export const manifestsExportsShape = defineRule({
|
|
|
66
70
|
const files = ["package.json", ...packages.map((owner) => posix.join(owner.directory, "package.json"))];
|
|
67
71
|
const findings = await Promise.all(
|
|
68
72
|
files.map(async (file) => {
|
|
69
|
-
const
|
|
70
|
-
if (file === "package.json" &&
|
|
73
|
+
const manifest = await readPackageManifest(inputs.readText, file);
|
|
74
|
+
if (file === "package.json" && manifest === undefined) {
|
|
71
75
|
return [];
|
|
72
76
|
}
|
|
73
|
-
const manifest: unknown = JSON.parse(text ?? "");
|
|
74
77
|
return findingsIn(file, isMap(manifest) ? manifest.exports : undefined);
|
|
75
78
|
}),
|
|
76
79
|
);
|
|
77
80
|
return findings.flat();
|
|
78
81
|
},
|
|
79
82
|
description:
|
|
80
|
-
"Workspace packages export
|
|
83
|
+
"Workspace packages export every module through one file-preserving wildcard, with optional root and exact non-code assets; null entries are rejected, and a package without modules exports only exact assets.",
|
|
81
84
|
id: "manifests/exports-shape",
|
|
82
85
|
registrable: false,
|
|
83
86
|
});
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { defineRule, type Finding } from "#rule.ts";
|
|
5
|
-
|
|
6
|
-
const MESSAGES = {
|
|
7
|
-
Invalid: "Is not valid JSON.",
|
|
8
|
-
Unsorted: "Keys are not in sort-package-json order. Run `quality fix`.",
|
|
9
|
-
} as const;
|
|
1
|
+
import { manifestFiles, manifestText } from "#adapters/manifestInventory.ts";
|
|
2
|
+
import { sortingOf } from "#manifests/sorted.ts";
|
|
3
|
+
import { defineRule } from "#rule.ts";
|
|
10
4
|
|
|
11
5
|
export const manifestsSorted = defineRule({
|
|
12
|
-
check: async (
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
check: async (inputs) => {
|
|
7
|
+
const findings = await Promise.all(
|
|
8
|
+
manifestFiles(inputs).map(async (file) => {
|
|
9
|
+
const text = await manifestText(inputs.readText, file);
|
|
10
|
+
return text === undefined || sortingOf(text)._tag === "Sorted"
|
|
11
|
+
? []
|
|
12
|
+
: [{ file, message: "Keys are not in sort-package-json order. Run `quality fix`." }];
|
|
13
|
+
}),
|
|
14
|
+
);
|
|
15
|
+
return findings.flat();
|
|
19
16
|
},
|
|
20
17
|
description: "Every package.json in the repository keeps its keys in sort-package-json order. `quality fix` sorts them.",
|
|
21
18
|
id: "manifests/sorted",
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { manifestsIn } from "#manifests/sorted.ts";
|
|
1
|
+
import { manifestEntry, manifestFiles } from "#adapters/manifestInventory.ts";
|
|
4
2
|
import { defineRule, type Finding } from "#rule.ts";
|
|
5
|
-
import {
|
|
3
|
+
import { itemsOf, type Json, member, parseJsonc } from "#rules/suppressions/biome/json.ts";
|
|
6
4
|
|
|
7
5
|
const CONDITION = "source";
|
|
8
6
|
|
|
9
|
-
function misplaced(path: string, field: string, node: Json): readonly Finding[] {
|
|
10
|
-
const conditions =
|
|
7
|
+
function misplaced(path: string, field: string, value: unknown, node: Json | undefined): readonly Finding[] {
|
|
8
|
+
const conditions = typeof value === "object" && value !== null && !Array.isArray(value) ? Object.entries(value) : [];
|
|
11
9
|
const first = conditions[0]?.[0];
|
|
12
10
|
const own: readonly Finding[] =
|
|
13
11
|
first === CONDITION || !conditions.some(([key]) => key === CONDITION)
|
|
@@ -15,31 +13,33 @@ function misplaced(path: string, field: string, node: Json): readonly Finding[]
|
|
|
15
13
|
: [
|
|
16
14
|
{
|
|
17
15
|
file: path,
|
|
18
|
-
line: node
|
|
16
|
+
line: node?.line,
|
|
19
17
|
message: `Lists the "${CONDITION}" condition after "${first}" in ${field}. TypeScript takes the first condition that matches, so once built output exists it reads that instead of the sources the "${CONDITION}" condition names. Move "${CONDITION}" to the top of this condition block.`,
|
|
20
18
|
subject: field,
|
|
21
19
|
},
|
|
22
20
|
];
|
|
23
|
-
const nested =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function findingsIn(path: string, text: string): readonly Finding[] {
|
|
28
|
-
const parsed = parseJsonc(path, text);
|
|
29
|
-
if (parsed._tag !== "Parsed") {
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
return ["exports", "imports"].flatMap((field) => {
|
|
33
|
-
const map = member(parsed.json, field);
|
|
34
|
-
return map === undefined ? [] : misplaced(path, field, map);
|
|
35
|
-
});
|
|
21
|
+
const nested = conditions.map(([key, child]) => misplaced(path, field, child, member(node, key)));
|
|
22
|
+
const items = Array.isArray(value) ? value.flatMap((child: unknown, index) => misplaced(path, field, child, itemsOf(node)[index])) : [];
|
|
23
|
+
return [...own, ...nested.flat(), ...items];
|
|
36
24
|
}
|
|
37
25
|
|
|
38
26
|
export const manifestsSourceFirst = defineRule({
|
|
39
|
-
check: async (
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
check: async (inputs) => {
|
|
28
|
+
const findings = await Promise.all(
|
|
29
|
+
manifestFiles(inputs).map(async (path) => {
|
|
30
|
+
const entry = await manifestEntry(inputs.readText, path);
|
|
31
|
+
if (entry === undefined) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
const { manifest, text } = entry;
|
|
35
|
+
const parsed = parseJsonc(path, text);
|
|
36
|
+
const location = parsed._tag === "Parsed" ? parsed.json : undefined;
|
|
37
|
+
return ["exports", "imports"].flatMap((field) =>
|
|
38
|
+
misplaced(path, field, field === "exports" ? manifest.exports : manifest.imports, member(location, field)),
|
|
39
|
+
);
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
return findings.flat();
|
|
43
43
|
},
|
|
44
44
|
description:
|
|
45
45
|
'Every package.json condition block that names the "source" condition lists it first in exports and imports, so TypeScript reads the sources whether or not built output exists.',
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { loadPackageManifests, manifestFiles } from "#adapters/manifestInventory.ts";
|
|
3
|
+
import { defineRule } from "#rule.ts";
|
|
4
|
+
|
|
5
|
+
export const manifestsValid = defineRule({
|
|
6
|
+
check: (inputs) =>
|
|
7
|
+
Effect.map(
|
|
8
|
+
Effect.promise(() => loadPackageManifests(inputs.readText, manifestFiles(inputs))),
|
|
9
|
+
(failures) => failures.map(({ path, message }) => ({ file: path, message })),
|
|
10
|
+
),
|
|
11
|
+
description: "Every package.json is valid JSON and decodes through PackageManifest before repository rules run.",
|
|
12
|
+
id: "manifests/valid",
|
|
13
|
+
registrable: false,
|
|
14
|
+
});
|
|
@@ -58,6 +58,24 @@ function tableBoundary(tokens: readonly string[], index: number, statementStart:
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
function userForeignKeyAt(tokens: readonly string[], index: number, statementStart: number): boolean {
|
|
62
|
+
const statement = tokens.slice(statementStart, index).map((token) => token.toLowerCase());
|
|
63
|
+
if (tokens[index]?.toLowerCase() !== "references" || !["create", "alter"].includes(statement[0] ?? "") || !statement.includes("table")) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
let table = index + 1;
|
|
67
|
+
while (tokens[table + 1] === ".") {
|
|
68
|
+
table += 2;
|
|
69
|
+
}
|
|
70
|
+
if (tokens[table + 1] !== "(" || !["id", '"id"'].includes(tokens[table + 2]?.toLowerCase() ?? "") || tokens[table + 3] !== ")") {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const remainder = tokens.slice(table + 4);
|
|
74
|
+
const end = remainder.findIndex((token) => [",", ";", ")"].includes(token));
|
|
75
|
+
const clause = remainder.slice(0, end === -1 ? undefined : end).join(" ");
|
|
76
|
+
return /\bon delete (?:cascade|set null)\b/iu.test(clause);
|
|
77
|
+
}
|
|
78
|
+
|
|
61
79
|
interface SqlContext {
|
|
62
80
|
depth: number;
|
|
63
81
|
readonly expressionFromDepths: Set<number>;
|
|
@@ -97,7 +115,11 @@ function authTableIn(text: string): boolean {
|
|
|
97
115
|
if (boundary.starts) {
|
|
98
116
|
context.tablesAtDepth.add(context.depth);
|
|
99
117
|
}
|
|
100
|
-
return (
|
|
118
|
+
return (
|
|
119
|
+
(boundary.starts || (token === "," && context.tablesAtDepth.has(context.depth)))
|
|
120
|
+
&& AUTH_TABLES.has(tableAt(tokens, index + 1))
|
|
121
|
+
&& !(tableAt(tokens, index + 1) === "user" && userForeignKeyAt(tokens, index, context.statementStart))
|
|
122
|
+
);
|
|
101
123
|
});
|
|
102
124
|
}
|
|
103
125
|
|
|
@@ -109,9 +131,9 @@ export const authSql = defineRule({
|
|
|
109
131
|
file: query.file,
|
|
110
132
|
line: query.line,
|
|
111
133
|
message:
|
|
112
|
-
"SQL accesses a Better Auth table (user, account, session or verification). Use platform's auth API; only
|
|
134
|
+
"SQL accesses a Better Auth table (user, account, session or verification). Use platform's auth API (@shivaedev/identity) for account data; app migrations may only reference user(id) with ON DELETE CASCADE or ON DELETE SET NULL. Only the configured auth-sql owners manage auth storage.",
|
|
113
135
|
})),
|
|
114
|
-
description: "Apps
|
|
136
|
+
description: "Apps reference user IDs by foreign key and use identity for account data.",
|
|
115
137
|
id: "boundaries/auth-sql",
|
|
116
138
|
options: Schema.toStandardSchemaV1(AuthSqlOptions, { parseOptions: { errors: "all", onExcessProperty: "error" } }),
|
|
117
139
|
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { defineRule } from "#rule.ts";
|
|
4
|
+
import { bindsModule, importBindings } from "./importBindings.ts";
|
|
5
|
+
import { storySources } from "./sources.ts";
|
|
6
|
+
import { memberName, nodesWhere, syntaxFindings, unwrapped } from "./syntax.ts";
|
|
7
|
+
|
|
8
|
+
const MESSAGE =
|
|
9
|
+
'Uses an Exit, Cause or Result value or reads a _tag in a story. Have the kit\'s verb or readout return the outcome in the domain\'s words, such as "unauthorized" or "rolled back", and expect that; build failing inputs in a kit trait.';
|
|
10
|
+
|
|
11
|
+
const SHAPES = ["Exit", "Cause", "Result"];
|
|
12
|
+
const OUTCOME_TAGS = new Set(["Failure", "Success"]);
|
|
13
|
+
|
|
14
|
+
function shapeModule(source: ts.SourceFile): (node: ts.Expression) => boolean {
|
|
15
|
+
const bindings = importBindings(source);
|
|
16
|
+
return (node) => {
|
|
17
|
+
const value = unwrapped(node);
|
|
18
|
+
return ts.isIdentifier(value) && SHAPES.some((shape) => bindsModule(bindings.get(value.text), shape, ["effect"]));
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function outcomeTag(node: ts.PropertyAssignment): boolean {
|
|
23
|
+
const name = ts.isIdentifier(node.name) || ts.isStringLiteral(node.name) ? node.name.text : undefined;
|
|
24
|
+
const value = unwrapped(node.initializer);
|
|
25
|
+
return name === "_tag" && ts.isStringLiteralLike(value) && OUTCOME_TAGS.has(value.text);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function shapeReads(source: ts.SourceFile): readonly ts.Node[] {
|
|
29
|
+
const fromShapeModule = shapeModule(source);
|
|
30
|
+
return nodesWhere(
|
|
31
|
+
source,
|
|
32
|
+
(node) =>
|
|
33
|
+
((ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node))
|
|
34
|
+
&& (memberName(node) === "_tag" || fromShapeModule(node.expression)))
|
|
35
|
+
|| (ts.isBindingElement(node) && (node.propertyName ?? node.name).getText(source) === "_tag")
|
|
36
|
+
|| (ts.isPropertyAssignment(node) && outcomeTag(node)),
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const domainOutcomes = defineRule({
|
|
41
|
+
check: (inputs) => Effect.map(storySources(inputs), (stories) => stories.flatMap((file) => syntaxFindings(file, shapeReads, MESSAGE))),
|
|
42
|
+
description: "Story verbs and readouts return outcomes in the domain's words, not Exit, Cause or Result shapes or _tag reads.",
|
|
43
|
+
id: "tests/domain-outcomes",
|
|
44
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { defineRule } from "#rule.ts";
|
|
4
|
+
import { importBindings } from "./importBindings.ts";
|
|
5
|
+
import { storySources } from "./sources.ts";
|
|
6
|
+
import { memberName, syntaxFindings, unwrapped } from "./syntax.ts";
|
|
7
|
+
|
|
8
|
+
const MESSAGE =
|
|
9
|
+
'Checks several outcomes with consecutive expect(yield* …) lines. Let the story\'s words lead: yield* outcomes({ "label": [readout, expected], … }) from @shivaedev/test-story/server/outcomes.ts, one row per outcome. Keep a plain expect for a single outcome.';
|
|
10
|
+
|
|
11
|
+
const EXPECT_MODULES = ["vitest", "@effect/vitest"];
|
|
12
|
+
|
|
13
|
+
function yields(node: ts.Node): boolean {
|
|
14
|
+
return (
|
|
15
|
+
(ts.isYieldExpression(node) && node.asteriskToken !== undefined)
|
|
16
|
+
|| (!ts.isFunctionLike(node) && ts.forEachChild(node, (child) => yields(child) || undefined) === true)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function expectNames(source: ts.SourceFile): ReadonlySet<string> {
|
|
21
|
+
const imported = [...importBindings(source)].filter(([, binding]) => binding.imported === "expect" && EXPECT_MODULES.includes(binding.module));
|
|
22
|
+
return new Set(["expect", ...imported.map(([local]) => local)]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function expectCall(node: ts.Expression, names: ReadonlySet<string>): ts.CallExpression | undefined {
|
|
26
|
+
const value = unwrapped(node);
|
|
27
|
+
if (ts.isCallExpression(value)) {
|
|
28
|
+
const callee = unwrapped(value.expression);
|
|
29
|
+
const receiver = ts.isPropertyAccessExpression(callee) && memberName(callee) === "soft" ? unwrapped(callee.expression) : callee;
|
|
30
|
+
return ts.isIdentifier(receiver) && names.has(receiver.text) ? value : expectCall(value.expression, names);
|
|
31
|
+
}
|
|
32
|
+
return ts.isPropertyAccessExpression(value) || ts.isElementAccessExpression(value) ? expectCall(value.expression, names) : undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function statementsOf(node: ts.Node): readonly ts.Statement[] {
|
|
36
|
+
return ts.isBlock(node) || ts.isSourceFile(node) || ts.isCaseClause(node) || ts.isDefaultClause(node) || ts.isModuleBlock(node)
|
|
37
|
+
? node.statements
|
|
38
|
+
: [];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function consecutiveChecks(source: ts.SourceFile): readonly ts.Node[] {
|
|
42
|
+
const names = expectNames(source);
|
|
43
|
+
function checksYield(statement: ts.Statement | undefined): boolean {
|
|
44
|
+
const subject =
|
|
45
|
+
statement !== undefined && ts.isExpressionStatement(statement) ? expectCall(statement.expression, names)?.arguments[0] : undefined;
|
|
46
|
+
return subject !== undefined && yields(subject);
|
|
47
|
+
}
|
|
48
|
+
const runs: ts.Node[] = [];
|
|
49
|
+
function visit(node: ts.Node): void {
|
|
50
|
+
const statements = statementsOf(node);
|
|
51
|
+
for (const [index, statement] of statements.entries()) {
|
|
52
|
+
if (checksYield(statement) && checksYield(statements[index + 1]) && !checksYield(statements[index - 1])) {
|
|
53
|
+
runs.push(statement);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
ts.forEachChild(node, visit);
|
|
57
|
+
}
|
|
58
|
+
visit(source);
|
|
59
|
+
return runs;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const groupedOutcomes = defineRule({
|
|
63
|
+
check: (inputs) => Effect.map(storySources(inputs), (stories) => stories.flatMap((file) => syntaxFindings(file, consecutiveChecks, MESSAGE))),
|
|
64
|
+
description: "Several outcomes after one action are rows of one outcomes call, so the story's words lead each line.",
|
|
65
|
+
id: "tests/grouped-outcomes",
|
|
66
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
export interface ImportBinding {
|
|
4
|
+
readonly imported: string;
|
|
5
|
+
readonly module: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const NAMESPACE = "*";
|
|
9
|
+
|
|
10
|
+
export function importBindings(source: ts.SourceFile): ReadonlyMap<string, ImportBinding> {
|
|
11
|
+
const bindings = new Map<string, ImportBinding>();
|
|
12
|
+
for (const statement of source.statements) {
|
|
13
|
+
if (!(ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier))) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const module = statement.moduleSpecifier.text;
|
|
17
|
+
const clause = statement.importClause;
|
|
18
|
+
const named = clause?.namedBindings;
|
|
19
|
+
if (named !== undefined && ts.isNamespaceImport(named)) {
|
|
20
|
+
bindings.set(named.name.text, { imported: NAMESPACE, module });
|
|
21
|
+
} else if (named !== undefined) {
|
|
22
|
+
for (const element of named.elements) {
|
|
23
|
+
bindings.set(element.name.text, { imported: (element.propertyName ?? element.name).text, module });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return bindings;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function bindsModule(binding: ImportBinding | undefined, name: string, modules: readonly string[]): boolean {
|
|
31
|
+
return (
|
|
32
|
+
binding !== undefined
|
|
33
|
+
&& (binding.imported === NAMESPACE
|
|
34
|
+
? modules.some((module) => binding.module === `${module}/${name}`)
|
|
35
|
+
: binding.imported === name && modules.includes(binding.module))
|
|
36
|
+
);
|
|
37
|
+
}
|