@shivaedev/quality 0.56.0 → 0.57.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 +34 -0
- package/README.md +63 -4
- package/biome/plugins/effect-test-bodies.grit +1 -1
- package/dist/{rules/suppressions → adapters}/biome/configs.d.ts +2 -2
- package/dist/adapters/biome/configs.d.ts.map +1 -0
- package/dist/{rules/suppressions → adapters}/biome/configs.js +2 -2
- package/dist/adapters/biome/configs.js.map +1 -0
- package/dist/adapters/biome/presetConfig.d.ts +21 -0
- package/dist/adapters/biome/presetConfig.d.ts.map +1 -0
- package/dist/adapters/biome/presetConfig.js +32 -0
- package/dist/adapters/biome/presetConfig.js.map +1 -0
- package/dist/adapters/biome/relocateConfig.d.ts.map +1 -0
- package/dist/adapters/biome/relocateConfig.js.map +1 -0
- package/dist/adapters/biome/resolvePackage.d.ts.map +1 -0
- package/dist/adapters/biome/resolvePackage.js.map +1 -0
- package/dist/adapters/biome/rootConfig.d.ts +9 -0
- package/dist/adapters/biome/rootConfig.d.ts.map +1 -0
- package/dist/adapters/biome/rootConfig.js +11 -0
- package/dist/adapters/biome/rootConfig.js.map +1 -0
- package/dist/adapters/biome/run.js +1 -1
- package/dist/adapters/biome/run.js.map +1 -1
- package/dist/adapters/biome/syntaxOf.d.ts +3 -0
- package/dist/adapters/biome/syntaxOf.d.ts.map +1 -0
- package/dist/adapters/biome/syntaxOf.js +11 -0
- package/dist/adapters/biome/syntaxOf.js.map +1 -0
- package/dist/adapters/biome/withExceptionConfig.d.ts +8 -0
- package/dist/adapters/biome/withExceptionConfig.d.ts.map +1 -0
- package/dist/adapters/biome/withExceptionConfig.js +38 -0
- package/dist/adapters/biome/withExceptionConfig.js.map +1 -0
- package/dist/adapters/changeKeyApi.d.ts +4 -0
- package/dist/adapters/changeKeyApi.d.ts.map +1 -0
- package/dist/adapters/changeKeyApi.js +58 -0
- package/dist/adapters/changeKeyApi.js.map +1 -0
- package/dist/adapters/changeKeyFindings.d.ts +4 -0
- package/dist/adapters/changeKeyFindings.d.ts.map +1 -0
- package/dist/adapters/changeKeyFindings.js +87 -0
- package/dist/adapters/changeKeyFindings.js.map +1 -0
- package/dist/adapters/changeKeyLiterals.d.ts +3 -0
- package/dist/adapters/changeKeyLiterals.d.ts.map +1 -0
- package/dist/adapters/changeKeyLiterals.js +56 -0
- package/dist/adapters/changeKeyLiterals.js.map +1 -0
- package/dist/adapters/ignore.d.ts +10 -0
- package/dist/adapters/ignore.d.ts.map +1 -0
- package/dist/adapters/ignore.js +10 -0
- package/dist/adapters/ignore.js.map +1 -0
- package/dist/adapters/imports/fakeReferences.d.ts +14 -0
- package/dist/adapters/imports/fakeReferences.d.ts.map +1 -0
- package/dist/adapters/imports/fakeReferences.js +103 -0
- package/dist/adapters/imports/fakeReferences.js.map +1 -0
- package/dist/adapters/imports/fakeTargets.d.ts +13 -0
- package/dist/adapters/imports/fakeTargets.d.ts.map +1 -0
- package/dist/adapters/imports/fakeTargets.js +14 -0
- package/dist/adapters/imports/fakeTargets.js.map +1 -0
- package/dist/adapters/outsideImportFindings.d.ts +5 -0
- package/dist/adapters/outsideImportFindings.d.ts.map +1 -0
- package/dist/adapters/outsideImportFindings.js +78 -0
- package/dist/adapters/outsideImportFindings.js.map +1 -0
- package/dist/adapters/queueReadoutFindings.d.ts +8 -0
- package/dist/adapters/queueReadoutFindings.d.ts.map +1 -0
- package/dist/adapters/queueReadoutFindings.js +30 -0
- package/dist/adapters/queueReadoutFindings.js.map +1 -0
- package/dist/adapters/queueTestingOrigin.d.ts +5 -0
- package/dist/adapters/queueTestingOrigin.d.ts.map +1 -0
- package/dist/adapters/queueTestingOrigin.js +95 -0
- package/dist/adapters/queueTestingOrigin.js.map +1 -0
- package/dist/adapters/readConfig.d.ts +7 -0
- package/dist/adapters/readConfig.d.ts.map +1 -0
- package/dist/adapters/readConfig.js +40 -0
- package/dist/adapters/readConfig.js.map +1 -0
- package/dist/adapters/serviceIdFindings.d.ts +4 -0
- package/dist/adapters/serviceIdFindings.d.ts.map +1 -0
- package/dist/adapters/serviceIdFindings.js +65 -0
- package/dist/adapters/serviceIdFindings.js.map +1 -0
- package/dist/adapters/sharedErrorFindings.d.ts +4 -0
- package/dist/adapters/sharedErrorFindings.d.ts.map +1 -0
- package/dist/adapters/sharedErrorFindings.js +71 -0
- package/dist/adapters/sharedErrorFindings.js.map +1 -0
- package/dist/adapters/sharedErrorModules.d.ts +7 -0
- package/dist/adapters/sharedErrorModules.d.ts.map +1 -0
- package/dist/adapters/sharedErrorModules.js +66 -0
- package/dist/adapters/sharedErrorModules.js.map +1 -0
- package/dist/adapters/testProjects.d.ts.map +1 -1
- package/dist/adapters/testProjects.js +18 -2
- package/dist/adapters/testProjects.js.map +1 -1
- package/dist/appTestConfig.d.ts +1 -1
- package/dist/appTestConfig.d.ts.map +1 -1
- package/dist/appTestConfig.js.map +1 -1
- package/dist/biome/exceptionConfig.d.ts +0 -7
- package/dist/biome/exceptionConfig.d.ts.map +1 -1
- package/dist/biome/exceptionConfig.js +0 -36
- package/dist/biome/exceptionConfig.js.map +1 -1
- package/dist/biome/recognizeDiagnostics.d.ts.map +1 -1
- package/dist/biome/recognizeDiagnostics.js +2 -1
- package/dist/biome/recognizeDiagnostics.js.map +1 -1
- package/dist/biome/syntax.d.ts +0 -1
- package/dist/biome/syntax.d.ts.map +1 -1
- package/dist/biome/syntax.js +0 -9
- package/dist/biome/syntax.js.map +1 -1
- package/dist/biome/withoutEntryPointImports.d.ts +32 -2
- package/dist/biome/withoutEntryPointImports.d.ts.map +1 -1
- package/dist/biome/withoutEntryPointImports.js +12 -10
- package/dist/biome/withoutEntryPointImports.js.map +1 -1
- package/dist/cli/fixRule.js +1 -1
- package/dist/cli/fixRule.js.map +1 -1
- package/dist/config/globs.d.ts.map +1 -1
- package/dist/config/globs.js +1 -5
- package/dist/config/globs.js.map +1 -1
- package/dist/config/load.d.ts +2 -2
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +5 -36
- package/dist/config/load.js.map +1 -1
- package/dist/domEnvironment.config.js +1 -1
- package/dist/domEnvironment.config.js.map +1 -1
- package/dist/exceptions/biomeFindings.d.ts +1 -1
- package/dist/exceptions/biomeFindings.d.ts.map +1 -1
- package/dist/exceptions/biomeFindings.js +10 -6
- package/dist/exceptions/biomeFindings.js.map +1 -1
- package/dist/inventory/collect.js +2 -2
- package/dist/inventory/collect.js.map +1 -1
- package/dist/inventory/ignoreScope.d.ts +2 -2
- package/dist/inventory/ignoreScope.d.ts.map +1 -1
- package/dist/inventory/ignoreScope.js +2 -2
- package/dist/inventory/ignoreScope.js.map +1 -1
- package/dist/naming/packageLayout.d.ts +2 -1
- package/dist/naming/packageLayout.d.ts.map +1 -1
- package/dist/naming/packageLayout.js +4 -6
- package/dist/naming/packageLayout.js.map +1 -1
- package/dist/naming/testName.d.ts +1 -1
- package/dist/naming/testName.d.ts.map +1 -1
- package/dist/naming/testName.js +1 -1
- package/dist/naming/testName.js.map +1 -1
- package/dist/rules/biome.d.ts +1 -8
- package/dist/rules/biome.d.ts.map +1 -1
- package/dist/rules/biome.js +6 -15
- package/dist/rules/biome.js.map +1 -1
- package/dist/rules/builtIn.d.ts +2 -2
- package/dist/rules/builtIn.d.ts.map +1 -1
- package/dist/rules/builtIn.js +12 -0
- package/dist/rules/builtIn.js.map +1 -1
- package/dist/rules/effect/adapterImports.d.ts +2 -0
- package/dist/rules/effect/adapterImports.d.ts.map +1 -0
- package/dist/rules/effect/adapterImports.js +9 -0
- package/dist/rules/effect/adapterImports.js.map +1 -0
- package/dist/rules/effect/program.d.ts +1 -1
- package/dist/rules/effect/program.d.ts.map +1 -1
- package/dist/rules/effect/program.js +2 -2
- package/dist/rules/effect/program.js.map +1 -1
- package/dist/rules/effect/serviceIds.d.ts +2 -0
- package/dist/rules/effect/serviceIds.d.ts.map +1 -0
- package/dist/rules/effect/serviceIds.js +9 -0
- package/dist/rules/effect/serviceIds.js.map +1 -0
- package/dist/rules/effect/sharedErrorClasses.d.ts +2 -0
- package/dist/rules/effect/sharedErrorClasses.d.ts.map +1 -0
- package/dist/rules/effect/sharedErrorClasses.js +9 -0
- package/dist/rules/effect/sharedErrorClasses.js.map +1 -0
- package/dist/rules/files/folderNames.d.ts.map +1 -1
- package/dist/rules/files/folderNames.js +7 -7
- package/dist/rules/files/folderNames.js.map +1 -1
- package/dist/rules/files/namedAfterExport.d.ts.map +1 -1
- package/dist/rules/files/namedAfterExport.js +6 -6
- package/dist/rules/files/namedAfterExport.js.map +1 -1
- package/dist/rules/files/otherNames.d.ts.map +1 -1
- package/dist/rules/files/otherNames.js +7 -7
- package/dist/rules/files/otherNames.js.map +1 -1
- package/dist/rules/files/packageImports.d.ts +2 -1
- package/dist/rules/files/packageImports.d.ts.map +1 -1
- package/dist/rules/files/packageImports.js +4 -3
- package/dist/rules/files/packageImports.js.map +1 -1
- package/dist/rules/files/stylesheetImporters.d.ts +2 -1
- package/dist/rules/files/stylesheetImporters.d.ts.map +1 -1
- package/dist/rules/files/stylesheetImporters.js +5 -4
- package/dist/rules/files/stylesheetImporters.js.map +1 -1
- package/dist/rules/manifestsApplication.d.ts.map +1 -1
- package/dist/rules/manifestsApplication.js +22 -22
- package/dist/rules/manifestsApplication.js.map +1 -1
- package/dist/rules/manifestsExportsShape.d.ts.map +1 -1
- package/dist/rules/manifestsExportsShape.js +32 -8
- package/dist/rules/manifestsExportsShape.js.map +1 -1
- package/dist/rules/manifestsSorted.d.ts.map +1 -1
- package/dist/rules/manifestsSorted.js +6 -5
- package/dist/rules/manifestsSorted.js.map +1 -1
- package/dist/rules/manifestsSourceFirst.d.ts.map +1 -1
- package/dist/rules/manifestsSourceFirst.js +6 -5
- package/dist/rules/manifestsSourceFirst.js.map +1 -1
- package/dist/rules/stories/adapterOnlyFakes.d.ts +2 -0
- package/dist/rules/stories/adapterOnlyFakes.d.ts.map +1 -0
- package/dist/rules/stories/adapterOnlyFakes.js +63 -0
- package/dist/rules/stories/adapterOnlyFakes.js.map +1 -0
- package/dist/rules/stories/fakeImplementation.d.ts +4 -0
- package/dist/rules/stories/fakeImplementation.d.ts.map +1 -0
- package/dist/rules/stories/fakeImplementation.js +22 -0
- package/dist/rules/stories/fakeImplementation.js.map +1 -0
- package/dist/rules/stories/fakeReplacements.d.ts +4 -0
- package/dist/rules/stories/fakeReplacements.d.ts.map +1 -0
- package/dist/rules/stories/fakeReplacements.js +71 -0
- package/dist/rules/stories/fakeReplacements.js.map +1 -0
- package/dist/rules/stories/importOrigin.js +2 -2
- package/dist/rules/stories/importOrigin.js.map +1 -1
- package/dist/rules/stories/importedChangeKeys.d.ts +2 -0
- package/dist/rules/stories/importedChangeKeys.d.ts.map +1 -0
- package/dist/rules/stories/importedChangeKeys.js +9 -0
- package/dist/rules/stories/importedChangeKeys.js.map +1 -0
- package/dist/rules/stories/pureNetImport.d.ts +4 -0
- package/dist/rules/stories/pureNetImport.d.ts.map +1 -0
- package/dist/rules/stories/pureNetImport.js +23 -0
- package/dist/rules/stories/pureNetImport.js.map +1 -0
- package/dist/rules/stories/queueReadouts.d.ts +2 -0
- package/dist/rules/stories/queueReadouts.d.ts.map +1 -0
- package/dist/rules/stories/queueReadouts.js +9 -0
- package/dist/rules/stories/queueReadouts.js.map +1 -0
- package/dist/rules/stories/unitTests.d.ts.map +1 -1
- package/dist/rules/stories/unitTests.js +4 -3
- package/dist/rules/stories/unitTests.js.map +1 -1
- package/dist/rules/suppressions/biome/weakenings.d.ts +1 -1
- package/dist/rules/suppressions/biome/weakenings.d.ts.map +1 -1
- package/dist/rules/suppressions/biomeOverrides.d.ts.map +1 -1
- package/dist/rules/suppressions/biomeOverrides.js +5 -5
- package/dist/rules/suppressions/biomeOverrides.js.map +1 -1
- package/dist/rules/suppressions/biomeRecommended.d.ts +1 -1
- package/dist/rules/suppressions/biomeRecommended.d.ts.map +1 -1
- package/dist/rules/suppressions/biomeRecommended.js +12 -30
- package/dist/rules/suppressions/biomeRecommended.js.map +1 -1
- package/dist/rules/test-names/colocated.js +2 -2
- package/dist/rules/test-names/colocated.js.map +1 -1
- package/dist/rules/test-names/follow.js +4 -4
- package/dist/rules/test-names/follow.js.map +1 -1
- package/dist/testing/adapters/cli.d.ts +21 -0
- package/dist/testing/adapters/cli.d.ts.map +1 -0
- package/dist/testing/adapters/cli.js +85 -0
- package/dist/testing/adapters/cli.js.map +1 -0
- package/dist/testing/adapters/git.d.ts +14 -0
- package/dist/testing/adapters/git.d.ts.map +1 -0
- package/dist/testing/adapters/git.js +52 -0
- package/dist/testing/adapters/git.js.map +1 -0
- package/dist/testing/adapters/hookPath.d.ts +2 -0
- package/dist/testing/adapters/hookPath.d.ts.map +1 -0
- package/dist/testing/adapters/hookPath.js +6 -0
- package/dist/testing/adapters/hookPath.js.map +1 -0
- package/dist/testing/adapters/hookRepository.d.ts +25 -0
- package/dist/testing/adapters/hookRepository.d.ts.map +1 -0
- package/dist/testing/adapters/hookRepository.js +96 -0
- package/dist/testing/adapters/hookRepository.js.map +1 -0
- package/dist/testing/adapters/imports.d.ts +5 -0
- package/dist/testing/adapters/imports.d.ts.map +1 -0
- package/dist/testing/adapters/imports.js +29 -0
- package/dist/testing/adapters/imports.js.map +1 -0
- package/dist/testing/adapters/packageExports.d.ts +15 -0
- package/dist/testing/adapters/packageExports.d.ts.map +1 -0
- package/dist/testing/adapters/packageExports.js +29 -0
- package/dist/testing/adapters/packageExports.js.map +1 -0
- package/dist/testing/adapters/qualityTree.d.ts +4 -0
- package/dist/testing/adapters/qualityTree.d.ts.map +1 -0
- package/dist/testing/adapters/qualityTree.js +21 -0
- package/dist/testing/adapters/qualityTree.js.map +1 -0
- package/dist/testing/adapters/run.d.ts +4 -0
- package/dist/testing/adapters/run.d.ts.map +1 -0
- package/dist/testing/adapters/run.js +6 -0
- package/dist/testing/adapters/run.js.map +1 -0
- package/dist/testing/adapters/storySpecFiles.d.ts +7 -0
- package/dist/testing/adapters/storySpecFiles.d.ts.map +1 -0
- package/dist/testing/adapters/storySpecFiles.js +48 -0
- package/dist/testing/adapters/storySpecFiles.js.map +1 -0
- package/dist/testing/adapters/tree.d.ts +13 -0
- package/dist/testing/adapters/tree.d.ts.map +1 -0
- package/dist/testing/adapters/tree.js +42 -0
- package/dist/testing/adapters/tree.js.map +1 -0
- package/dist/testing/adapters/writePackageExports.d.ts +2 -0
- package/dist/testing/adapters/writePackageExports.d.ts.map +1 -0
- package/dist/testing/adapters/writePackageExports.js +9 -0
- package/dist/testing/adapters/writePackageExports.js.map +1 -0
- package/dist/testing/ruleStory.d.ts +28 -0
- package/dist/testing/ruleStory.d.ts.map +1 -0
- package/dist/testing/ruleStory.js +115 -0
- package/dist/testing/ruleStory.js.map +1 -0
- package/dist/unitIoGuard.config.js +1 -1
- package/dist/unitIoGuard.config.js.map +1 -1
- package/package.json +7 -2
- package/src/{rules/suppressions → adapters}/biome/configs.ts +2 -2
- package/src/adapters/biome/presetConfig.ts +34 -0
- package/src/adapters/biome/rootConfig.ts +19 -0
- package/src/adapters/biome/run.ts +1 -1
- package/src/adapters/biome/syntaxOf.ts +12 -0
- package/src/adapters/biome/withExceptionConfig.ts +45 -0
- package/src/adapters/changeKeyApi.ts +62 -0
- package/src/adapters/changeKeyFindings.ts +96 -0
- package/src/adapters/changeKeyLiterals.ts +60 -0
- package/src/adapters/ignore.ts +16 -0
- package/src/adapters/imports/fakeReferences.ts +115 -0
- package/src/adapters/imports/fakeTargets.ts +21 -0
- package/src/adapters/outsideImportFindings.ts +98 -0
- package/src/adapters/queueReadoutFindings.ts +37 -0
- package/src/adapters/queueTestingOrigin.ts +113 -0
- package/src/adapters/readConfig.ts +42 -0
- package/src/adapters/serviceIdFindings.ts +80 -0
- package/src/adapters/sharedErrorFindings.ts +84 -0
- package/src/adapters/sharedErrorModules.ts +81 -0
- package/src/adapters/testProjects.ts +18 -2
- package/src/appTestConfig.ts +1 -1
- package/src/biome/exceptionConfig.ts +0 -43
- package/src/biome/recognizeDiagnostics.ts +2 -1
- package/src/biome/syntax.ts +0 -10
- package/src/biome/withoutEntryPointImports.ts +15 -10
- package/src/cli/fixRule.ts +1 -1
- package/src/config/globs.ts +1 -6
- package/src/config/load.ts +6 -38
- package/src/domEnvironment.config.ts +1 -1
- package/src/exceptions/biomeFindings.ts +11 -10
- package/src/inventory/collect.ts +2 -2
- package/src/inventory/ignoreScope.ts +3 -3
- package/src/naming/packageLayout.ts +14 -7
- package/src/naming/testName.ts +1 -1
- package/src/rules/biome.ts +6 -23
- package/src/rules/builtIn.ts +12 -0
- package/src/rules/effect/adapterImports.ts +10 -0
- package/src/rules/effect/program.ts +2 -2
- package/src/rules/effect/serviceIds.ts +10 -0
- package/src/rules/effect/sharedErrorClasses.ts +10 -0
- package/src/rules/files/folderNames.ts +19 -18
- package/src/rules/files/namedAfterExport.ts +10 -9
- package/src/rules/files/otherNames.ts +17 -16
- package/src/rules/files/packageImports.ts +14 -4
- package/src/rules/files/stylesheetImporters.ts +13 -6
- package/src/rules/manifestsApplication.ts +44 -33
- package/src/rules/manifestsExportsShape.ts +45 -15
- package/src/rules/manifestsSorted.ts +16 -11
- package/src/rules/manifestsSourceFirst.ts +22 -17
- package/src/rules/stories/adapterOnlyFakes.ts +66 -0
- package/src/rules/stories/fakeImplementation.ts +23 -0
- package/src/rules/stories/fakeReplacements.ts +74 -0
- package/src/rules/stories/importOrigin.ts +2 -2
- package/src/rules/stories/importedChangeKeys.ts +10 -0
- package/src/rules/stories/pureNetImport.ts +29 -0
- package/src/rules/stories/queueReadouts.ts +9 -0
- package/src/rules/stories/unitTests.ts +6 -3
- package/src/rules/suppressions/biome/weakenings.ts +1 -1
- package/src/rules/suppressions/biomeOverrides.ts +17 -16
- package/src/rules/suppressions/biomeRecommended.ts +13 -32
- package/src/rules/test-names/colocated.ts +2 -2
- package/src/rules/test-names/follow.ts +4 -4
- package/src/testing/adapters/cli.ts +105 -0
- package/src/testing/adapters/git.ts +62 -0
- package/src/testing/adapters/hookPath.ts +6 -0
- package/src/testing/adapters/hookRepository.ts +134 -0
- package/src/testing/adapters/imports.ts +35 -0
- package/src/testing/adapters/packageExports.ts +37 -0
- package/src/testing/adapters/qualityTree.ts +26 -0
- package/src/testing/adapters/run.ts +7 -0
- package/src/testing/adapters/storySpecFiles.ts +54 -0
- package/src/testing/adapters/tree.ts +55 -0
- package/src/testing/adapters/writePackageExports.ts +9 -0
- package/src/testing/ruleStory.ts +139 -0
- package/src/unitIoGuard.config.ts +1 -1
- package/dist/biome/relocateConfig.d.ts.map +0 -1
- package/dist/biome/relocateConfig.js.map +0 -1
- package/dist/rules/suppressions/biome/configs.d.ts.map +0 -1
- package/dist/rules/suppressions/biome/configs.js.map +0 -1
- package/dist/rules/suppressions/biome/resolvePackage.d.ts.map +0 -1
- package/dist/rules/suppressions/biome/resolvePackage.js.map +0 -1
- /package/dist/{biome → adapters/biome}/relocateConfig.d.ts +0 -0
- /package/dist/{biome → adapters/biome}/relocateConfig.js +0 -0
- /package/dist/{rules/suppressions → adapters}/biome/resolvePackage.d.ts +0 -0
- /package/dist/{rules/suppressions → adapters}/biome/resolvePackage.js +0 -0
- /package/src/{biome → adapters/biome}/relocateConfig.ts +0 -0
- /package/src/{rules/suppressions → adapters}/biome/resolvePackage.ts +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
+
import { Effect } from "effect";
|
|
2
3
|
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
3
4
|
import { isTooling } from "#imports/isTooling.ts";
|
|
4
5
|
import { entryPointsOf, isApplication, provider } from "#manifests/entryPoints.ts";
|
|
@@ -10,33 +11,37 @@ const UNDECLARED = "lint/correctness/noUndeclaredDependencies";
|
|
|
10
11
|
|
|
11
12
|
const DEPENDENCY = /^Dependency (?<name>\S+) isn't specified in /u;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
const ownerOf = Effect.fn("Biome.ownerOf")(function* (inputs: Pick<RuleInputs, "readText">, path: string) {
|
|
14
15
|
let directory = posix.dirname(path);
|
|
15
16
|
for (;;) {
|
|
16
|
-
const
|
|
17
|
+
const file = posix.join(directory, "package.json");
|
|
18
|
+
const manifest = yield* Effect.promise(() => readPackageManifest(inputs.readText, file));
|
|
17
19
|
if (manifest !== undefined || directory === ".") {
|
|
18
20
|
return { directory, manifest };
|
|
19
21
|
}
|
|
20
22
|
directory = posix.dirname(directory);
|
|
21
23
|
}
|
|
22
|
-
}
|
|
24
|
+
});
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
const brought = Effect.fn("Biome.brought")(function* (inputs: Pick<RuleInputs, "readText">, diagnostic: Diagnostic) {
|
|
25
27
|
const name = DEPENDENCY.exec(diagnostic.message)?.groups?.name;
|
|
26
28
|
const path = diagnostic.location.path;
|
|
27
29
|
if (diagnostic.category !== UNDECLARED || name === undefined || path === undefined) {
|
|
28
30
|
return false;
|
|
29
31
|
}
|
|
30
|
-
const owner =
|
|
32
|
+
const owner = yield* ownerOf(inputs, path);
|
|
31
33
|
if (!isApplication(owner.manifest)) {
|
|
32
34
|
return false;
|
|
33
35
|
}
|
|
34
|
-
const entryPoints =
|
|
36
|
+
const entryPoints = yield* Effect.promise(() => entryPointsOf(inputs, owner.directory, owner.manifest, new Map()));
|
|
35
37
|
const development = isTestCode(path) || isTooling(owner.directory, path);
|
|
36
38
|
return provider(entryPoints, name, development, true) !== undefined;
|
|
37
|
-
}
|
|
39
|
+
});
|
|
38
40
|
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
+
export const withoutEntryPointImports = Effect.fn("Biome.withoutEntryPointImports")(function* (
|
|
42
|
+
inputs: Pick<RuleInputs, "readText">,
|
|
43
|
+
diagnostics: readonly Diagnostic[],
|
|
44
|
+
) {
|
|
45
|
+
const covered = yield* Effect.forEach(diagnostics, (diagnostic) => brought(inputs, diagnostic), { concurrency: "unbounded" });
|
|
41
46
|
return diagnostics.filter((_, index) => !covered[index]);
|
|
42
|
-
}
|
|
47
|
+
});
|
package/src/cli/fixRule.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { plural } from "#report/plural.ts";
|
|
|
9
9
|
import type { RuleServices } from "#rule.ts";
|
|
10
10
|
|
|
11
11
|
const GROUPED =
|
|
12
|
-
"Consecutive assertions stop on the first failure; outcomes
|
|
12
|
+
"Consecutive assertions stop on the first failure; outcomes constructs rows eagerly, then lazily invokes each readout callback in row order before the grouped assertion. Rewrite these stories by hand to review that change in evaluation and failure order.";
|
|
13
13
|
|
|
14
14
|
export const fixRule = Effect.fn("Cli.fixRule")(function* (
|
|
15
15
|
cwd: string,
|
package/src/config/globs.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
|
-
import
|
|
2
|
+
import { matchesIgnorePattern } from "#adapters/ignore.ts";
|
|
3
3
|
|
|
4
4
|
const GlobDeclaration = Schema.Struct({
|
|
5
5
|
glob: Schema.NonEmptyString,
|
|
@@ -14,11 +14,6 @@ export function globPatterns(declarations: readonly (typeof GlobDeclaration.Type
|
|
|
14
14
|
return declarations.map(({ glob }) => glob);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function matchesIgnorePattern(file: string, glob: string): boolean {
|
|
18
|
-
const result = ignore().add(glob).test(file);
|
|
19
|
-
return result.ignored || result.unignored;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
17
|
export function validateGlobs(
|
|
23
18
|
{ files, options }: { readonly files: readonly string[]; readonly options: GlobOptions },
|
|
24
19
|
matches: (file: string, glob: string) => boolean = matchesIgnorePattern,
|
package/src/config/load.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { Effect, type FileSystem, Schema } from "effect";
|
|
3
|
+
import { readConfig } from "#adapters/readConfig.ts";
|
|
4
4
|
import { validOrFail } from "#decoded.ts";
|
|
5
5
|
import type { ExceptionDeclaration } from "#exceptions/declaration.ts";
|
|
6
|
-
import { SetupFailure } from "#failure.ts";
|
|
6
|
+
import type { SetupFailure } from "#failure.ts";
|
|
7
7
|
import type { InventoryScope } from "#inventory/collect.ts";
|
|
8
8
|
import { ConsumerDeclaration } from "#rules/suppressions/biome/ConsumerDeclaration.ts";
|
|
9
9
|
import type { Declaration } from "#rules/suppressions/biome/declarations.ts";
|
|
10
|
-
import {
|
|
10
|
+
import { DEFAULT_EXTENSIONS } from "./constants.ts";
|
|
11
11
|
import { type ConfigInput, decodeConfig } from "./decode.ts";
|
|
12
12
|
import { type ResolvedRules, resolveRules } from "./resolve.ts";
|
|
13
13
|
|
|
@@ -20,23 +20,6 @@ export interface ResolvedConfig extends ResolvedRules, InventoryScope {
|
|
|
20
20
|
readonly root: string;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
function messageOf(cause: unknown): string {
|
|
24
|
-
return cause instanceof Error ? cause.message : String(cause);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function importDefault(file: string): Effect.Effect<unknown, SetupFailure> {
|
|
28
|
-
return Effect.flatMap(
|
|
29
|
-
Effect.tryPromise({
|
|
30
|
-
catch: (cause) => new SetupFailure({ cause, message: `cannot load ${file}: ${messageOf(cause)}` }),
|
|
31
|
-
try: async (): Promise<unknown> => import(pathToFileURL(file).href),
|
|
32
|
-
}),
|
|
33
|
-
(loaded) =>
|
|
34
|
-
typeof loaded === "object" && loaded !== null && "default" in loaded
|
|
35
|
-
? Effect.succeed(loaded.default)
|
|
36
|
-
: Effect.fail(new SetupFailure({ message: `${file} has no default export. Export defineConfig({ ... }) as the default.` })),
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
23
|
const LegacyOptions = Schema.Struct({ declared: Schema.Array(ConsumerDeclaration) });
|
|
41
24
|
function biomeDeclarations(config: ConfigInput): readonly Declaration[] {
|
|
42
25
|
const setting = config.rules?.["suppressions/biome-overrides"];
|
|
@@ -63,22 +46,7 @@ export const loadConfig = Effect.fn("Config.loadConfig")(function* (
|
|
|
63
46
|
cwd: string,
|
|
64
47
|
path: string | undefined,
|
|
65
48
|
): Effect.fn.Return<ResolvedConfig, SetupFailure, FileSystem.FileSystem> {
|
|
66
|
-
const
|
|
67
|
-
const file = resolve(cwd, path ?? CONFIG_FILE);
|
|
68
|
-
const entries = yield* fs
|
|
69
|
-
.readDirectory(dirname(file))
|
|
70
|
-
.pipe(
|
|
71
|
-
Effect.catchTag("PlatformError", (error) =>
|
|
72
|
-
error.reason._tag === "NotFound"
|
|
73
|
-
? Effect.succeed<string[]>([])
|
|
74
|
-
: Effect.fail(new SetupFailure({ cause: error, message: `cannot inspect ${file}: ${error.message}` })),
|
|
75
|
-
),
|
|
76
|
-
);
|
|
77
|
-
const present = entries.includes(basename(file));
|
|
78
|
-
if (!present && path !== undefined) {
|
|
79
|
-
return yield* new SetupFailure({ message: `no config at ${file}. Check the --config path.` });
|
|
80
|
-
}
|
|
81
|
-
const loaded = present ? yield* importDefault(file) : {};
|
|
49
|
+
const { file, loaded } = yield* readConfig(cwd, path);
|
|
82
50
|
const config = yield* validOrFail(file, yield* Effect.promise(() => decodeConfig(loaded)));
|
|
83
51
|
const rules = yield* validOrFail(file, yield* resolveRules(config));
|
|
84
52
|
return resolved(dirname(file), file, config, rules);
|
|
@@ -7,7 +7,7 @@ import type { Environment } from "vitest/runtime";
|
|
|
7
7
|
// Resolve the DOM plugin from the consumer; depending on test-story would cycle through its Quality tooling.
|
|
8
8
|
const consumer = createRequire(join(process.cwd(), "package.json"));
|
|
9
9
|
const { default: environment }: { readonly default: Environment } = await import(
|
|
10
|
-
pathToFileURL(consumer.resolve("@shivaedev/test-story/server/domEnvironment.config.ts")).href
|
|
10
|
+
pathToFileURL(consumer.resolve("@shivaedev/test-story/server/adapters/domEnvironment.config.ts")).href
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
export default environment;
|
|
@@ -18,7 +18,7 @@ export const staleBiomeExceptions = Effect.fn("Exceptions.staleBiomeExceptions")
|
|
|
18
18
|
entry.rules.includes("biome/files/includes") ? [{ ...entry, rules: ["biome/files/includes"] as const }] : [],
|
|
19
19
|
);
|
|
20
20
|
const report = yield* biomeReport(inputs.root, ["check", "--no-errors-on-unmatched"], exclusions, [...new Set(entries.map(({ file }) => file))]);
|
|
21
|
-
const diagnostics = yield*
|
|
21
|
+
const diagnostics = yield* withoutEntryPointImports(inputs, report.diagnostics);
|
|
22
22
|
return entries
|
|
23
23
|
.filter(({ file, rule }) => !diagnostics.some((diagnostic) => diagnostic.location.path === file && `biome/${diagnostic.category}` === rule))
|
|
24
24
|
.map(
|
|
@@ -29,19 +29,20 @@ export const staleBiomeExceptions = Effect.fn("Exceptions.staleBiomeExceptions")
|
|
|
29
29
|
);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
const missingBiomeFile = Effect.fn("Exceptions.missingBiomeFile")(function* (inputs: RuleInputs, file: string): Effect.fn.Return<readonly Finding[]> {
|
|
33
|
+
const text = yield* Effect.promise(() => inputs.readText(file));
|
|
34
|
+
return text === undefined
|
|
35
|
+
? [{ file, message: `This Biome exception names a missing file. Remove it from exceptions in ${inputs.configFile ?? "quality.config.ts"}.` }]
|
|
36
|
+
: [];
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const missingBiomeFiles = Effect.fn("Exceptions.missingBiomeFiles")(function* (inputs: RuleInputs) {
|
|
33
40
|
const paths = (inputs.exceptions ?? [])
|
|
34
41
|
.filter((entry) => entry.rules.some((rule) => rule.startsWith("biome/") && rule !== "biome/files/includes"))
|
|
35
42
|
.flatMap((entry) => entry.files);
|
|
36
|
-
const checked =
|
|
37
|
-
[...new Set(paths)].map(async (file) =>
|
|
38
|
-
(await inputs.readText(file)) === undefined
|
|
39
|
-
? [{ file, message: `This Biome exception names a missing file. Remove it from exceptions in ${inputs.configFile ?? "quality.config.ts"}.` }]
|
|
40
|
-
: [],
|
|
41
|
-
),
|
|
42
|
-
);
|
|
43
|
+
const checked = yield* Effect.forEach([...new Set(paths)], (file) => missingBiomeFile(inputs, file), { concurrency: "unbounded" });
|
|
43
44
|
return checked.flat();
|
|
44
|
-
}
|
|
45
|
+
});
|
|
45
46
|
|
|
46
47
|
export function biomeExceptionHint(files: readonly string[], rule: string, config = "quality.config.ts"): string {
|
|
47
48
|
const entry = { files, reason: "Explain why this exception is permanent.", rules: [`biome/${rule}`] };
|
package/src/inventory/collect.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join, relative } from "node:path";
|
|
2
2
|
import { Effect, FileSystem } from "effect";
|
|
3
|
-
import
|
|
3
|
+
import { ignorePatterns } from "#adapters/ignore.ts";
|
|
4
4
|
import type { SetupFailure } from "#failure.ts";
|
|
5
5
|
import { manifestsIn } from "#manifests/sorted.ts";
|
|
6
6
|
import type { RuleServices, SourceFile } from "#rule.ts";
|
|
@@ -48,7 +48,7 @@ export const collectInventory = Effect.fn("Inventory.collectInventory")(function
|
|
|
48
48
|
root: string,
|
|
49
49
|
scope: InventoryScope,
|
|
50
50
|
): Effect.fn.Return<Inventory, FilesystemFailure | SetupFailure, RuleServices> {
|
|
51
|
-
const excluded =
|
|
51
|
+
const excluded = ignorePatterns([...scope.exclude]);
|
|
52
52
|
const toolOwned = new Set(yield* shadcnFiles(root));
|
|
53
53
|
const zones = yield* Effect.forEach(scope.sources, (zone) => zoneFiles(root, zone), { concurrency: READ_CONCURRENCY });
|
|
54
54
|
const relativePaths = zones.flat().map((absolute) => posix(relative(root, absolute)));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { dirname, relative, resolve } from "node:path";
|
|
2
|
-
import
|
|
2
|
+
import { ignorePatterns } from "#adapters/ignore.ts";
|
|
3
3
|
|
|
4
4
|
export type Verdict = "ignored" | "kept" | "unknown";
|
|
5
5
|
|
|
6
6
|
interface IgnoreMatcher {
|
|
7
7
|
readonly base: string;
|
|
8
|
-
readonly rules: ReturnType<typeof
|
|
8
|
+
readonly rules: ReturnType<typeof ignorePatterns>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface IgnoreScope {
|
|
@@ -23,7 +23,7 @@ export function posix(path: string): string {
|
|
|
23
23
|
export function withIgnoreFile(scope: IgnoreScope, base: string, contents: string): IgnoreScope {
|
|
24
24
|
return {
|
|
25
25
|
boundary: scope.boundary,
|
|
26
|
-
matchers: [...scope.matchers, { base, rules:
|
|
26
|
+
matchers: [...scope.matchers, { base, rules: ignorePatterns(contents) }],
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
+
import { Effect } from "effect";
|
|
2
3
|
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
3
4
|
import type { RuleInputs } from "#rule.ts";
|
|
4
5
|
|
|
@@ -42,13 +43,19 @@ function runBy(directory: string, manifest: unknown): readonly string[] {
|
|
|
42
43
|
return [...commands, ...bins].map((target) => posix.join(directory, target));
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
export
|
|
46
|
+
export const packageLayout = Effect.fn("Naming.packageLayout")(function* ({
|
|
47
|
+
files,
|
|
48
|
+
readText,
|
|
49
|
+
}: Pick<RuleInputs, "files" | "readText">): Effect.fn.Return<PackageLayout> {
|
|
46
50
|
const directories = ["", ...files.filter((path) => posix.basename(path) === MANIFEST).map((path) => posix.dirname(path))];
|
|
47
|
-
const manifests =
|
|
48
|
-
[...new Set(directories)]
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
const manifests = yield* Effect.forEach(
|
|
52
|
+
[...new Set(directories)],
|
|
53
|
+
(directory) =>
|
|
54
|
+
Effect.map(
|
|
55
|
+
Effect.promise(() => readPackageManifest(readText, directory === "" ? MANIFEST : `${directory}/${MANIFEST}`)),
|
|
56
|
+
(manifest) => ({ directory: directory === "." ? "" : directory, manifest }),
|
|
57
|
+
),
|
|
58
|
+
{ concurrency: "unbounded" },
|
|
52
59
|
);
|
|
53
60
|
const present = manifests.filter((entry) => entry.manifest !== undefined);
|
|
54
61
|
const roots = present.map((entry) => entry.directory).toSorted((left, right) => right.length - left.length);
|
|
@@ -62,4 +69,4 @@ export async function packageLayout({ files, readText }: Pick<RuleInputs, "files
|
|
|
62
69
|
names,
|
|
63
70
|
scripts: new Set(present.flatMap(({ directory, manifest }) => runBy(directory, manifest))),
|
|
64
71
|
};
|
|
65
|
-
}
|
|
72
|
+
});
|
package/src/naming/testName.ts
CHANGED
package/src/rules/biome.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
+
import { PRESET, rootConfig } from "#adapters/biome/rootConfig.ts";
|
|
2
3
|
import { biomeReport, type Diagnostic, FAILING } from "#biome/report.ts";
|
|
3
4
|
import { withoutEntryPointImports } from "#biome/withoutEntryPointImports.ts";
|
|
4
5
|
import { defineRule, type Finding, type Rule, type RuleInputs } from "#rule.ts";
|
|
5
|
-
import { itemsOf, member, parseJsonc, textOf } from "#rules/suppressions/biome/json.ts";
|
|
6
|
-
|
|
7
|
-
export const PRESET = "@shivaedev/quality/biome/preset.json";
|
|
8
|
-
|
|
9
|
-
const ROOT_CONFIGS: readonly string[] = ["biome.json", "biome.jsonc"];
|
|
10
6
|
|
|
11
7
|
function messageOf(diagnostic: Diagnostic): string {
|
|
12
8
|
return diagnostic.category === "format" && diagnostic.message.startsWith("Formatter would have printed")
|
|
@@ -24,32 +20,19 @@ function findingOf(diagnostic: Diagnostic): Finding {
|
|
|
24
20
|
};
|
|
25
21
|
}
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
readonly path: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export async function rootConfig(readText: RuleInputs["readText"]): Promise<RootConfig> {
|
|
33
|
-
const texts = await Promise.all(ROOT_CONFIGS.map(async (path) => ({ path, text: await readText(path) })));
|
|
34
|
-
const found = texts.find((candidate) => candidate.text !== undefined);
|
|
35
|
-
const parsed = found?.text === undefined ? undefined : parseJsonc(found.path, found.text);
|
|
36
|
-
const extended = parsed?._tag === "Parsed" ? itemsOf(member(parsed.json, "extends")).map(textOf) : [];
|
|
37
|
-
return { extendsPreset: extended.includes(PRESET), path: found?.path ?? "biome.json" };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function presetFinding(readText: RuleInputs["readText"]): Promise<readonly Finding[]> {
|
|
41
|
-
const { extendsPreset, path } = await rootConfig(readText);
|
|
23
|
+
const presetFinding = Effect.fn("Biome.presetFinding")(function* (inputs: Pick<RuleInputs, "readText">) {
|
|
24
|
+
const { extendsPreset, path } = yield* Effect.promise(() => rootConfig(inputs.readText));
|
|
42
25
|
return extendsPreset ? [] : [{ file: path, message: `Extend "${PRESET}" from the root Biome config.`, subject: "preset" }];
|
|
43
|
-
}
|
|
26
|
+
});
|
|
44
27
|
|
|
45
28
|
const bridge = defineRule({
|
|
46
29
|
check: ({ exceptions, readText, root }) =>
|
|
47
30
|
Effect.gen(function* () {
|
|
48
|
-
const [preset, report] = yield* Effect.all([
|
|
31
|
+
const [preset, report] = yield* Effect.all([presetFinding({ readText }), biomeReport(root, ["check"], exceptions)], {
|
|
49
32
|
concurrency: "unbounded",
|
|
50
33
|
});
|
|
51
34
|
const failing = report.diagnostics.filter((diagnostic) => FAILING.has(diagnostic.severity));
|
|
52
|
-
return [...preset, ...(yield*
|
|
35
|
+
return [...preset, ...(yield* withoutEntryPointImports({ readText }, failing)).map(findingOf)];
|
|
53
36
|
}),
|
|
54
37
|
description:
|
|
55
38
|
"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.",
|
package/src/rules/builtIn.ts
CHANGED
|
@@ -7,9 +7,12 @@ import { noPrReference } from "#rules/comments/noPrReference.ts";
|
|
|
7
7
|
import { noTodo } from "#rules/comments/noTodo.ts";
|
|
8
8
|
import { docsReferences } from "#rules/docs/references.ts";
|
|
9
9
|
import { docsUnversionedInstalls } from "#rules/docs/unversionedInstalls.ts";
|
|
10
|
+
import { adapterImports } from "#rules/effect/adapterImports.ts";
|
|
10
11
|
import { effectBoundary } from "#rules/effect/boundary.ts";
|
|
11
12
|
import { failureHonesty } from "#rules/effect/failureHonesty.ts";
|
|
13
|
+
import { serviceIds } from "#rules/effect/serviceIds.ts";
|
|
12
14
|
import { serviceParameters } from "#rules/effect/serviceParameters.ts";
|
|
15
|
+
import { sharedErrorClasses } from "#rules/effect/sharedErrorClasses.ts";
|
|
13
16
|
import { distinctCase } from "#rules/files/distinctCase.ts";
|
|
14
17
|
import { folderNames } from "#rules/files/folderNames.ts";
|
|
15
18
|
import { namedAfterExport } from "#rules/files/namedAfterExport.ts";
|
|
@@ -23,15 +26,18 @@ import { noTestCode } from "#rules/imports/noTestCode.ts";
|
|
|
23
26
|
import { importsResolvable } from "#rules/imports/resolvable.ts";
|
|
24
27
|
import { importsRuntime } from "#rules/imports/runtime.ts";
|
|
25
28
|
import { jsxConditionals } from "#rules/react/jsxConditionals.ts";
|
|
29
|
+
import { adapterOnlyFakes } from "#rules/stories/adapterOnlyFakes.ts";
|
|
26
30
|
import { authSql } from "#rules/stories/authSql.ts";
|
|
27
31
|
import { domainOutcomes } from "#rules/stories/domainOutcomes.ts";
|
|
28
32
|
import { storyEngine } from "#rules/stories/engine.ts";
|
|
29
33
|
import { globalRetries } from "#rules/stories/globalRetries.ts";
|
|
30
34
|
import { groupedOutcomes } from "#rules/stories/groupedOutcomes.ts";
|
|
31
35
|
import { httpStatus } from "#rules/stories/httpStatus.ts";
|
|
36
|
+
import { importedChangeKeys } from "#rules/stories/importedChangeKeys.ts";
|
|
32
37
|
import { namedValues } from "#rules/stories/namedValues.ts";
|
|
33
38
|
import { noExpect } from "#rules/stories/noExpect.ts";
|
|
34
39
|
import { noLimitImports } from "#rules/stories/noLimitImports.ts";
|
|
40
|
+
import { queueReadouts } from "#rules/stories/queueReadouts.ts";
|
|
35
41
|
import { queueSql } from "#rules/stories/queueSql.ts";
|
|
36
42
|
import { storySetup } from "#rules/stories/setup.ts";
|
|
37
43
|
import { specHelpers } from "#rules/stories/specHelpers.ts";
|
|
@@ -57,9 +63,12 @@ import { unusedCode } from "./unusedCode.ts";
|
|
|
57
63
|
|
|
58
64
|
export const builtInRules = [
|
|
59
65
|
unusedCode,
|
|
66
|
+
adapterImports,
|
|
60
67
|
effectBoundary,
|
|
61
68
|
failureHonesty,
|
|
69
|
+
serviceIds,
|
|
62
70
|
serviceParameters,
|
|
71
|
+
sharedErrorClasses,
|
|
63
72
|
jsxConditionals,
|
|
64
73
|
maxLines,
|
|
65
74
|
maxDepth,
|
|
@@ -100,9 +109,12 @@ export const builtInRules = [
|
|
|
100
109
|
testsColocated,
|
|
101
110
|
storySetup,
|
|
102
111
|
storySpecs,
|
|
112
|
+
adapterOnlyFakes,
|
|
103
113
|
globalRetries,
|
|
104
114
|
storyEngine,
|
|
105
115
|
queueSql,
|
|
116
|
+
queueReadouts,
|
|
117
|
+
importedChangeKeys,
|
|
106
118
|
authSql,
|
|
107
119
|
noExpect,
|
|
108
120
|
specHelpers,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { outsideImportFindings } from "#adapters/outsideImportFindings.ts";
|
|
2
|
+
import { defineRule } from "#rule.ts";
|
|
3
|
+
|
|
4
|
+
export const adapterImports = defineRule({
|
|
5
|
+
check: outsideImportFindings,
|
|
6
|
+
description:
|
|
7
|
+
"Keep value imports of non-Effect runtime dependencies, peers, optional dependencies and Node builtins in adapters/. Type-only imports, workspace modules, test-support/ kits, Effect and @shivaedev packages and React in client/ folders are accepted. Move integrations into adapters/ and expose Effect values. No config exceptions or inline suppressions; baseline existing debt.",
|
|
8
|
+
id: "effect/adapter-imports",
|
|
9
|
+
registrable: false,
|
|
10
|
+
});
|
|
@@ -3,7 +3,7 @@ import ts from "typescript";
|
|
|
3
3
|
import { projectsFor } from "#adapters/imports/projects.ts";
|
|
4
4
|
import type { RuleInputs } from "#rule.ts";
|
|
5
5
|
|
|
6
|
-
export function effectProgram(inputs: RuleInputs, externalTypes = true): ts.Program {
|
|
6
|
+
export function effectProgram(inputs: RuleInputs, externalTypes = true, roots: readonly string[] = []): ts.Program {
|
|
7
7
|
const projectOf = projectsFor(inputs.root);
|
|
8
8
|
const options: ts.CompilerOptions = {
|
|
9
9
|
allowJs: true,
|
|
@@ -25,5 +25,5 @@ export function effectProgram(inputs: RuleInputs, externalTypes = true): ts.Prog
|
|
|
25
25
|
const project = projectOf(from);
|
|
26
26
|
return ts.resolveModuleName(name, from, project.typesOptions, host, project.typesCache).resolvedModule;
|
|
27
27
|
});
|
|
28
|
-
return ts.createProgram([...texts.keys()], options, host);
|
|
28
|
+
return ts.createProgram([...texts.keys(), ...roots], options, host);
|
|
29
29
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { serviceIdFindings } from "#adapters/serviceIdFindings.ts";
|
|
2
|
+
import { defineRule } from "#rule.ts";
|
|
3
|
+
|
|
4
|
+
export const serviceIds = defineRule({
|
|
5
|
+
check: serviceIdFindings,
|
|
6
|
+
description:
|
|
7
|
+
"Literal Context.Service, Context.Reference, defineService and RPC middleware ids in packages/<name>/ start with @shivaedev/<name>/. Prefix the id and update its references. Includes adapters and tests; computed ids and files outside packages/ are not checked. No config exceptions or inline suppressions.",
|
|
8
|
+
id: "effect/service-ids",
|
|
9
|
+
registrable: false,
|
|
10
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { sharedErrorFindings } from "#adapters/sharedErrorFindings.ts";
|
|
2
|
+
import { defineRule } from "#rule.ts";
|
|
3
|
+
|
|
4
|
+
export const sharedErrorClasses = defineRule({
|
|
5
|
+
check: sharedErrorFindings,
|
|
6
|
+
description:
|
|
7
|
+
"A tagged error with a tag exported by @shivaedev/errors must use that exported class. Import the shared class instead of declaring another error or subclass with its tag.",
|
|
8
|
+
id: "effect/shared-error-classes",
|
|
9
|
+
registrable: false,
|
|
10
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
-
import { Order, Schema } from "effect";
|
|
3
|
-
import
|
|
2
|
+
import { Effect, Order, Schema } from "effect";
|
|
3
|
+
import { type IgnoreMatcher, ignorePatterns } from "#adapters/ignore.ts";
|
|
4
4
|
import { GlobDeclarations, globPatterns, validateGlobs } from "#config/globs.ts";
|
|
5
5
|
import { nativeNames } from "#naming/nativeNames.ts";
|
|
6
6
|
import { packageLayout } from "#naming/packageLayout.ts";
|
|
@@ -50,11 +50,11 @@ function groupMessage(name: string): string | undefined {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
interface Context {
|
|
53
|
-
readonly content:
|
|
53
|
+
readonly content: IgnoreMatcher;
|
|
54
54
|
readonly names: ReadonlyMap<string, string>;
|
|
55
55
|
readonly native: ReadonlySet<string>;
|
|
56
56
|
readonly stems: ReadonlySet<string>;
|
|
57
|
-
readonly toolOwned:
|
|
57
|
+
readonly toolOwned: IgnoreMatcher;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
function messageFor(folder: string, context: Context): string | undefined {
|
|
@@ -73,20 +73,21 @@ function messageFor(folder: string, context: Context): string | undefined {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export const folderNames = defineRule({
|
|
76
|
-
check:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
check: ({ files, options, readText }) =>
|
|
77
|
+
Effect.gen(function* () {
|
|
78
|
+
const layout = yield* packageLayout({ files, readText });
|
|
79
|
+
const context: Context = {
|
|
80
|
+
content: ignorePatterns([...globPatterns(options.content)]),
|
|
81
|
+
names: layout.names,
|
|
82
|
+
native: nativeNames(files).folders,
|
|
83
|
+
stems: stemsIn(files),
|
|
84
|
+
toolOwned: ignorePatterns([...globPatterns(options.toolOwned)]),
|
|
85
|
+
};
|
|
86
|
+
return foldersIn(files).flatMap((folder): readonly Finding[] => {
|
|
87
|
+
const message = messageFor(folder, context);
|
|
88
|
+
return message === undefined ? [] : [{ file: folder, message }];
|
|
89
|
+
});
|
|
90
|
+
}),
|
|
90
91
|
description:
|
|
91
92
|
"A package folder is named after its package, a module folder after its main file, a content folder in snake_case and every other folder in kebab-case.",
|
|
92
93
|
id: "files/folder-names",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
import
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
import { ignorePatterns } from "#adapters/ignore.ts";
|
|
4
4
|
import { GlobDeclarations, globPatterns, validateGlobs } from "#config/globs.ts";
|
|
5
5
|
import { exportFits } from "#naming/exportFits.ts";
|
|
6
6
|
import { mainExport } from "#naming/mainExport.ts";
|
|
@@ -89,13 +89,14 @@ function findingsOf(file: SourceFile, layout: PackageLayout): readonly Finding[]
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export const namedAfterExport = defineRule({
|
|
92
|
-
check:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
check: ({ files, options, readText, sources }) =>
|
|
93
|
+
Effect.gen(function* () {
|
|
94
|
+
const layout = yield* packageLayout({ files, readText });
|
|
95
|
+
const toolOwned = ignorePatterns([...DEFAULT_TOOL_OWNED, ...globPatterns(options.toolOwned)]);
|
|
96
|
+
return sources
|
|
97
|
+
.filter((file) => !(TEST.test(file.path) || isMigrationFile(file.path) || toolOwned.ignores(file.path)))
|
|
98
|
+
.flatMap((file) => findingsOf(file, layout));
|
|
99
|
+
}),
|
|
99
100
|
description:
|
|
100
101
|
"A file is named after its main export or a module-level constant, including a private constant, with its folders as the prefix; module client/admin and server/admin files may repeat names from above the admin folder. A file of several exports is a camelCase topic file, and a script is kebab-case. Rename the file or the export; nothing renames them for you.",
|
|
101
102
|
id: "files/named-after-export",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
import
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
import { type IgnoreMatcher, ignorePatterns } from "#adapters/ignore.ts";
|
|
4
4
|
import { GlobDeclarations, globPatterns, validateGlobs } from "#config/globs.ts";
|
|
5
5
|
import { nativeNames } from "#naming/nativeNames.ts";
|
|
6
6
|
import { CAMEL, KEBAB } from "#naming/words.ts";
|
|
@@ -54,10 +54,10 @@ function stylesheetMessage(path: string, stem: string, importedBy: readonly stri
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
interface Context {
|
|
57
|
-
readonly content:
|
|
57
|
+
readonly content: IgnoreMatcher;
|
|
58
58
|
readonly native: ReturnType<typeof nativeNames>;
|
|
59
59
|
readonly stylesheets: ReadonlyMap<string, readonly string[]>;
|
|
60
|
-
readonly toolOwned:
|
|
60
|
+
readonly toolOwned: IgnoreMatcher;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
function messageFor(path: string, context: Context): string | undefined {
|
|
@@ -87,18 +87,19 @@ function messageFor(path: string, context: Context): string | undefined {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export const otherNames = defineRule({
|
|
90
|
-
check:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
check: ({ files, options, readText, sources }) =>
|
|
91
|
+
Effect.gen(function* () {
|
|
92
|
+
const context: Context = {
|
|
93
|
+
content: ignorePatterns([...globPatterns(options.content)]),
|
|
94
|
+
native: nativeNames(files),
|
|
95
|
+
stylesheets: yield* stylesheetImporters({ files, readText, sources }),
|
|
96
|
+
toolOwned: ignorePatterns([...DEFAULT_TOOL_OWNED, ...globPatterns(options.toolOwned)]),
|
|
97
|
+
};
|
|
98
|
+
return files.flatMap((path): readonly Finding[] => {
|
|
99
|
+
const message = messageFor(path, context);
|
|
100
|
+
return message === undefined ? [] : [{ file: path, message }];
|
|
101
|
+
});
|
|
102
|
+
}),
|
|
102
103
|
description:
|
|
103
104
|
"Documents, data, assets and GritQL files are kebab-case, a stylesheet that one component imports is named after it, a Prisma schema is camelCase and content is snake_case.",
|
|
104
105
|
id: "files/other-names",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
+
import { Effect } from "effect";
|
|
2
3
|
import { readPackageManifest } from "#adapters/manifestInventory.ts";
|
|
3
4
|
import type { RuleInputs } from "#rule.ts";
|
|
4
5
|
|
|
@@ -38,10 +39,19 @@ function matched(imports: unknown, specifier: string): readonly string[] {
|
|
|
38
39
|
return targetsIn(best.value).map((target) => target.replaceAll("*", star));
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
export
|
|
42
|
+
export const packageImports = Effect.fn("Files.packageImports")(function* ({
|
|
43
|
+
files,
|
|
44
|
+
readText,
|
|
45
|
+
}: Pick<RuleInputs, "files" | "readText">): Effect.fn.Return<PackageImports> {
|
|
42
46
|
const directories = files.filter((path) => posix.basename(path) === MANIFEST).map((path) => posix.dirname(path));
|
|
43
|
-
const manifests =
|
|
44
|
-
directories
|
|
47
|
+
const manifests = yield* Effect.forEach(
|
|
48
|
+
directories,
|
|
49
|
+
(directory) =>
|
|
50
|
+
Effect.map(
|
|
51
|
+
Effect.promise(() => readPackageManifest(readText, posix.join(directory, MANIFEST))),
|
|
52
|
+
(manifest) => ({ directory, imports: manifest?.imports }),
|
|
53
|
+
),
|
|
54
|
+
{ concurrency: "unbounded" },
|
|
45
55
|
);
|
|
46
56
|
const deepestFirst = manifests.toSorted((left, right) => right.directory.length - left.directory.length);
|
|
47
57
|
const present = new Set(files);
|
|
@@ -54,4 +64,4 @@ export async function packageImports({ files, readText }: Pick<RuleInputs, "file
|
|
|
54
64
|
.map((target) => posix.normalize(posix.join(owner.directory, target)))
|
|
55
65
|
.find((path) => present.has(path));
|
|
56
66
|
};
|
|
57
|
-
}
|
|
67
|
+
});
|