@shivaedev/quality 0.23.0 → 0.25.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 +18 -0
- package/README.md +6 -2
- package/dist/baseline/compare.d.ts +2 -2
- package/dist/baseline/compare.d.ts.map +1 -1
- package/dist/baseline/compare.js +6 -4
- package/dist/baseline/compare.js.map +1 -1
- package/dist/baseline/format.d.ts +5 -5
- package/dist/baseline/format.d.ts.map +1 -1
- package/dist/baseline/format.js +23 -13
- package/dist/baseline/format.js.map +1 -1
- package/dist/baseline/legacy.d.ts +2 -2
- package/dist/baseline/legacy.d.ts.map +1 -1
- package/dist/baseline/legacy.js +4 -4
- package/dist/baseline/legacy.js.map +1 -1
- package/dist/baseline/rewrite.d.ts +1 -1
- package/dist/baseline/rewrite.d.ts.map +1 -1
- package/dist/baseline/rewrite.js +2 -2
- package/dist/baseline/rewrite.js.map +1 -1
- package/dist/baseline/update.d.ts +2 -2
- package/dist/baseline/update.d.ts.map +1 -1
- package/dist/baseline/update.js +27 -21
- package/dist/baseline/update.js.map +1 -1
- package/dist/cli/args.d.ts +2 -4
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +19 -18
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/baseline.d.ts +1 -1
- package/dist/cli/baseline.d.ts.map +1 -1
- package/dist/cli/baseline.js +10 -6
- package/dist/cli/baseline.js.map +1 -1
- package/dist/cli/fix.d.ts +2 -2
- package/dist/cli/fix.d.ts.map +1 -1
- package/dist/cli/fix.js +35 -41
- package/dist/cli/fix.js.map +1 -1
- package/dist/cli/lint.d.ts +1 -2
- package/dist/cli/lint.d.ts.map +1 -1
- package/dist/cli/lint.js +1 -2
- 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 -2
- package/dist/cli/migrate.d.ts.map +1 -1
- package/dist/cli/migrate.js +2 -2
- package/dist/cli/migrate.js.map +1 -1
- package/dist/cli/migrateExceptions.js +1 -1
- package/dist/cli/migrateExceptions.js.map +1 -1
- package/dist/cli/program.js +1 -1
- package/dist/cli/program.js.map +1 -1
- package/dist/cli/{run-main.d.ts → runMain.d.ts} +1 -1
- package/dist/cli/runMain.d.ts.map +1 -0
- package/dist/cli/{run-main.js → runMain.js} +3 -3
- package/dist/cli/runMain.js.map +1 -0
- package/dist/cli/shrink.d.ts +2 -2
- package/dist/cli/shrink.d.ts.map +1 -1
- package/dist/cli/shrink.js +9 -3
- package/dist/cli/shrink.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.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 +13 -9
- package/dist/config/decode.js.map +1 -1
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +26 -20
- package/dist/config/load.js.map +1 -1
- package/dist/config/resolve.d.ts +23 -3
- package/dist/config/resolve.d.ts.map +1 -1
- package/dist/config/resolve.js +19 -11
- package/dist/config/resolve.js.map +1 -1
- package/dist/config.d.ts +3 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/decoded.d.ts +3 -3
- package/dist/decoded.d.ts.map +1 -1
- package/dist/decoded.js +8 -6
- package/dist/decoded.js.map +1 -1
- package/dist/engine/{baseline-file.d.ts → baselineFile.d.ts} +2 -2
- package/dist/engine/baselineFile.d.ts.map +1 -0
- package/dist/engine/{baseline-file.js → baselineFile.js} +5 -3
- package/dist/engine/baselineFile.js.map +1 -0
- package/dist/engine/evaluate.d.ts +2 -3
- package/dist/engine/evaluate.d.ts.map +1 -1
- package/dist/engine/evaluate.js +6 -5
- package/dist/engine/evaluate.js.map +1 -1
- package/dist/engine/{run-rules.d.ts → runRules.d.ts} +2 -2
- package/dist/engine/runRules.d.ts.map +1 -0
- package/dist/engine/runRules.js +44 -0
- package/dist/engine/runRules.js.map +1 -0
- package/dist/engine/session.d.ts +1 -1
- package/dist/engine/session.d.ts.map +1 -1
- package/dist/engine/session.js +10 -6
- package/dist/engine/session.js.map +1 -1
- package/dist/engine/violation.d.ts +8 -8
- package/dist/engine/violation.d.ts.map +1 -1
- package/dist/engine/violation.js +23 -11
- package/dist/engine/violation.js.map +1 -1
- package/dist/exceptions/registry.d.ts +2 -2
- package/dist/exceptions/registry.d.ts.map +1 -1
- package/dist/exceptions/registry.js +10 -6
- package/dist/exceptions/registry.js.map +1 -1
- package/dist/git/base.d.ts +1 -2
- package/dist/git/base.d.ts.map +1 -1
- package/dist/git/base.js +22 -10
- package/dist/git/base.js.map +1 -1
- package/dist/git/command.d.ts +2 -2
- package/dist/git/command.d.ts.map +1 -1
- package/dist/git/command.js +13 -9
- package/dist/git/command.js.map +1 -1
- package/dist/git/history.d.ts +1 -1
- package/dist/git/history.d.ts.map +1 -1
- package/dist/git/history.js +5 -3
- package/dist/git/history.js.map +1 -1
- package/dist/hooks/preCommit.js +1 -1
- package/dist/hooks/preCommit.js.map +1 -1
- package/dist/imports/generated.js +1 -1
- package/dist/imports/generated.js.map +1 -1
- package/dist/imports/{pnpm-workspace.d.ts → pnpmWorkspacePatterns.d.ts} +1 -1
- package/dist/imports/pnpmWorkspacePatterns.d.ts.map +1 -0
- package/dist/imports/{pnpm-workspace.js → pnpmWorkspacePatterns.js} +1 -1
- package/dist/imports/pnpmWorkspacePatterns.js.map +1 -0
- package/dist/imports/resolve.js +1 -1
- package/dist/imports/resolve.js.map +1 -1
- package/dist/imports/workspace.js +1 -1
- package/dist/imports/workspace.js.map +1 -1
- package/dist/inventory/collect.d.ts +1 -1
- package/dist/inventory/collect.d.ts.map +1 -1
- package/dist/inventory/collect.js +8 -6
- package/dist/inventory/collect.js.map +1 -1
- package/dist/inventory/filesystem.d.ts +1 -1
- package/dist/inventory/filesystem.d.ts.map +1 -1
- package/dist/inventory/filesystem.js +11 -7
- package/dist/inventory/filesystem.js.map +1 -1
- package/dist/inventory/ignoreScope.d.ts +17 -0
- package/dist/inventory/ignoreScope.d.ts.map +1 -0
- package/dist/inventory/{ignore-scope.js → ignoreScope.js} +19 -10
- package/dist/inventory/ignoreScope.js.map +1 -0
- package/dist/inventory/walk.d.ts +1 -1
- package/dist/inventory/walk.d.ts.map +1 -1
- package/dist/inventory/walk.js +1 -1
- package/dist/inventory/walk.js.map +1 -1
- package/dist/manifests/sorted.d.ts +1 -1
- package/dist/manifests/sorted.d.ts.map +1 -1
- package/dist/manifests/sorted.js +15 -17
- package/dist/manifests/sorted.js.map +1 -1
- package/dist/report/plural.d.ts +1 -1
- package/dist/report/plural.d.ts.map +1 -1
- package/dist/report/plural.js +3 -1
- package/dist/report/plural.js.map +1 -1
- package/dist/report/render.d.ts +1 -3
- package/dist/report/render.d.ts.map +1 -1
- package/dist/report/render.js +30 -32
- package/dist/report/render.js.map +1 -1
- package/dist/report/stale.d.ts +1 -1
- package/dist/report/stale.d.ts.map +1 -1
- package/dist/report/stale.js +18 -8
- package/dist/report/stale.js.map +1 -1
- package/dist/rule.d.ts +14 -14
- package/dist/rule.d.ts.map +1 -1
- package/dist/rule.js +11 -9
- package/dist/rule.js.map +1 -1
- package/dist/rules/{built-in.d.ts → builtIn.d.ts} +3 -3
- package/dist/rules/builtIn.d.ts.map +1 -0
- package/dist/rules/{built-in.js → builtIn.js} +17 -13
- package/dist/rules/builtIn.js.map +1 -0
- package/dist/rules/comments/{pattern-rule.d.ts → definePattern.d.ts} +2 -2
- package/dist/rules/comments/definePattern.d.ts.map +1 -0
- package/dist/rules/comments/definePattern.js +18 -0
- package/dist/rules/comments/definePattern.js.map +1 -0
- package/dist/rules/comments/kinds.d.ts +4 -4
- package/dist/rules/comments/kinds.d.ts.map +1 -1
- package/dist/rules/comments/kinds.js +16 -8
- package/dist/rules/comments/kinds.js.map +1 -1
- package/dist/rules/comments/{max-per-file.d.ts → maxPerFile.d.ts} +1 -1
- package/dist/rules/comments/maxPerFile.d.ts.map +1 -0
- package/dist/rules/comments/{max-per-file.js → maxPerFile.js} +14 -10
- package/dist/rules/comments/maxPerFile.js.map +1 -0
- package/dist/rules/comments/{no-banner.d.ts → noBanner.d.ts} +1 -1
- package/dist/rules/comments/noBanner.d.ts.map +1 -0
- package/dist/rules/comments/{no-banner.js → noBanner.js} +2 -2
- package/dist/rules/comments/noBanner.js.map +1 -0
- package/dist/rules/comments/{no-environment-pragma.d.ts → noEnvironmentPragma.d.ts} +1 -1
- package/dist/rules/comments/noEnvironmentPragma.d.ts.map +1 -0
- package/dist/rules/comments/{no-environment-pragma.js → noEnvironmentPragma.js} +2 -2
- package/dist/rules/comments/noEnvironmentPragma.js.map +1 -0
- package/dist/rules/comments/{no-jsdoc.d.ts → noJsdoc.d.ts} +1 -1
- package/dist/rules/comments/noJsdoc.d.ts.map +1 -0
- package/dist/rules/comments/{no-jsdoc.js → noJsdoc.js} +1 -1
- package/dist/rules/comments/noJsdoc.js.map +1 -0
- package/dist/rules/comments/{no-line-reference.d.ts → noLineReference.d.ts} +1 -1
- package/dist/rules/comments/noLineReference.d.ts.map +1 -0
- package/dist/rules/comments/{no-line-reference.js → noLineReference.js} +2 -2
- package/dist/rules/comments/noLineReference.js.map +1 -0
- package/dist/rules/comments/{no-pr-reference.d.ts → noPrReference.d.ts} +1 -1
- package/dist/rules/comments/noPrReference.d.ts.map +1 -0
- package/dist/rules/comments/{no-pr-reference.js → noPrReference.js} +2 -2
- package/dist/rules/comments/noPrReference.js.map +1 -0
- package/dist/rules/comments/{no-todo.d.ts → noTodo.d.ts} +1 -1
- package/dist/rules/comments/noTodo.d.ts.map +1 -0
- package/dist/rules/comments/{no-todo.js → noTodo.js} +2 -2
- package/dist/rules/comments/noTodo.js.map +1 -0
- package/dist/rules/comments/scan.d.ts +3 -3
- package/dist/rules/comments/scan.d.ts.map +1 -1
- package/dist/rules/comments/scan.js +23 -19
- package/dist/rules/comments/scan.js.map +1 -1
- package/dist/rules/{manifests-sorted.d.ts → manifestsSorted.d.ts} +1 -1
- package/dist/rules/manifestsSorted.d.ts.map +1 -0
- package/dist/rules/{manifests-sorted.js → manifestsSorted.js} +1 -1
- package/dist/rules/manifestsSorted.js.map +1 -0
- package/dist/rules/manifestsSourceFirst.d.ts +2 -0
- package/dist/rules/manifestsSourceFirst.d.ts.map +1 -0
- package/dist/rules/manifestsSourceFirst.js +43 -0
- package/dist/rules/manifestsSourceFirst.js.map +1 -0
- package/dist/rules/{max-lines.d.ts → maxLines.d.ts} +1 -1
- package/dist/rules/maxLines.d.ts.map +1 -0
- package/dist/rules/{max-lines.js → maxLines.js} +13 -11
- package/dist/rules/maxLines.js.map +1 -0
- package/dist/rules/stories/origins.d.ts +10 -0
- package/dist/rules/stories/origins.d.ts.map +1 -0
- package/dist/rules/stories/origins.js +129 -0
- package/dist/rules/stories/origins.js.map +1 -0
- package/dist/rules/stories/prerequisites.d.ts +4 -0
- package/dist/rules/stories/prerequisites.d.ts.map +1 -0
- package/dist/rules/stories/prerequisites.js +32 -0
- package/dist/rules/stories/prerequisites.js.map +1 -0
- package/dist/rules/stories/program.d.ts +5 -0
- package/dist/rules/stories/program.d.ts.map +1 -0
- package/dist/rules/stories/program.js +22 -0
- package/dist/rules/stories/program.js.map +1 -0
- package/dist/rules/stories/specs.d.ts +2 -0
- package/dist/rules/stories/specs.d.ts.map +1 -0
- package/dist/rules/stories/specs.js +80 -0
- package/dist/rules/stories/specs.js.map +1 -0
- package/dist/rules/suppressions/biome/configs.d.ts +1 -1
- package/dist/rules/suppressions/biome/configs.d.ts.map +1 -1
- package/dist/rules/suppressions/biome/configs.js +23 -17
- package/dist/rules/suppressions/biome/configs.js.map +1 -1
- package/dist/rules/suppressions/biome/declarations.d.ts +4 -4
- package/dist/rules/suppressions/biome/declarations.d.ts.map +1 -1
- package/dist/rules/suppressions/biome/declarations.js +15 -7
- package/dist/rules/suppressions/biome/declarations.js.map +1 -1
- package/dist/rules/suppressions/biome/json.d.ts +6 -6
- package/dist/rules/suppressions/biome/json.d.ts.map +1 -1
- package/dist/rules/suppressions/biome/json.js +27 -13
- package/dist/rules/suppressions/biome/json.js.map +1 -1
- package/dist/rules/suppressions/biome/resolve.d.ts +1 -1
- package/dist/rules/suppressions/biome/resolve.d.ts.map +1 -1
- package/dist/rules/suppressions/biome/resolve.js +23 -17
- package/dist/rules/suppressions/biome/resolve.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/biome/weakenings.js +78 -52
- package/dist/rules/suppressions/biome/weakenings.js.map +1 -1
- package/dist/rules/suppressions/{biome-overrides.d.ts → biomeOverrides.d.ts} +1 -1
- package/dist/rules/suppressions/biomeOverrides.d.ts.map +1 -0
- package/dist/rules/suppressions/biomeOverrides.js +75 -0
- package/dist/rules/suppressions/biomeOverrides.js.map +1 -0
- package/dist/rules/suppressions/directives.d.ts +1 -1
- package/dist/rules/suppressions/directives.d.ts.map +1 -1
- package/dist/rules/suppressions/directives.js +5 -3
- package/dist/rules/suppressions/directives.js.map +1 -1
- package/dist/rules/suppressions/{no-double-cast.d.ts → noDoubleCast.d.ts} +1 -1
- package/dist/rules/suppressions/noDoubleCast.d.ts.map +1 -0
- package/dist/rules/suppressions/{no-double-cast.js → noDoubleCast.js} +15 -11
- package/dist/rules/suppressions/noDoubleCast.js.map +1 -0
- package/dist/rules/suppressions/noIgnoreDeprecations.js +1 -1
- package/dist/rules/suppressions/noIgnoreDeprecations.js.map +1 -1
- package/dist/rules/suppressions/{no-inline.d.ts → noInline.d.ts} +1 -1
- package/dist/rules/suppressions/noInline.d.ts.map +1 -0
- package/dist/rules/suppressions/{no-inline.js → noInline.js} +10 -8
- package/dist/rules/suppressions/noInline.js.map +1 -0
- package/dist/rules/suppressions/stylesheetComments.d.ts +4 -0
- package/dist/rules/suppressions/stylesheetComments.d.ts.map +1 -0
- package/dist/rules/suppressions/{stylesheet-comments.js → stylesheetComments.js} +12 -6
- package/dist/rules/suppressions/stylesheetComments.js.map +1 -0
- package/dist/rules/syntax.d.ts +1 -1
- package/dist/rules/syntax.d.ts.map +1 -1
- package/dist/rules/syntax.js +2 -2
- package/dist/rules/syntax.js.map +1 -1
- package/dist/{standard-schema.d.ts → standardSchema.d.ts} +7 -7
- package/dist/standardSchema.d.ts.map +1 -0
- package/dist/{standard-schema.js → standardSchema.js} +1 -1
- package/dist/standardSchema.js.map +1 -0
- package/docs/debt-and-hooks.md +2 -2
- package/docs/modules.md +27 -24
- package/docs/roadmap.md +1 -1
- package/docs/rules.md +2 -0
- package/package.json +2 -3
- package/src/baseline/compare.ts +6 -4
- package/src/baseline/format.ts +17 -10
- package/src/baseline/legacy.ts +4 -4
- package/src/baseline/rewrite.ts +2 -2
- package/src/baseline/update.ts +23 -19
- package/src/cli/args.ts +20 -21
- package/src/cli/baseline.ts +36 -35
- package/src/cli/fix.ts +40 -43
- package/src/cli/lint.ts +17 -21
- package/src/cli/messages.ts +2 -2
- package/src/cli/migrate.ts +21 -22
- package/src/cli/migrateExceptions.ts +1 -1
- package/src/cli/program.ts +1 -1
- package/src/cli/{run-main.ts → runMain.ts} +2 -2
- package/src/cli/shrink.ts +11 -8
- package/src/cli.ts +1 -1
- package/src/config/decode.ts +15 -10
- package/src/config/load.ts +44 -37
- package/src/config/resolve.ts +34 -29
- package/src/config.ts +5 -3
- package/src/decoded.ts +6 -5
- package/src/engine/baselineFile.ts +29 -0
- package/src/engine/evaluate.ts +7 -8
- package/src/engine/{run-rules.ts → runRules.ts} +22 -14
- package/src/engine/session.ts +34 -27
- package/src/engine/violation.ts +24 -13
- package/src/exceptions/registry.ts +10 -8
- package/src/git/base.ts +45 -37
- package/src/git/command.ts +6 -4
- package/src/git/history.ts +5 -4
- package/src/hooks/preCommit.ts +1 -1
- package/src/imports/generated.ts +1 -1
- package/src/imports/resolve.ts +1 -1
- package/src/imports/workspace.ts +1 -1
- package/src/inventory/collect.ts +40 -35
- package/src/inventory/filesystem.ts +38 -30
- package/src/inventory/{ignore-scope.ts → ignoreScope.ts} +20 -10
- package/src/inventory/walk.ts +1 -1
- package/src/manifests/sorted.ts +19 -19
- package/src/report/plural.ts +3 -1
- package/src/report/render.ts +24 -39
- package/src/report/stale.ts +33 -25
- package/src/rule.ts +26 -20
- package/src/rules/{built-in.ts → builtIn.ts} +16 -12
- package/src/rules/comments/{pattern-rule.ts → definePattern.ts} +5 -4
- package/src/rules/comments/kinds.ts +16 -9
- package/src/rules/comments/{max-per-file.ts → maxPerFile.ts} +15 -11
- package/src/rules/comments/{no-banner.ts → noBanner.ts} +1 -1
- package/src/rules/comments/{no-environment-pragma.ts → noEnvironmentPragma.ts} +1 -1
- package/src/rules/comments/{no-line-reference.ts → noLineReference.ts} +1 -1
- package/src/rules/comments/{no-pr-reference.ts → noPrReference.ts} +1 -1
- package/src/rules/comments/{no-todo.ts → noTodo.ts} +1 -1
- package/src/rules/comments/scan.ts +18 -15
- package/src/rules/manifestsSourceFirst.ts +48 -0
- package/src/rules/{max-lines.ts → maxLines.ts} +3 -2
- package/src/rules/stories/origins.ts +147 -0
- package/src/rules/stories/prerequisites.ts +37 -0
- package/src/rules/stories/program.ts +29 -0
- package/src/rules/stories/specs.ts +93 -0
- package/src/rules/suppressions/biome/configs.ts +23 -17
- package/src/rules/suppressions/biome/declarations.ts +15 -10
- package/src/rules/suppressions/biome/json.ts +25 -13
- package/src/rules/suppressions/biome/resolve.ts +23 -18
- package/src/rules/suppressions/biome/weakenings.ts +60 -41
- package/src/rules/suppressions/{biome-overrides.ts → biomeOverrides.ts} +32 -22
- package/src/rules/suppressions/directives.ts +5 -4
- package/src/rules/suppressions/{no-double-cast.ts → noDoubleCast.ts} +14 -10
- package/src/rules/suppressions/noIgnoreDeprecations.ts +1 -1
- package/src/rules/suppressions/{no-inline.ts → noInline.ts} +6 -5
- package/src/rules/suppressions/{stylesheet-comments.ts → stylesheetComments.ts} +11 -6
- package/src/rules/syntax.ts +2 -2
- package/src/{standard-schema.ts → standardSchema.ts} +4 -4
- package/dist/cli/run-main.d.ts.map +0 -1
- package/dist/cli/run-main.js.map +0 -1
- package/dist/engine/baseline-file.d.ts.map +0 -1
- package/dist/engine/baseline-file.js.map +0 -1
- package/dist/engine/run-rules.d.ts.map +0 -1
- package/dist/engine/run-rules.js +0 -34
- package/dist/engine/run-rules.js.map +0 -1
- package/dist/imports/pnpm-workspace.d.ts.map +0 -1
- package/dist/imports/pnpm-workspace.js.map +0 -1
- package/dist/inventory/ignore-scope.d.ts +0 -17
- package/dist/inventory/ignore-scope.d.ts.map +0 -1
- package/dist/inventory/ignore-scope.js.map +0 -1
- package/dist/rules/built-in.d.ts.map +0 -1
- package/dist/rules/built-in.js.map +0 -1
- package/dist/rules/comments/max-per-file.d.ts.map +0 -1
- package/dist/rules/comments/max-per-file.js.map +0 -1
- package/dist/rules/comments/no-banner.d.ts.map +0 -1
- package/dist/rules/comments/no-banner.js.map +0 -1
- package/dist/rules/comments/no-environment-pragma.d.ts.map +0 -1
- package/dist/rules/comments/no-environment-pragma.js.map +0 -1
- package/dist/rules/comments/no-jsdoc.d.ts.map +0 -1
- package/dist/rules/comments/no-jsdoc.js.map +0 -1
- package/dist/rules/comments/no-line-reference.d.ts.map +0 -1
- package/dist/rules/comments/no-line-reference.js.map +0 -1
- package/dist/rules/comments/no-pr-reference.d.ts.map +0 -1
- package/dist/rules/comments/no-pr-reference.js.map +0 -1
- package/dist/rules/comments/no-todo.d.ts.map +0 -1
- package/dist/rules/comments/no-todo.js.map +0 -1
- package/dist/rules/comments/pattern-rule.d.ts.map +0 -1
- package/dist/rules/comments/pattern-rule.js +0 -16
- package/dist/rules/comments/pattern-rule.js.map +0 -1
- package/dist/rules/manifests-sorted.d.ts.map +0 -1
- package/dist/rules/manifests-sorted.js.map +0 -1
- package/dist/rules/max-lines.d.ts.map +0 -1
- package/dist/rules/max-lines.js.map +0 -1
- package/dist/rules/suppressions/biome-overrides.d.ts.map +0 -1
- package/dist/rules/suppressions/biome-overrides.js +0 -63
- package/dist/rules/suppressions/biome-overrides.js.map +0 -1
- package/dist/rules/suppressions/no-double-cast.d.ts.map +0 -1
- package/dist/rules/suppressions/no-double-cast.js.map +0 -1
- package/dist/rules/suppressions/no-inline.d.ts.map +0 -1
- package/dist/rules/suppressions/no-inline.js.map +0 -1
- package/dist/rules/suppressions/stylesheet-comments.d.ts +0 -4
- package/dist/rules/suppressions/stylesheet-comments.d.ts.map +0 -1
- package/dist/rules/suppressions/stylesheet-comments.js.map +0 -1
- package/dist/standard-schema.d.ts.map +0 -1
- package/dist/standard-schema.js.map +0 -1
- package/src/engine/baseline-file.ts +0 -27
- /package/src/imports/{pnpm-workspace.ts → pnpmWorkspacePatterns.ts} +0 -0
- /package/src/rules/comments/{no-jsdoc.ts → noJsdoc.ts} +0 -0
- /package/src/rules/{manifests-sorted.ts → manifestsSorted.ts} +0 -0
package/src/git/base.ts
CHANGED
|
@@ -9,54 +9,62 @@ export interface Base {
|
|
|
9
9
|
|
|
10
10
|
const FALLBACK_BRANCHES = ["origin/main", "origin/master"];
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
function fail(message: string) {
|
|
13
|
+
return Effect.fail(new SetupFailure({ message }));
|
|
14
|
+
}
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
Effect.map(git(root, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]), (result) => result.code === 0);
|
|
16
|
+
function isCommit(root: string, ref: string): Effect.Effect<boolean, SetupFailure, Git> {
|
|
17
|
+
return Effect.map(git(root, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]), (result) => result.code === 0);
|
|
18
|
+
}
|
|
16
19
|
|
|
17
|
-
const defaultBranch = (root: string): Effect.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return candidate;
|
|
26
|
-
}
|
|
20
|
+
const defaultBranch = Effect.fn("Git.defaultBranch")(function* (root: string): Effect.fn.Return<string, SetupFailure, Git> {
|
|
21
|
+
const head = yield* git(root, ["symbolic-ref", "--quiet", "--short", "refs/remotes/origin/HEAD"]);
|
|
22
|
+
if (head.code === 0) {
|
|
23
|
+
return head.stdout.trim();
|
|
24
|
+
}
|
|
25
|
+
for (const candidate of FALLBACK_BRANCHES) {
|
|
26
|
+
if (yield* isCommit(root, candidate)) {
|
|
27
|
+
return candidate;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
}
|
|
30
|
+
return yield* fail(
|
|
31
|
+
"cannot find the default branch: origin/HEAD, origin/main and origin/master are missing. Pass --against <ref>, or run `git remote set-head origin --auto`.",
|
|
32
|
+
);
|
|
33
|
+
});
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
Effect.map(git(root, ["rev-parse", "--is-shallow-repository"]), (result) => result.stdout.trim() === "true");
|
|
35
|
+
function isShallow(root: string): Effect.Effect<boolean, SetupFailure, Git> {
|
|
36
|
+
return Effect.map(git(root, ["rev-parse", "--is-shallow-repository"]), (result) => result.stdout.trim() === "true");
|
|
37
|
+
}
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
Effect.map(git(root, ["merge-base", "HEAD", ref]), (result) => (result.code === 0 ? result.stdout.trim() : undefined));
|
|
39
|
+
function mergeBase(root: string, ref: string): Effect.Effect<string | undefined, SetupFailure, Git> {
|
|
40
|
+
return Effect.map(git(root, ["merge-base", "HEAD", ref]), (result) => (result.code === 0 ? result.stdout.trim() : undefined));
|
|
41
|
+
}
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
Effect.flatMap(isShallow(root), (shallow) =>
|
|
43
|
+
function missingMergeBase(root: string, ref: string): Effect.Effect<never, SetupFailure, Git> {
|
|
44
|
+
return Effect.flatMap(isShallow(root), (shallow) =>
|
|
41
45
|
fail(
|
|
42
46
|
shallow
|
|
43
47
|
? `the clone is shallow and does not reach the merge base of HEAD and ${ref}. Fetch the history first: \`git fetch --unshallow\`.`
|
|
44
48
|
: `HEAD and ${ref} share no history.`,
|
|
45
49
|
),
|
|
46
50
|
);
|
|
51
|
+
}
|
|
47
52
|
|
|
48
|
-
|
|
49
|
-
Effect.flatMap(mergeBase(root, ref), (found) => (found === undefined ? missingMergeBase(root, ref) : Effect.succeed(found)));
|
|
53
|
+
function reachMergeBase(root: string, ref: string): Effect.Effect<string, SetupFailure, Git> {
|
|
54
|
+
return Effect.flatMap(mergeBase(root, ref), (found) => (found === undefined ? missingMergeBase(root, ref) : Effect.succeed(found)));
|
|
55
|
+
}
|
|
50
56
|
|
|
51
|
-
export const resolveBase =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return { commit
|
|
62
|
-
}
|
|
57
|
+
export const resolveBase = Effect.fn("Git.resolveBase")(function* (
|
|
58
|
+
root: string,
|
|
59
|
+
against: string | undefined,
|
|
60
|
+
): Effect.fn.Return<Base, SetupFailure, Git> {
|
|
61
|
+
const inside = yield* git(root, ["rev-parse", "--is-inside-work-tree"]);
|
|
62
|
+
if (inside.code !== 0 || inside.stdout.trim() !== "true") {
|
|
63
|
+
return yield* fail(`${root} is not in a git work tree; moves are followed through git history.`);
|
|
64
|
+
}
|
|
65
|
+
const ref = against ?? (yield* defaultBranch(root));
|
|
66
|
+
if (!(yield* isCommit(root, ref))) {
|
|
67
|
+
return yield* fail(`${ref} names no commit in this clone. Fetch it first, or pass another --against <ref>.`);
|
|
68
|
+
}
|
|
69
|
+
return { commit: yield* reachMergeBase(root, ref), ref };
|
|
70
|
+
});
|
package/src/git/command.ts
CHANGED
|
@@ -10,8 +10,8 @@ export interface GitResult {
|
|
|
10
10
|
|
|
11
11
|
export type Git = ChildProcessSpawner.ChildProcessSpawner;
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
Effect.scoped(
|
|
13
|
+
export function git(cwd: string, args: readonly string[]): Effect.Effect<GitResult, SetupFailure, Git> {
|
|
14
|
+
return Effect.scoped(
|
|
15
15
|
Effect.gen(function* () {
|
|
16
16
|
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
17
17
|
const child = yield* spawner.spawn(ChildProcess.make("git", [...args], { cwd, stdin: "ignore" }));
|
|
@@ -22,10 +22,12 @@ export const git = (cwd: string, args: readonly string[]): Effect.Effect<GitResu
|
|
|
22
22
|
return { code: Number(code), stderr, stdout };
|
|
23
23
|
}),
|
|
24
24
|
).pipe(Effect.mapError((error) => new SetupFailure({ message: `cannot run git: ${error.message}` })));
|
|
25
|
+
}
|
|
25
26
|
|
|
26
|
-
export
|
|
27
|
-
Effect.flatMap(git(cwd, args), (result) =>
|
|
27
|
+
export function gitOrFail(cwd: string, args: readonly string[]): Effect.Effect<string, SetupFailure, Git> {
|
|
28
|
+
return Effect.flatMap(git(cwd, args), (result) =>
|
|
28
29
|
result.code === 0
|
|
29
30
|
? Effect.succeed(result.stdout)
|
|
30
31
|
: Effect.fail(new SetupFailure({ message: `git ${args[0]} failed: ${result.stderr.trim() || `exit code ${result.code}`}` })),
|
|
31
32
|
);
|
|
33
|
+
}
|
package/src/git/history.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface Changes {
|
|
|
7
7
|
readonly moves: ReadonlyMap<string, string>;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
function parse(output: string): Changes {
|
|
11
11
|
const fields = output.split("\0");
|
|
12
12
|
const files = new Set<string>();
|
|
13
13
|
const moves = new Map<string, string>();
|
|
@@ -24,11 +24,12 @@ const parse = (output: string): Changes => {
|
|
|
24
24
|
index += paths.length + 1;
|
|
25
25
|
}
|
|
26
26
|
return { files, moves };
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
|
|
29
29
|
// Paths are relative to the root, and only tracked files count: a move is seen once both of its sides are staged.
|
|
30
|
-
export
|
|
31
|
-
Effect.map(
|
|
30
|
+
export function changesSince(root: string, revision: readonly string[]): Effect.Effect<Changes, SetupFailure, Git> {
|
|
31
|
+
return Effect.map(
|
|
32
32
|
gitOrFail(root, ["diff", "--no-color", "--no-ext-diff", "--find-renames", "--name-status", "-z", "--relative", ...revision, "--"]),
|
|
33
33
|
parse,
|
|
34
34
|
);
|
|
35
|
+
}
|
package/src/hooks/preCommit.ts
CHANGED
|
@@ -48,7 +48,7 @@ const runScript = Effect.fnUntraced(
|
|
|
48
48
|
export const preCommitHook = Effect.fn("Hooks.preCommitHook")(function* (cwd: string, path: string | undefined) {
|
|
49
49
|
const config = yield* loadConfig(cwd, path);
|
|
50
50
|
const { manager, scripts } = yield* commitScripts(config.root);
|
|
51
|
-
const linted = yield* lint(cwd, path
|
|
51
|
+
const linted = yield* lint(cwd, path).pipe(
|
|
52
52
|
Effect.as(true),
|
|
53
53
|
Effect.catchTag("GateFailed", () => Effect.succeed(false)),
|
|
54
54
|
);
|
package/src/imports/generated.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { posix } from "node:path";
|
|
3
3
|
import { promisify } from "node:util";
|
|
4
|
-
import { emptyScope, type IgnoreScope, verdictFor, withIgnoreFile } from "#inventory/
|
|
4
|
+
import { emptyScope, type IgnoreScope, verdictFor, withIgnoreFile } from "#inventory/ignoreScope.ts";
|
|
5
5
|
import type { RuleInputs } from "#rule.ts";
|
|
6
6
|
import type { ImportGraph, UnresolvedImport } from "./graph.ts";
|
|
7
7
|
|
package/src/imports/resolve.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { realpathSync } from "node:fs";
|
|
|
2
2
|
import { isBuiltin } from "node:module";
|
|
3
3
|
import { dirname, join, relative } from "node:path";
|
|
4
4
|
import ts from "typescript";
|
|
5
|
-
import { posix } from "#inventory/
|
|
5
|
+
import { posix } from "#inventory/ignoreScope.ts";
|
|
6
6
|
import type { Ambient } from "./ambient.ts";
|
|
7
7
|
import type { ImportRequest } from "./extract.ts";
|
|
8
8
|
import type { Project } from "./projects.ts";
|
package/src/imports/workspace.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Effect } from "effect";
|
|
|
4
4
|
import { manifestsIn } from "#manifests/sorted.ts";
|
|
5
5
|
import type { RuleInputs } from "#rule.ts";
|
|
6
6
|
import { globMatcher } from "./glob.ts";
|
|
7
|
-
import { pnpmWorkspacePatterns } from "./
|
|
7
|
+
import { pnpmWorkspacePatterns } from "./pnpmWorkspacePatterns.ts";
|
|
8
8
|
|
|
9
9
|
export interface WorkspacePackage {
|
|
10
10
|
readonly directory: string;
|
package/src/inventory/collect.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Effect, FileSystem } from "effect";
|
|
|
3
3
|
import ignore from "ignore";
|
|
4
4
|
import type { SourceFile } from "#rule.ts";
|
|
5
5
|
import { FilesystemFailure, orWhenAbsent, readRequiredText } from "./filesystem.ts";
|
|
6
|
-
import { posix } from "./
|
|
6
|
+
import { posix } from "./ignoreScope.ts";
|
|
7
7
|
import { scopeAbove, walk } from "./walk.ts";
|
|
8
8
|
|
|
9
9
|
export interface InventoryScope {
|
|
@@ -19,42 +19,47 @@ export interface Inventory {
|
|
|
19
19
|
|
|
20
20
|
const READ_CONCURRENCY = 16;
|
|
21
21
|
|
|
22
|
-
export
|
|
22
|
+
export function linesOf(text: string): readonly string[] {
|
|
23
23
|
const lines = text.split("\n");
|
|
24
24
|
return lines.at(-1) === "" ? lines.slice(0, -1) : lines;
|
|
25
|
-
}
|
|
25
|
+
}
|
|
26
26
|
|
|
27
|
-
const zoneFiles =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return
|
|
39
|
-
}
|
|
27
|
+
const zoneFiles = Effect.fn("Inventory.zoneFiles")(function* (
|
|
28
|
+
root: string,
|
|
29
|
+
zone: string,
|
|
30
|
+
): Effect.fn.Return<readonly string[], FilesystemFailure, FileSystem.FileSystem> {
|
|
31
|
+
const fs = yield* FileSystem.FileSystem;
|
|
32
|
+
const path = join(root, zone);
|
|
33
|
+
if (posix(relative(root, path)).startsWith("..")) {
|
|
34
|
+
return yield* new FilesystemFailure({ message: `source "${zone}" lies outside the repository at ${root}`, path });
|
|
35
|
+
}
|
|
36
|
+
const info = yield* orWhenAbsent<FileSystem.File.Info | undefined>(path, fs.stat(path), undefined);
|
|
37
|
+
if (info === undefined) {
|
|
38
|
+
return yield* new FilesystemFailure({ message: `source "${zone}" does not exist in ${root}`, path });
|
|
39
|
+
}
|
|
40
|
+
return info.type === "Directory" ? yield* walk(path, yield* scopeAbove(root, path)) : [path];
|
|
41
|
+
});
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
Effect.map(readRequiredText(join(root, path)), (text) => ({ lines: linesOf(text), path, text }));
|
|
43
|
+
function readSource(root: string, path: string): Effect.Effect<SourceFile, FilesystemFailure, FileSystem.FileSystem> {
|
|
44
|
+
return Effect.map(readRequiredText(join(root, path)), (text) => ({ lines: linesOf(text), path, text }));
|
|
45
|
+
}
|
|
43
46
|
|
|
44
|
-
export const collectInventory =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
});
|
|
47
|
+
export const collectInventory = Effect.fn("Inventory.collectInventory")(function* (
|
|
48
|
+
root: string,
|
|
49
|
+
scope: InventoryScope,
|
|
50
|
+
): Effect.fn.Return<Inventory, FilesystemFailure, FileSystem.FileSystem> {
|
|
51
|
+
const excluded = ignore().add([...scope.exclude]);
|
|
52
|
+
const zones = yield* Effect.forEach(scope.sources, (zone) => zoneFiles(root, zone), { concurrency: READ_CONCURRENCY });
|
|
53
|
+
const relativePaths = zones.flat().map((absolute) => posix(relative(root, absolute)));
|
|
54
|
+
const files = [...new Set(relativePaths)]
|
|
55
|
+
.filter((path) => !excluded.ignores(path))
|
|
56
|
+
.sort((left, right) => {
|
|
57
|
+
if (left === right) {
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
return left < right ? -1 : 1;
|
|
61
|
+
});
|
|
62
|
+
const sourcePaths = files.filter((path) => scope.extensions.some((extension) => path.endsWith(extension)));
|
|
63
|
+
const sources = yield* Effect.forEach(sourcePaths, (path) => readSource(root, path), { concurrency: READ_CONCURRENCY });
|
|
64
|
+
return { files, sources };
|
|
65
|
+
});
|
|
@@ -10,38 +10,46 @@ export class FilesystemFailure extends Data.TaggedError("FilesystemFailure")<{
|
|
|
10
10
|
}> {}
|
|
11
11
|
|
|
12
12
|
// Effect maps ENOTDIR and EISDIR to BadResource; the original errno remains on the cause.
|
|
13
|
-
|
|
13
|
+
function errnoOf(error: PlatformError): string {
|
|
14
14
|
const cause: unknown = error.reason.cause;
|
|
15
15
|
return typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
new FilesystemFailure({ message: `cannot read ${path}: ${error.message}`, path });
|
|
18
|
+
function failure(path: string, error: PlatformError): FilesystemFailure {
|
|
19
|
+
return new FilesystemFailure({ message: `cannot read ${path}: ${error.message}`, path });
|
|
20
|
+
}
|
|
20
21
|
|
|
21
|
-
export
|
|
22
|
+
export function orWhenAbsent<TValue>(
|
|
22
23
|
path: string,
|
|
23
|
-
action: Effect.Effect<
|
|
24
|
-
whenAbsent:
|
|
25
|
-
): Effect.Effect<
|
|
26
|
-
Effect.catchTag(action, "PlatformError", (error) =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
24
|
+
action: Effect.Effect<TValue, PlatformError, FileSystem.FileSystem>,
|
|
25
|
+
whenAbsent: TValue,
|
|
26
|
+
): Effect.Effect<TValue, FilesystemFailure, FileSystem.FileSystem> {
|
|
27
|
+
return Effect.catchTag(action, "PlatformError", (error) =>
|
|
28
|
+
ABSENT.has(errnoOf(error)) ? Effect.succeed(whenAbsent) : Effect.fail(failure(path, error)),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const readOptionalText = Effect.fn("Inventory.readOptionalText")(function* (
|
|
33
|
+
path: string,
|
|
34
|
+
): Effect.fn.Return<string | undefined, FilesystemFailure, FileSystem.FileSystem> {
|
|
35
|
+
const fs = yield* FileSystem.FileSystem;
|
|
36
|
+
return yield* orWhenAbsent<string | undefined>(path, fs.readFileString(path), undefined);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const readRequiredText = Effect.fn("Inventory.readRequiredText")(function* (
|
|
40
|
+
path: string,
|
|
41
|
+
): Effect.fn.Return<string, FilesystemFailure, FileSystem.FileSystem> {
|
|
42
|
+
const fs = yield* FileSystem.FileSystem;
|
|
43
|
+
return yield* Effect.mapError(fs.readFileString(path), (error) =>
|
|
44
|
+
ABSENT.has(errnoOf(error)) ? new FilesystemFailure({ message: `required input is missing: ${path}`, path }) : failure(path, error),
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const writeText = Effect.fn("Inventory.writeText")(function* (
|
|
49
|
+
path: string,
|
|
50
|
+
text: string,
|
|
51
|
+
): Effect.fn.Return<void, FilesystemFailure, FileSystem.FileSystem> {
|
|
52
|
+
const fs = yield* FileSystem.FileSystem;
|
|
53
|
+
const written = Effect.andThen(fs.makeDirectory(dirname(path), { recursive: true }), fs.writeFileString(path, text));
|
|
54
|
+
return yield* Effect.mapError(written, (error) => new FilesystemFailure({ message: `cannot write ${path}: ${error.message}`, path }));
|
|
55
|
+
});
|
|
@@ -15,17 +15,23 @@ export interface IgnoreScope {
|
|
|
15
15
|
|
|
16
16
|
export const emptyScope: IgnoreScope = { boundary: undefined, matchers: [] };
|
|
17
17
|
|
|
18
|
-
export
|
|
18
|
+
export function posix(path: string): string {
|
|
19
|
+
return path.replaceAll("\\", "/");
|
|
20
|
+
}
|
|
19
21
|
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
22
|
+
export function withIgnoreFile(scope: IgnoreScope, base: string, contents: string): IgnoreScope {
|
|
23
|
+
return {
|
|
24
|
+
boundary: scope.boundary,
|
|
25
|
+
matchers: [...scope.matchers, { base, rules: ignore().add(contents) }],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
24
28
|
|
|
25
29
|
// Re-including a directory resets directory rules below that boundary; filename rules still apply.
|
|
26
|
-
export
|
|
30
|
+
export function insideKept(scope: IgnoreScope, directory: string): IgnoreScope {
|
|
31
|
+
return { boundary: directory, matchers: scope.matchers };
|
|
32
|
+
}
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
function matcherVerdict(matcher: IgnoreMatcher, boundary: string | undefined, path: string, directory: boolean): Verdict {
|
|
29
35
|
const anchor = boundary !== undefined && boundary.length > matcher.base.length ? boundary : matcher.base;
|
|
30
36
|
const rel = posix(relative(anchor, path));
|
|
31
37
|
if (rel === "" || rel.startsWith("..")) {
|
|
@@ -37,7 +43,11 @@ const matcherVerdict = (matcher: IgnoreMatcher, boundary: string | undefined, pa
|
|
|
37
43
|
return "ignored";
|
|
38
44
|
}
|
|
39
45
|
return result.unignored ? "kept" : "unknown";
|
|
40
|
-
}
|
|
46
|
+
}
|
|
41
47
|
|
|
42
|
-
export
|
|
43
|
-
|
|
48
|
+
export function verdictFor(scope: IgnoreScope, path: string, directory: boolean): Verdict {
|
|
49
|
+
return (
|
|
50
|
+
scope.matchers.map((matcher) => matcherVerdict(matcher, scope.boundary, path, directory)).findLast((verdict) => verdict !== "unknown")
|
|
51
|
+
?? "unknown"
|
|
52
|
+
);
|
|
53
|
+
}
|
package/src/inventory/walk.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dirname, join, relative, sep } from "node:path";
|
|
2
2
|
import { Effect, FileSystem } from "effect";
|
|
3
3
|
import { FilesystemFailure, orWhenAbsent, readOptionalText } from "./filesystem.ts";
|
|
4
|
-
import { emptyScope, type IgnoreScope, insideKept, verdictFor, withIgnoreFile } from "./
|
|
4
|
+
import { emptyScope, type IgnoreScope, insideKept, verdictFor, withIgnoreFile } from "./ignoreScope.ts";
|
|
5
5
|
import { trackedPaths } from "./trackedPaths.ts";
|
|
6
6
|
|
|
7
7
|
const SKIPPED = new Set([".git", "node_modules"]);
|
package/src/manifests/sorted.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { basename, join, relative } from "node:path";
|
|
|
2
2
|
import { Effect, FileSystem } from "effect";
|
|
3
3
|
import { sortPackageJson } from "sort-package-json";
|
|
4
4
|
import { FilesystemFailure } from "#inventory/filesystem.ts";
|
|
5
|
-
import { posix } from "#inventory/
|
|
5
|
+
import { posix } from "#inventory/ignoreScope.ts";
|
|
6
6
|
import { walk } from "#inventory/walk.ts";
|
|
7
7
|
|
|
8
8
|
export type Sorting = { readonly _tag: "Invalid" } | { readonly _tag: "Sorted" } | { readonly _tag: "Unsorted"; readonly sorted: string };
|
|
@@ -26,21 +26,21 @@ export function sortingOf(text: string): Sorting {
|
|
|
26
26
|
return sorted === text ? { _tag: "Sorted" } : { _tag: "Unsorted", sorted };
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
29
|
+
export const sortManifests = Effect.fn("Manifests.sortManifests")(function* (
|
|
30
|
+
root: string,
|
|
31
|
+
): Effect.fn.Return<number, FilesystemFailure, FileSystem.FileSystem> {
|
|
32
|
+
const fs = yield* FileSystem.FileSystem;
|
|
33
|
+
const manifests = yield* manifestsIn(root);
|
|
34
|
+
const written = yield* Effect.forEach(manifests, (path) =>
|
|
35
|
+
Effect.gen(function* () {
|
|
36
|
+
const absolute = join(root, path);
|
|
37
|
+
const sorting = sortingOf(yield* fs.readFileString(absolute));
|
|
38
|
+
if (sorting._tag !== "Unsorted") {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
yield* fs.writeFileString(absolute, sorting.sorted);
|
|
42
|
+
return true;
|
|
43
|
+
}).pipe(Effect.mapError((error) => new FilesystemFailure({ message: `cannot sort ${path}: ${error.message}`, path }))),
|
|
44
|
+
);
|
|
45
|
+
return written.filter(Boolean).length;
|
|
46
|
+
});
|
package/src/report/plural.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export function plural(count: number, singular: string, many = `${singular}s`): string {
|
|
2
|
+
return `${count} ${count === 1 ? singular : many}`;
|
|
3
|
+
}
|
package/src/report/render.ts
CHANGED
|
@@ -4,30 +4,28 @@ import { groupBy, keyOf, type Violation } from "#engine/violation.ts";
|
|
|
4
4
|
import { plural } from "./plural.ts";
|
|
5
5
|
import { staleSections } from "./stale.ts";
|
|
6
6
|
|
|
7
|
-
export type WarningDetail = "summary" | "all";
|
|
8
|
-
|
|
9
7
|
export interface ReportContext {
|
|
10
8
|
readonly baseline: string;
|
|
11
9
|
readonly checked: number;
|
|
12
10
|
readonly descriptions: ReadonlyMap<string, string>;
|
|
13
11
|
readonly registry: string;
|
|
14
|
-
readonly warnings: WarningDetail;
|
|
15
12
|
}
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
function locate(violation: Violation): string {
|
|
15
|
+
return violation.line === undefined ? violation.file : `${violation.file}:${violation.line}`;
|
|
16
|
+
}
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
` ${regression.entry.file} is over its baseline: ${regression.count} against ${regression.entry.count} baselined.`;
|
|
18
|
+
function regressionNote(regression: Regression): string {
|
|
19
|
+
return ` ${regression.entry.file} is over its baseline: ${regression.count} against ${regression.entry.count} baselined.`;
|
|
20
|
+
}
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
function heading(rule: string, violations: readonly Violation[], context: ReportContext): readonly string[] {
|
|
25
23
|
const description = context.descriptions.get(rule);
|
|
26
|
-
return [
|
|
27
|
-
}
|
|
24
|
+
return [`error ${rule} (${violations.length})`, ...(description === undefined ? [] : [` ${description}`])];
|
|
25
|
+
}
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
[...groupBy(violations, (violation) => violation.file).values()].flatMap((inFile) => {
|
|
27
|
+
function detailed(violations: readonly Violation[], regressions: ReadonlyMap<string, Regression>): readonly string[] {
|
|
28
|
+
return [...groupBy(violations, (violation) => violation.file).values()].flatMap((inFile) => {
|
|
31
29
|
const first = inFile[0];
|
|
32
30
|
const regression = first === undefined ? undefined : regressions.get(keyOf(first.rule, first.file));
|
|
33
31
|
return [
|
|
@@ -35,43 +33,32 @@ const detailed = (violations: readonly Violation[], regressions: ReadonlyMap<str
|
|
|
35
33
|
...(regression === undefined ? [] : [regressionNote(regression)]),
|
|
36
34
|
];
|
|
37
35
|
});
|
|
36
|
+
}
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const rest = files.length - listed.length;
|
|
43
|
-
return [` ${listed.join(", ")}${rest > 0 ? `, and ${plural(rest, "more file", "more files")}` : ""}. --warnings all lists each one.`];
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const ruleSections = (
|
|
47
|
-
label: string,
|
|
48
|
-
violations: readonly Violation[],
|
|
49
|
-
context: ReportContext,
|
|
50
|
-
body: (inRule: readonly Violation[]) => readonly string[],
|
|
51
|
-
): readonly string[] =>
|
|
52
|
-
[...groupBy(violations, (violation) => violation.rule).entries()].map(([rule, inRule]) =>
|
|
53
|
-
[...heading(label, rule, inRule, context), ...body(inRule)].join("\n"),
|
|
38
|
+
function ruleSections(violations: readonly Violation[], context: ReportContext, regressions: ReadonlyMap<string, Regression>): readonly string[] {
|
|
39
|
+
return [...groupBy(violations, (violation) => violation.rule).entries()].map(([rule, inRule]) =>
|
|
40
|
+
[...heading(rule, inRule, context), ...detailed(inRule, regressions)].join("\n"),
|
|
54
41
|
);
|
|
42
|
+
}
|
|
55
43
|
|
|
56
|
-
|
|
44
|
+
function failures(outcome: Outcome): string {
|
|
57
45
|
const stale = outcome.staleBaseline.length + outcome.staleRegistry.length;
|
|
58
46
|
return [
|
|
59
47
|
...(outcome.errors.length > 0 ? [plural(outcome.errors.length, "error")] : []),
|
|
60
48
|
...(stale > 0 ? [plural(stale, "stale entry", "stale entries")] : []),
|
|
61
49
|
].join(" and ");
|
|
62
|
-
}
|
|
50
|
+
}
|
|
63
51
|
|
|
64
|
-
|
|
52
|
+
function summary(outcome: Outcome, context: ReportContext): string {
|
|
65
53
|
const verdict = passes(outcome) ? "quality: passed" : `quality: failed with ${failures(outcome)}`;
|
|
66
|
-
const warnings = outcome.warnings.length > 0 ? `; ${plural(outcome.warnings.length, "warning")} from rules still at warn` : "";
|
|
67
54
|
const hidden = [
|
|
68
55
|
...(outcome.baselined > 0 ? [`${outcome.baselined} baselined`] : []),
|
|
69
56
|
...(outcome.registered > 0 ? [`${outcome.registered} registered`] : []),
|
|
70
57
|
];
|
|
71
58
|
const suppressed =
|
|
72
59
|
hidden.length === 0 ? "" : `; ${hidden.join(" and ")} ${outcome.baselined + outcome.registered === 1 ? "violation" : "violations"} not shown`;
|
|
73
|
-
return `${verdict}
|
|
74
|
-
}
|
|
60
|
+
return `${verdict}. ${plural(context.checked, "source file")} checked${suppressed}.`;
|
|
61
|
+
}
|
|
75
62
|
|
|
76
63
|
function rerecord(outcome: Outcome): readonly string[] {
|
|
77
64
|
const rules = [...new Set(outcome.errors.map((violation) => violation.rule))].sort((left, right) => left.localeCompare(right));
|
|
@@ -84,14 +71,12 @@ function rerecord(outcome: Outcome): readonly string[] {
|
|
|
84
71
|
];
|
|
85
72
|
}
|
|
86
73
|
|
|
87
|
-
export
|
|
74
|
+
export function render(outcome: Outcome, context: ReportContext): string {
|
|
88
75
|
const regressions = new Map(outcome.regressions.map((regression) => [keyOf(regression.entry.rule, regression.entry.file), regression]));
|
|
89
|
-
const warningBody = context.warnings === "all" ? (inRule: readonly Violation[]) => detailed(inRule, regressions) : summarized;
|
|
90
76
|
return [
|
|
91
|
-
...ruleSections(
|
|
92
|
-
...ruleSections("warn", outcome.warnings, context, warningBody),
|
|
77
|
+
...ruleSections(outcome.errors, context, regressions),
|
|
93
78
|
...staleSections(outcome, context),
|
|
94
79
|
summary(outcome, context),
|
|
95
80
|
...rerecord(outcome),
|
|
96
81
|
].join("\n\n");
|
|
97
|
-
}
|
|
82
|
+
}
|