@ontrails/warden 1.0.0-beta.13 → 1.0.0-beta.15
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/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +30 -0
- package/README.md +31 -20
- package/dist/cli.d.ts +19 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +261 -64
- package/dist/cli.js.map +1 -1
- package/dist/draft.d.ts +5 -0
- package/dist/draft.d.ts.map +1 -0
- package/dist/draft.js +16 -0
- package/dist/draft.js.map +1 -0
- package/dist/drift.d.ts +10 -7
- package/dist/drift.d.ts.map +1 -1
- package/dist/drift.js +50 -16
- package/dist/drift.js.map +1 -1
- package/dist/formatters.d.ts +2 -1
- package/dist/formatters.d.ts.map +1 -1
- package/dist/formatters.js +15 -4
- package/dist/formatters.js.map +1 -1
- package/dist/index.d.ts +9 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -17
- package/dist/index.js.map +1 -1
- package/dist/rules/ast.d.ts +412 -7
- package/dist/rules/ast.d.ts.map +1 -1
- package/dist/rules/ast.js +1847 -102
- package/dist/rules/ast.js.map +1 -1
- package/dist/rules/circular-refs.d.ts +6 -0
- package/dist/rules/circular-refs.d.ts.map +1 -0
- package/dist/rules/circular-refs.js +83 -0
- package/dist/rules/circular-refs.js.map +1 -0
- package/dist/rules/context-no-surface-types.d.ts.map +1 -1
- package/dist/rules/context-no-surface-types.js +59 -3
- package/dist/rules/context-no-surface-types.js.map +1 -1
- package/dist/rules/contour-exists.d.ts +7 -0
- package/dist/rules/contour-exists.d.ts.map +1 -0
- package/dist/rules/contour-exists.js +113 -0
- package/dist/rules/contour-exists.js.map +1 -0
- package/dist/rules/contour-ids.d.ts +10 -0
- package/dist/rules/contour-ids.d.ts.map +1 -0
- package/dist/rules/contour-ids.js +12 -0
- package/dist/rules/contour-ids.js.map +1 -0
- package/dist/rules/cross-declarations.d.ts.map +1 -1
- package/dist/rules/cross-declarations.js +171 -57
- package/dist/rules/cross-declarations.js.map +1 -1
- package/dist/rules/dead-internal-trail.d.ts +3 -0
- package/dist/rules/dead-internal-trail.d.ts.map +1 -0
- package/dist/rules/dead-internal-trail.js +80 -0
- package/dist/rules/dead-internal-trail.js.map +1 -0
- package/dist/rules/draft-file-marking.d.ts +6 -0
- package/dist/rules/draft-file-marking.d.ts.map +1 -0
- package/dist/rules/draft-file-marking.js +87 -0
- package/dist/rules/draft-file-marking.js.map +1 -0
- package/dist/rules/draft-visible-debt.d.ts +12 -0
- package/dist/rules/draft-visible-debt.d.ts.map +1 -0
- package/dist/rules/draft-visible-debt.js +50 -0
- package/dist/rules/draft-visible-debt.js.map +1 -0
- package/dist/rules/error-mapping-completeness.d.ts +13 -0
- package/dist/rules/error-mapping-completeness.d.ts.map +1 -0
- package/dist/rules/error-mapping-completeness.js +160 -0
- package/dist/rules/error-mapping-completeness.js.map +1 -0
- package/dist/rules/example-valid.d.ts +6 -0
- package/dist/rules/example-valid.d.ts.map +1 -0
- package/dist/rules/example-valid.js +203 -0
- package/dist/rules/example-valid.js.map +1 -0
- package/dist/rules/fires-declarations.d.ts +16 -0
- package/dist/rules/fires-declarations.d.ts.map +1 -0
- package/dist/rules/fires-declarations.js +444 -0
- package/dist/rules/fires-declarations.js.map +1 -0
- package/dist/rules/implementation-returns-result.d.ts +9 -0
- package/dist/rules/implementation-returns-result.d.ts.map +1 -1
- package/dist/rules/implementation-returns-result.js +638 -76
- package/dist/rules/implementation-returns-result.js.map +1 -1
- package/dist/rules/incomplete-accessor-for-standard-op.d.ts +30 -0
- package/dist/rules/incomplete-accessor-for-standard-op.d.ts.map +1 -0
- package/dist/rules/incomplete-accessor-for-standard-op.js +226 -0
- package/dist/rules/incomplete-accessor-for-standard-op.js.map +1 -0
- package/dist/rules/incomplete-crud.d.ts +21 -0
- package/dist/rules/incomplete-crud.d.ts.map +1 -0
- package/dist/rules/incomplete-crud.js +368 -0
- package/dist/rules/incomplete-crud.js.map +1 -0
- package/dist/rules/index.d.ts +40 -7
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +91 -15
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/intent-propagation.d.ts +3 -0
- package/dist/rules/intent-propagation.d.ts.map +1 -0
- package/dist/rules/intent-propagation.js +57 -0
- package/dist/rules/intent-propagation.js.map +1 -0
- package/dist/rules/missing-reconcile.d.ts +3 -0
- package/dist/rules/missing-reconcile.d.ts.map +1 -0
- package/dist/rules/missing-reconcile.js +44 -0
- package/dist/rules/missing-reconcile.js.map +1 -0
- package/dist/rules/missing-visibility.d.ts +3 -0
- package/dist/rules/missing-visibility.d.ts.map +1 -0
- package/dist/rules/missing-visibility.js +63 -0
- package/dist/rules/missing-visibility.js.map +1 -0
- package/dist/rules/no-direct-impl-in-route.d.ts.map +1 -1
- package/dist/rules/no-direct-impl-in-route.js +0 -3
- package/dist/rules/no-direct-impl-in-route.js.map +1 -1
- package/dist/rules/no-direct-implementation-call.js +1 -1
- package/dist/rules/no-direct-implementation-call.js.map +1 -1
- package/dist/rules/no-sync-result-assumption.d.ts.map +1 -1
- package/dist/rules/no-sync-result-assumption.js +870 -61
- package/dist/rules/no-sync-result-assumption.js.map +1 -1
- package/dist/rules/no-throw-in-detour-recover.d.ts +3 -0
- package/dist/rules/no-throw-in-detour-recover.d.ts.map +1 -0
- package/dist/rules/no-throw-in-detour-recover.js +147 -0
- package/dist/rules/no-throw-in-detour-recover.js.map +1 -0
- package/dist/rules/no-throw-in-detour-target.d.ts +4 -1
- package/dist/rules/no-throw-in-detour-target.d.ts.map +1 -1
- package/dist/rules/no-throw-in-detour-target.js +6 -3
- package/dist/rules/no-throw-in-detour-target.js.map +1 -1
- package/dist/rules/no-throw-in-implementation.d.ts +4 -2
- package/dist/rules/no-throw-in-implementation.d.ts.map +1 -1
- package/dist/rules/no-throw-in-implementation.js +6 -4
- package/dist/rules/no-throw-in-implementation.js.map +1 -1
- package/dist/rules/on-references-exist.d.ts +14 -0
- package/dist/rules/on-references-exist.d.ts.map +1 -0
- package/dist/rules/on-references-exist.js +109 -0
- package/dist/rules/on-references-exist.js.map +1 -0
- package/dist/rules/orphaned-signal.d.ts +3 -0
- package/dist/rules/orphaned-signal.d.ts.map +1 -0
- package/dist/rules/orphaned-signal.js +67 -0
- package/dist/rules/orphaned-signal.js.map +1 -0
- package/dist/rules/permit-governance.d.ts +3 -0
- package/dist/rules/permit-governance.d.ts.map +1 -0
- package/dist/rules/permit-governance.js +15 -0
- package/dist/rules/permit-governance.js.map +1 -0
- package/dist/rules/reference-exists.d.ts +6 -0
- package/dist/rules/reference-exists.d.ts.map +1 -0
- package/dist/rules/reference-exists.js +47 -0
- package/dist/rules/reference-exists.js.map +1 -0
- package/dist/rules/registry-names.d.ts +8 -0
- package/dist/rules/registry-names.d.ts.map +1 -0
- package/dist/rules/registry-names.js +83 -0
- package/dist/rules/registry-names.js.map +1 -0
- package/dist/rules/resource-declarations.d.ts +14 -0
- package/dist/rules/resource-declarations.d.ts.map +1 -0
- package/dist/rules/resource-declarations.js +413 -0
- package/dist/rules/resource-declarations.js.map +1 -0
- package/dist/rules/resource-exists.d.ts +6 -0
- package/dist/rules/resource-exists.d.ts.map +1 -0
- package/dist/rules/resource-exists.js +90 -0
- package/dist/rules/resource-exists.js.map +1 -0
- package/dist/rules/resource-id-grammar.d.ts +3 -0
- package/dist/rules/resource-id-grammar.d.ts.map +1 -0
- package/dist/rules/resource-id-grammar.js +39 -0
- package/dist/rules/resource-id-grammar.js.map +1 -0
- package/dist/rules/specs.d.ts.map +1 -1
- package/dist/rules/specs.js +5 -1
- package/dist/rules/specs.js.map +1 -1
- package/dist/rules/types.d.ts +53 -4
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/unreachable-detour-shadowing.d.ts +3 -0
- package/dist/rules/unreachable-detour-shadowing.d.ts.map +1 -0
- package/dist/rules/unreachable-detour-shadowing.js +202 -0
- package/dist/rules/unreachable-detour-shadowing.js.map +1 -0
- package/dist/rules/valid-describe-refs.d.ts.map +1 -1
- package/dist/rules/valid-describe-refs.js +132 -16
- package/dist/rules/valid-describe-refs.js.map +1 -1
- package/dist/rules/valid-detour-contract.d.ts +3 -0
- package/dist/rules/valid-detour-contract.d.ts.map +1 -0
- package/dist/rules/valid-detour-contract.js +47 -0
- package/dist/rules/valid-detour-contract.js.map +1 -0
- package/dist/rules/valid-detour-refs.d.ts.map +1 -1
- package/dist/rules/valid-detour-refs.js +73 -82
- package/dist/rules/valid-detour-refs.js.map +1 -1
- package/dist/rules/warden-export-symmetry.d.ts +7 -0
- package/dist/rules/warden-export-symmetry.d.ts.map +1 -0
- package/dist/rules/warden-export-symmetry.js +352 -0
- package/dist/rules/warden-export-symmetry.js.map +1 -0
- package/dist/rules/warden-rules-use-ast.d.ts +17 -0
- package/dist/rules/warden-rules-use-ast.d.ts.map +1 -0
- package/dist/rules/warden-rules-use-ast.js +778 -0
- package/dist/rules/warden-rules-use-ast.js.map +1 -0
- package/dist/trails/circular-refs.trail.d.ts +24 -0
- package/dist/trails/circular-refs.trail.d.ts.map +1 -0
- package/dist/trails/circular-refs.trail.js +29 -0
- package/dist/trails/circular-refs.trail.js.map +1 -0
- package/dist/trails/context-no-surface-types.trail.d.ts +2 -2
- package/dist/trails/context-no-surface-types.trail.d.ts.map +1 -1
- package/dist/trails/context-no-trailhead-types.trail.d.ts +2 -2
- package/dist/trails/context-no-trailhead-types.trail.d.ts.map +1 -1
- package/dist/trails/contour-exists.trail.d.ts +24 -0
- package/dist/trails/contour-exists.trail.d.ts.map +1 -0
- package/dist/trails/contour-exists.trail.js +21 -0
- package/dist/trails/contour-exists.trail.js.map +1 -0
- package/dist/trails/cross-declarations.trail.d.ts +2 -2
- package/dist/trails/cross-declarations.trail.d.ts.map +1 -1
- package/dist/trails/dead-internal-trail.trail.d.ts +24 -0
- package/dist/trails/dead-internal-trail.trail.d.ts.map +1 -0
- package/dist/trails/dead-internal-trail.trail.js +26 -0
- package/dist/trails/dead-internal-trail.trail.js.map +1 -0
- package/dist/trails/{provision-declarations.trail.d.ts → draft-file-marking.trail.d.ts} +3 -3
- package/dist/trails/draft-file-marking.trail.d.ts.map +1 -0
- package/dist/trails/draft-file-marking.trail.js +16 -0
- package/dist/trails/draft-file-marking.trail.js.map +1 -0
- package/dist/trails/draft-visible-debt.trail.d.ts +13 -0
- package/dist/trails/draft-visible-debt.trail.d.ts.map +1 -0
- package/dist/trails/draft-visible-debt.trail.js +16 -0
- package/dist/trails/draft-visible-debt.trail.js.map +1 -0
- package/dist/trails/error-mapping-completeness.trail.d.ts +13 -0
- package/dist/trails/error-mapping-completeness.trail.d.ts.map +1 -0
- package/dist/trails/error-mapping-completeness.trail.js +29 -0
- package/dist/trails/error-mapping-completeness.trail.js.map +1 -0
- package/dist/trails/{follow-declarations.trail.d.ts → example-valid.trail.d.ts} +3 -3
- package/dist/trails/example-valid.trail.d.ts.map +1 -0
- package/dist/trails/example-valid.trail.js +25 -0
- package/dist/trails/example-valid.trail.js.map +1 -0
- package/dist/trails/fires-declarations.trail.d.ts +13 -0
- package/dist/trails/fires-declarations.trail.d.ts.map +1 -0
- package/dist/trails/fires-declarations.trail.js +22 -0
- package/dist/trails/fires-declarations.trail.js.map +1 -0
- package/dist/trails/implementation-returns-result.trail.d.ts +2 -2
- package/dist/trails/implementation-returns-result.trail.d.ts.map +1 -1
- package/dist/trails/incomplete-accessor-for-standard-op.trail.d.ts +12 -0
- package/dist/trails/incomplete-accessor-for-standard-op.trail.d.ts.map +1 -0
- package/dist/trails/incomplete-accessor-for-standard-op.trail.js +60 -0
- package/dist/trails/incomplete-accessor-for-standard-op.trail.js.map +1 -0
- package/dist/trails/incomplete-crud.trail.d.ts +24 -0
- package/dist/trails/incomplete-crud.trail.d.ts.map +1 -0
- package/dist/trails/incomplete-crud.trail.js +39 -0
- package/dist/trails/incomplete-crud.trail.js.map +1 -0
- package/dist/trails/index.d.ts +29 -7
- package/dist/trails/index.d.ts.map +1 -1
- package/dist/trails/index.js +28 -6
- package/dist/trails/index.js.map +1 -1
- package/dist/trails/intent-propagation.trail.d.ts +24 -0
- package/dist/trails/intent-propagation.trail.d.ts.map +1 -0
- package/dist/trails/intent-propagation.trail.js +30 -0
- package/dist/trails/intent-propagation.trail.js.map +1 -0
- package/dist/trails/missing-reconcile.trail.d.ts +24 -0
- package/dist/trails/missing-reconcile.trail.d.ts.map +1 -0
- package/dist/trails/missing-reconcile.trail.js +33 -0
- package/dist/trails/missing-reconcile.trail.js.map +1 -0
- package/dist/trails/missing-visibility.trail.d.ts +24 -0
- package/dist/trails/missing-visibility.trail.d.ts.map +1 -0
- package/dist/trails/missing-visibility.trail.js +22 -0
- package/dist/trails/missing-visibility.trail.js.map +1 -0
- package/dist/trails/no-direct-impl-in-route.trail.d.ts +2 -2
- package/dist/trails/no-direct-impl-in-route.trail.d.ts.map +1 -1
- package/dist/trails/no-direct-implementation-call.trail.d.ts +2 -2
- package/dist/trails/no-direct-implementation-call.trail.d.ts.map +1 -1
- package/dist/trails/no-sync-result-assumption.trail.d.ts +2 -2
- package/dist/trails/no-sync-result-assumption.trail.d.ts.map +1 -1
- package/dist/trails/no-throw-in-detour-recover.trail.d.ts +13 -0
- package/dist/trails/no-throw-in-detour-recover.trail.d.ts.map +1 -0
- package/dist/trails/no-throw-in-detour-recover.trail.js +24 -0
- package/dist/trails/no-throw-in-detour-recover.trail.js.map +1 -0
- package/dist/trails/no-throw-in-detour-target.trail.d.ts +13 -3
- package/dist/trails/no-throw-in-detour-target.trail.d.ts.map +1 -1
- package/dist/trails/no-throw-in-implementation.trail.d.ts +2 -2
- package/dist/trails/no-throw-in-implementation.trail.d.ts.map +1 -1
- package/dist/trails/on-references-exist.trail.d.ts +24 -0
- package/dist/trails/on-references-exist.trail.d.ts.map +1 -0
- package/dist/trails/on-references-exist.trail.js +21 -0
- package/dist/trails/on-references-exist.trail.js.map +1 -0
- package/dist/trails/orphaned-signal.trail.d.ts +24 -0
- package/dist/trails/orphaned-signal.trail.d.ts.map +1 -0
- package/dist/trails/orphaned-signal.trail.js +36 -0
- package/dist/trails/orphaned-signal.trail.js.map +1 -0
- package/dist/trails/permit-governance.trail.d.ts +12 -0
- package/dist/trails/permit-governance.trail.d.ts.map +1 -0
- package/dist/trails/permit-governance.trail.js +47 -0
- package/dist/trails/permit-governance.trail.js.map +1 -0
- package/dist/trails/prefer-schema-inference.trail.d.ts +2 -2
- package/dist/trails/prefer-schema-inference.trail.d.ts.map +1 -1
- package/dist/trails/reference-exists.trail.d.ts +24 -0
- package/dist/trails/reference-exists.trail.d.ts.map +1 -0
- package/dist/trails/reference-exists.trail.js +25 -0
- package/dist/trails/reference-exists.trail.js.map +1 -0
- package/dist/trails/resource-declarations.trail.d.ts +13 -0
- package/dist/trails/resource-declarations.trail.d.ts.map +1 -0
- package/dist/trails/{provision-declarations.trail.js → resource-declarations.trail.js} +7 -7
- package/dist/trails/resource-declarations.trail.js.map +1 -0
- package/dist/trails/resource-exists.trail.d.ts +24 -0
- package/dist/trails/resource-exists.trail.d.ts.map +1 -0
- package/dist/trails/{provision-exists.trail.js → resource-exists.trail.js} +8 -8
- package/dist/trails/resource-exists.trail.js.map +1 -0
- package/dist/trails/resource-id-grammar.trail.d.ts +13 -0
- package/dist/trails/resource-id-grammar.trail.d.ts.map +1 -0
- package/dist/trails/resource-id-grammar.trail.js +38 -0
- package/dist/trails/resource-id-grammar.trail.js.map +1 -0
- package/dist/trails/run.d.ts +25 -9
- package/dist/trails/run.d.ts.map +1 -1
- package/dist/trails/run.js +63 -19
- package/dist/trails/run.js.map +1 -1
- package/dist/trails/schema.d.ts +28 -3
- package/dist/trails/schema.d.ts.map +1 -1
- package/dist/trails/schema.js +57 -4
- package/dist/trails/schema.js.map +1 -1
- package/dist/trails/unreachable-detour-shadowing.trail.d.ts +13 -0
- package/dist/trails/unreachable-detour-shadowing.trail.d.ts.map +1 -0
- package/dist/trails/unreachable-detour-shadowing.trail.js +44 -0
- package/dist/trails/unreachable-detour-shadowing.trail.js.map +1 -0
- package/dist/trails/valid-describe-refs.trail.d.ts +12 -3
- package/dist/trails/valid-describe-refs.trail.d.ts.map +1 -1
- package/dist/trails/valid-detour-contract.trail.d.ts +12 -0
- package/dist/trails/valid-detour-contract.trail.d.ts.map +1 -0
- package/dist/trails/valid-detour-contract.trail.js +66 -0
- package/dist/trails/valid-detour-contract.trail.js.map +1 -0
- package/dist/trails/valid-detour-refs.trail.d.ts +13 -3
- package/dist/trails/valid-detour-refs.trail.d.ts.map +1 -1
- package/dist/trails/warden-export-symmetry.trail.d.ts +13 -0
- package/dist/trails/warden-export-symmetry.trail.d.ts.map +1 -0
- package/dist/trails/warden-export-symmetry.trail.js +16 -0
- package/dist/trails/warden-export-symmetry.trail.js.map +1 -0
- package/dist/trails/warden-rules-use-ast.trail.d.ts +13 -0
- package/dist/trails/warden-rules-use-ast.trail.d.ts.map +1 -0
- package/dist/trails/warden-rules-use-ast.trail.js +41 -0
- package/dist/trails/warden-rules-use-ast.trail.js.map +1 -0
- package/dist/trails/wrap-rule.d.ts +16 -2
- package/dist/trails/wrap-rule.d.ts.map +1 -1
- package/dist/trails/wrap-rule.js +71 -11
- package/dist/trails/wrap-rule.js.map +1 -1
- package/package.json +7 -4
- package/src/__tests__/ast.test.ts +613 -0
- package/src/__tests__/circular-refs.test.ts +121 -0
- package/src/__tests__/cli.test.ts +360 -32
- package/src/__tests__/contour-exists.test.ts +203 -0
- package/src/__tests__/cross-declarations.test.ts +245 -0
- package/src/__tests__/dead-internal-trail.test.ts +81 -0
- package/src/__tests__/draft-rules-context.test.ts +150 -0
- package/src/__tests__/drift.test.ts +75 -5
- package/src/__tests__/error-mapping-completeness.test.ts +56 -0
- package/src/__tests__/example-valid.test.ts +101 -0
- package/src/__tests__/fires-declarations-param-destructure.test.ts +54 -0
- package/src/__tests__/fires-declarations.test.ts +652 -0
- package/src/__tests__/formatters.test.ts +2 -2
- package/src/__tests__/implementation-returns-result.test.ts +1016 -2
- package/src/__tests__/incomplete-accessor-for-standard-op.test.ts +337 -0
- package/src/__tests__/incomplete-crud.test.ts +498 -0
- package/src/__tests__/intent-propagation.test.ts +116 -0
- package/src/__tests__/missing-reconcile.test.ts +154 -0
- package/src/__tests__/missing-visibility.test.ts +108 -0
- package/src/__tests__/no-sync-result-assumption.test.ts +870 -39
- package/src/__tests__/no-throw-in-detour-recover.test.ts +93 -0
- package/src/__tests__/no-throw-in-implementation.test.ts +88 -0
- package/src/__tests__/on-references-exist.test.ts +151 -0
- package/src/__tests__/orphaned-signal.test.ts +137 -0
- package/src/__tests__/permit-governance.test.ts +66 -0
- package/src/__tests__/reference-exists.test.ts +281 -0
- package/src/__tests__/resource-declarations.test.ts +448 -0
- package/src/__tests__/resource-exists.test.ts +122 -0
- package/src/__tests__/resource-id-grammar.test.ts +50 -0
- package/src/__tests__/rules.test.ts +17 -77
- package/src/__tests__/topo-aware-rule.test.ts +257 -0
- package/src/__tests__/trails.test.ts +2 -2
- package/src/__tests__/unreachable-detour-shadowing.test.ts +128 -0
- package/src/__tests__/valid-describe-refs.test.ts +183 -0
- package/src/__tests__/valid-detour-contract.test.ts +86 -0
- package/src/__tests__/warden-export-symmetry.test.ts +251 -0
- package/src/__tests__/warden-rules-use-ast.test.ts +468 -0
- package/src/__tests__/wrap-rule.test.ts +3 -3
- package/src/cli.ts +458 -91
- package/src/draft.ts +22 -0
- package/src/drift.ts +63 -21
- package/src/formatters.ts +15 -4
- package/src/index.ts +62 -23
- package/src/rules/ast.ts +2715 -119
- package/src/rules/circular-refs.ts +154 -0
- package/src/rules/{context-no-trailhead-types.ts → context-no-surface-types.ts} +72 -12
- package/src/rules/contour-exists.ts +251 -0
- package/src/rules/contour-ids.ts +15 -0
- package/src/rules/cross-declarations.ts +277 -69
- package/src/rules/dead-internal-trail.ts +141 -0
- package/src/rules/draft-file-marking.ts +160 -0
- package/src/rules/draft-visible-debt.ts +87 -0
- package/src/rules/error-mapping-completeness.ts +273 -0
- package/src/rules/example-valid.ts +401 -0
- package/src/rules/fires-declarations.ts +609 -0
- package/src/rules/implementation-returns-result.ts +1042 -122
- package/src/rules/incomplete-accessor-for-standard-op.ts +315 -0
- package/src/rules/incomplete-crud.ts +579 -0
- package/src/rules/index.ts +95 -16
- package/src/rules/intent-propagation.ts +142 -0
- package/src/rules/missing-reconcile.ts +98 -0
- package/src/rules/missing-visibility.ts +110 -0
- package/src/rules/no-direct-impl-in-route.ts +0 -4
- package/src/rules/no-direct-implementation-call.ts +1 -1
- package/src/rules/no-sync-result-assumption.ts +1134 -96
- package/src/rules/no-throw-in-detour-recover.ts +225 -0
- package/src/rules/no-throw-in-implementation.ts +6 -4
- package/src/rules/on-references-exist.ts +194 -0
- package/src/rules/orphaned-signal.ts +150 -0
- package/src/rules/permit-governance.ts +25 -0
- package/src/rules/reference-exists.ts +98 -0
- package/src/rules/registry-names.ts +83 -0
- package/src/rules/{provision-declarations.ts → resource-declarations.ts} +208 -138
- package/src/rules/{provision-exists.ts → resource-exists.ts} +48 -51
- package/src/rules/resource-id-grammar.ts +65 -0
- package/src/rules/specs.ts +5 -1
- package/src/rules/types.ts +57 -4
- package/src/rules/unreachable-detour-shadowing.ts +375 -0
- package/src/rules/valid-describe-refs.ts +160 -32
- package/src/rules/valid-detour-contract.ts +78 -0
- package/src/rules/warden-export-symmetry.ts +533 -0
- package/src/rules/warden-rules-use-ast.ts +996 -0
- package/src/trails/circular-refs.trail.ts +29 -0
- package/src/trails/{context-no-trailhead-types.trail.ts → context-no-surface-types.trail.ts} +4 -4
- package/src/trails/contour-exists.trail.ts +21 -0
- package/src/trails/dead-internal-trail.trail.ts +26 -0
- package/src/trails/draft-file-marking.trail.ts +16 -0
- package/src/trails/draft-visible-debt.trail.ts +16 -0
- package/src/trails/error-mapping-completeness.trail.ts +29 -0
- package/src/trails/example-valid.trail.ts +25 -0
- package/src/trails/fires-declarations.trail.ts +22 -0
- package/src/trails/incomplete-accessor-for-standard-op.trail.ts +76 -0
- package/src/trails/incomplete-crud.trail.ts +39 -0
- package/src/trails/index.ts +40 -7
- package/src/trails/intent-propagation.trail.ts +30 -0
- package/src/trails/missing-reconcile.trail.ts +33 -0
- package/src/trails/missing-visibility.trail.ts +22 -0
- package/src/trails/no-throw-in-detour-recover.trail.ts +24 -0
- package/src/trails/on-references-exist.trail.ts +21 -0
- package/src/trails/orphaned-signal.trail.ts +36 -0
- package/src/trails/permit-governance.trail.ts +51 -0
- package/src/trails/reference-exists.trail.ts +25 -0
- package/src/trails/{provision-declarations.trail.ts → resource-declarations.trail.ts} +6 -6
- package/src/trails/{provision-exists.trail.ts → resource-exists.trail.ts} +7 -7
- package/src/trails/resource-id-grammar.trail.ts +39 -0
- package/src/trails/run.ts +121 -24
- package/src/trails/schema.ts +66 -4
- package/src/trails/unreachable-detour-shadowing.trail.ts +45 -0
- package/src/trails/valid-detour-contract.trail.ts +71 -0
- package/src/trails/warden-export-symmetry.trail.ts +16 -0
- package/src/trails/warden-rules-use-ast.trail.ts +45 -0
- package/src/trails/wrap-rule.ts +104 -12
- package/tsconfig.tests.json +10 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/rules/follow-declarations.d.ts +0 -13
- package/dist/rules/follow-declarations.d.ts.map +0 -1
- package/dist/rules/follow-declarations.js +0 -264
- package/dist/rules/follow-declarations.js.map +0 -1
- package/dist/rules/provision-declarations.d.ts +0 -14
- package/dist/rules/provision-declarations.d.ts.map +0 -1
- package/dist/rules/provision-declarations.js +0 -344
- package/dist/rules/provision-declarations.js.map +0 -1
- package/dist/rules/provision-exists.d.ts +0 -6
- package/dist/rules/provision-exists.d.ts.map +0 -1
- package/dist/rules/provision-exists.js +0 -89
- package/dist/rules/provision-exists.js.map +0 -1
- package/dist/rules/service-declarations.d.ts +0 -16
- package/dist/rules/service-declarations.d.ts.map +0 -1
- package/dist/rules/service-declarations.js +0 -346
- package/dist/rules/service-declarations.js.map +0 -1
- package/dist/rules/service-exists.d.ts +0 -8
- package/dist/rules/service-exists.d.ts.map +0 -1
- package/dist/rules/service-exists.js +0 -91
- package/dist/rules/service-exists.js.map +0 -1
- package/dist/trails/follow-declarations.trail.d.ts.map +0 -1
- package/dist/trails/follow-declarations.trail.js +0 -22
- package/dist/trails/follow-declarations.trail.js.map +0 -1
- package/dist/trails/provision-declarations.trail.d.ts.map +0 -1
- package/dist/trails/provision-declarations.trail.js.map +0 -1
- package/dist/trails/provision-exists.trail.d.ts +0 -15
- package/dist/trails/provision-exists.trail.d.ts.map +0 -1
- package/dist/trails/provision-exists.trail.js.map +0 -1
- package/dist/trails/service-declarations.trail.d.ts +0 -26
- package/dist/trails/service-declarations.trail.d.ts.map +0 -1
- package/dist/trails/service-declarations.trail.js +0 -27
- package/dist/trails/service-declarations.trail.js.map +0 -1
- package/dist/trails/service-exists.trail.d.ts +0 -32
- package/dist/trails/service-exists.trail.d.ts.map +0 -1
- package/dist/trails/service-exists.trail.js +0 -29
- package/dist/trails/service-exists.trail.js.map +0 -1
- package/src/__tests__/no-throw-in-detour-target.test.ts +0 -78
- package/src/__tests__/provision-declarations.test.ts +0 -318
- package/src/__tests__/provision-exists.test.ts +0 -122
- package/src/rules/no-throw-in-detour-target.ts +0 -150
- package/src/rules/valid-detour-refs.ts +0 -187
- package/src/trails/no-throw-in-detour-target.trail.ts +0 -20
- package/src/trails/valid-detour-refs.trail.ts +0 -24
package/src/rules/index.ts
CHANGED
|
@@ -1,38 +1,79 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { circularRefs } from './circular-refs.js';
|
|
2
|
+
import { contourExists } from './contour-exists.js';
|
|
3
|
+
import { contextNoSurfaceTypes } from './context-no-surface-types.js';
|
|
2
4
|
import { crossDeclarations } from './cross-declarations.js';
|
|
5
|
+
import { deadInternalTrail } from './dead-internal-trail.js';
|
|
6
|
+
import { draftFileMarking } from './draft-file-marking.js';
|
|
7
|
+
import { draftVisibleDebt } from './draft-visible-debt.js';
|
|
8
|
+
import { errorMappingCompleteness } from './error-mapping-completeness.js';
|
|
9
|
+
import { exampleValid } from './example-valid.js';
|
|
10
|
+
import { firesDeclarations } from './fires-declarations.js';
|
|
3
11
|
import { implementationReturnsResult } from './implementation-returns-result.js';
|
|
12
|
+
import { incompleteAccessorForStandardOp } from './incomplete-accessor-for-standard-op.js';
|
|
13
|
+
import { incompleteCrud } from './incomplete-crud.js';
|
|
14
|
+
import { intentPropagation } from './intent-propagation.js';
|
|
15
|
+
import { missingVisibility } from './missing-visibility.js';
|
|
16
|
+
import { missingReconcile } from './missing-reconcile.js';
|
|
4
17
|
import { noDirectImplInRoute } from './no-direct-impl-in-route.js';
|
|
5
18
|
import { noDirectImplementationCall } from './no-direct-implementation-call.js';
|
|
6
19
|
import { noSyncResultAssumption } from './no-sync-result-assumption.js';
|
|
7
|
-
import {
|
|
20
|
+
import { noThrowInDetourRecover } from './no-throw-in-detour-recover.js';
|
|
8
21
|
import { noThrowInImplementation } from './no-throw-in-implementation.js';
|
|
22
|
+
import { onReferencesExist } from './on-references-exist.js';
|
|
23
|
+
import { orphanedSignal } from './orphaned-signal.js';
|
|
24
|
+
import { permitGovernance } from './permit-governance.js';
|
|
9
25
|
import { preferSchemaInference } from './prefer-schema-inference.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
26
|
+
import { referenceExists } from './reference-exists.js';
|
|
27
|
+
import { resourceDeclarations } from './resource-declarations.js';
|
|
28
|
+
import { resourceExists } from './resource-exists.js';
|
|
29
|
+
import { resourceIdGrammar } from './resource-id-grammar.js';
|
|
30
|
+
import type { TopoAwareWardenRule, WardenRule } from './types.js';
|
|
31
|
+
import { unreachableDetourShadowing } from './unreachable-detour-shadowing.js';
|
|
32
|
+
import { validDetourContract } from './valid-detour-contract.js';
|
|
13
33
|
import { validDescribeRefs } from './valid-describe-refs.js';
|
|
14
|
-
import {
|
|
34
|
+
import { wardenExportSymmetry } from './warden-export-symmetry.js';
|
|
35
|
+
import { wardenRulesUseAst } from './warden-rules-use-ast.js';
|
|
15
36
|
|
|
16
37
|
export type {
|
|
17
38
|
ProjectAwareWardenRule,
|
|
18
39
|
ProjectContext,
|
|
40
|
+
TopoAwareWardenRule,
|
|
19
41
|
WardenDiagnostic,
|
|
20
42
|
WardenRule,
|
|
21
43
|
WardenSeverity,
|
|
22
44
|
} from './types.js';
|
|
23
45
|
|
|
24
46
|
export { noThrowInImplementation } from './no-throw-in-implementation.js';
|
|
25
|
-
export {
|
|
47
|
+
export { circularRefs } from './circular-refs.js';
|
|
48
|
+
export { contourExists } from './contour-exists.js';
|
|
49
|
+
export { contextNoSurfaceTypes } from './context-no-surface-types.js';
|
|
26
50
|
export { crossDeclarations } from './cross-declarations.js';
|
|
27
|
-
export {
|
|
51
|
+
export { deadInternalTrail } from './dead-internal-trail.js';
|
|
52
|
+
export { draftFileMarking } from './draft-file-marking.js';
|
|
53
|
+
export { draftVisibleDebt } from './draft-visible-debt.js';
|
|
54
|
+
export { errorMappingCompleteness } from './error-mapping-completeness.js';
|
|
55
|
+
export { exampleValid } from './example-valid.js';
|
|
56
|
+
export { firesDeclarations } from './fires-declarations.js';
|
|
57
|
+
export { incompleteAccessorForStandardOp } from './incomplete-accessor-for-standard-op.js';
|
|
58
|
+
export { incompleteCrud } from './incomplete-crud.js';
|
|
59
|
+
export { intentPropagation } from './intent-propagation.js';
|
|
60
|
+
export { missingVisibility } from './missing-visibility.js';
|
|
61
|
+
export { missingReconcile } from './missing-reconcile.js';
|
|
62
|
+
export { onReferencesExist } from './on-references-exist.js';
|
|
28
63
|
export { noDirectImplInRoute } from './no-direct-impl-in-route.js';
|
|
29
64
|
export { noDirectImplementationCall } from './no-direct-implementation-call.js';
|
|
30
65
|
export { noSyncResultAssumption } from './no-sync-result-assumption.js';
|
|
31
66
|
export { implementationReturnsResult } from './implementation-returns-result.js';
|
|
32
|
-
export {
|
|
67
|
+
export { noThrowInDetourRecover } from './no-throw-in-detour-recover.js';
|
|
68
|
+
export { orphanedSignal } from './orphaned-signal.js';
|
|
69
|
+
export { permitGovernance } from './permit-governance.js';
|
|
33
70
|
export { preferSchemaInference } from './prefer-schema-inference.js';
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
71
|
+
export { referenceExists } from './reference-exists.js';
|
|
72
|
+
export { resourceDeclarations } from './resource-declarations.js';
|
|
73
|
+
export { resourceExists } from './resource-exists.js';
|
|
74
|
+
export { resourceIdGrammar } from './resource-id-grammar.js';
|
|
75
|
+
export { unreachableDetourShadowing } from './unreachable-detour-shadowing.js';
|
|
76
|
+
export { validDetourContract } from './valid-detour-contract.js';
|
|
36
77
|
export { validDescribeRefs } from './valid-describe-refs.js';
|
|
37
78
|
|
|
38
79
|
/** All built-in warden rules, keyed by rule name. */
|
|
@@ -41,16 +82,54 @@ export const wardenRules: ReadonlyMap<string, WardenRule> = new Map<
|
|
|
41
82
|
WardenRule
|
|
42
83
|
>([
|
|
43
84
|
[noThrowInImplementation.name, noThrowInImplementation],
|
|
44
|
-
[
|
|
85
|
+
[circularRefs.name, circularRefs],
|
|
86
|
+
[contourExists.name, contourExists],
|
|
87
|
+
[contextNoSurfaceTypes.name, contextNoSurfaceTypes],
|
|
45
88
|
[crossDeclarations.name, crossDeclarations],
|
|
46
|
-
[
|
|
47
|
-
[
|
|
89
|
+
[deadInternalTrail.name, deadInternalTrail],
|
|
90
|
+
[draftFileMarking.name, draftFileMarking],
|
|
91
|
+
[draftVisibleDebt.name, draftVisibleDebt],
|
|
92
|
+
[errorMappingCompleteness.name, errorMappingCompleteness],
|
|
93
|
+
[exampleValid.name, exampleValid],
|
|
94
|
+
[firesDeclarations.name, firesDeclarations],
|
|
95
|
+
[incompleteCrud.name, incompleteCrud],
|
|
96
|
+
[intentPropagation.name, intentPropagation],
|
|
97
|
+
[missingVisibility.name, missingVisibility],
|
|
98
|
+
[missingReconcile.name, missingReconcile],
|
|
99
|
+
[onReferencesExist.name, onReferencesExist],
|
|
100
|
+
[orphanedSignal.name, orphanedSignal],
|
|
101
|
+
[resourceDeclarations.name, resourceDeclarations],
|
|
102
|
+
[referenceExists.name, referenceExists],
|
|
103
|
+
[resourceIdGrammar.name, resourceIdGrammar],
|
|
104
|
+
[resourceExists.name, resourceExists],
|
|
48
105
|
[preferSchemaInference.name, preferSchemaInference],
|
|
49
106
|
[validDescribeRefs.name, validDescribeRefs],
|
|
50
|
-
[validDetourRefs.name, validDetourRefs],
|
|
51
107
|
[noDirectImplementationCall.name, noDirectImplementationCall],
|
|
52
108
|
[noSyncResultAssumption.name, noSyncResultAssumption],
|
|
53
109
|
[implementationReturnsResult.name, implementationReturnsResult],
|
|
54
|
-
[
|
|
110
|
+
[noThrowInDetourRecover.name, noThrowInDetourRecover],
|
|
55
111
|
[noDirectImplInRoute.name, noDirectImplInRoute],
|
|
112
|
+
[unreachableDetourShadowing.name, unreachableDetourShadowing],
|
|
113
|
+
[wardenExportSymmetry.name, wardenExportSymmetry],
|
|
114
|
+
[wardenRulesUseAst.name, wardenRulesUseAst],
|
|
56
115
|
]);
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Built-in topo-aware warden rules, keyed by rule name.
|
|
119
|
+
*
|
|
120
|
+
* These rules inspect the compiled runtime trail graph once per topo,
|
|
121
|
+
* rather than scanning source files. Kept in a separate registry because
|
|
122
|
+
* their dispatch shape differs from `WardenRule` / `ProjectAwareWardenRule`.
|
|
123
|
+
*
|
|
124
|
+
* @remarks
|
|
125
|
+
* Topo-aware rules only fire when the warden runtime is invoked with a
|
|
126
|
+
* resolved `Topo` (see `WardenOptions.topo`). Runs without a topo — e.g.
|
|
127
|
+
* pure source-directory lints — silently skip this registry. Rules
|
|
128
|
+
* registered here must tolerate non-execution when no topo is available.
|
|
129
|
+
*/
|
|
130
|
+
export const wardenTopoRules: ReadonlyMap<string, TopoAwareWardenRule> =
|
|
131
|
+
new Map<string, TopoAwareWardenRule>([
|
|
132
|
+
[incompleteAccessorForStandardOp.name, incompleteAccessorForStandardOp],
|
|
133
|
+
[permitGovernance.name, permitGovernance],
|
|
134
|
+
[validDetourContract.name, validDetourContract],
|
|
135
|
+
]);
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { Intent } from '@ontrails/core';
|
|
2
|
+
import {
|
|
3
|
+
collectNamedTrailIds,
|
|
4
|
+
collectTrailIntentsById,
|
|
5
|
+
extractDefinitionCrossTargetIds,
|
|
6
|
+
findConfigProperty,
|
|
7
|
+
findTrailDefinitions,
|
|
8
|
+
getStringValue,
|
|
9
|
+
isStringLiteral,
|
|
10
|
+
offsetToLine,
|
|
11
|
+
parse,
|
|
12
|
+
} from './ast.js';
|
|
13
|
+
import type { AstNode } from './ast.js';
|
|
14
|
+
import { isTestFile } from './scan.js';
|
|
15
|
+
import type {
|
|
16
|
+
ProjectAwareWardenRule,
|
|
17
|
+
ProjectContext,
|
|
18
|
+
WardenDiagnostic,
|
|
19
|
+
} from './types.js';
|
|
20
|
+
|
|
21
|
+
const extractTrailIntent = (config: AstNode): Intent => {
|
|
22
|
+
const intentProp = findConfigProperty(config, 'intent');
|
|
23
|
+
const intentValue = intentProp?.value as AstNode | undefined;
|
|
24
|
+
if (!intentValue || !isStringLiteral(intentValue)) {
|
|
25
|
+
return 'write';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const value = getStringValue(intentValue);
|
|
29
|
+
return value === 'destroy' || value === 'read' ? value : 'write';
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const buildIntentPropagationDiagnostic = (
|
|
33
|
+
trailId: string,
|
|
34
|
+
targetTrailId: string,
|
|
35
|
+
targetIntent: Exclude<Intent, 'read'>,
|
|
36
|
+
filePath: string,
|
|
37
|
+
line: number
|
|
38
|
+
): WardenDiagnostic => ({
|
|
39
|
+
filePath,
|
|
40
|
+
line,
|
|
41
|
+
message: `Trail "${trailId}" declares intent: 'read' but crosses "${targetTrailId}" with intent: '${targetIntent}'. Read trails must not compose write or destroy side effects.`,
|
|
42
|
+
rule: 'intent-propagation',
|
|
43
|
+
severity: 'warn',
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const buildDiagnosticsForCrossTargets = (
|
|
47
|
+
trailId: string,
|
|
48
|
+
targetTrailIds: readonly string[],
|
|
49
|
+
filePath: string,
|
|
50
|
+
line: number,
|
|
51
|
+
trailIntentsById: ReadonlyMap<string, Intent>
|
|
52
|
+
): readonly WardenDiagnostic[] =>
|
|
53
|
+
targetTrailIds.flatMap((targetTrailId) => {
|
|
54
|
+
const targetIntent = trailIntentsById.get(targetTrailId);
|
|
55
|
+
if (!targetIntent || targetIntent === 'read') {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return [
|
|
60
|
+
buildIntentPropagationDiagnostic(
|
|
61
|
+
trailId,
|
|
62
|
+
targetTrailId,
|
|
63
|
+
targetIntent,
|
|
64
|
+
filePath,
|
|
65
|
+
line
|
|
66
|
+
),
|
|
67
|
+
];
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const buildDiagnosticsForTrail = (
|
|
71
|
+
def: ReturnType<typeof findTrailDefinitions>[number],
|
|
72
|
+
sourceCode: string,
|
|
73
|
+
filePath: string,
|
|
74
|
+
namedTrailIds: ReadonlyMap<string, string>,
|
|
75
|
+
trailIntentsById: ReadonlyMap<string, Intent>
|
|
76
|
+
): readonly WardenDiagnostic[] => {
|
|
77
|
+
if (def.kind !== 'trail' || extractTrailIntent(def.config) !== 'read') {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return buildDiagnosticsForCrossTargets(
|
|
82
|
+
def.id,
|
|
83
|
+
extractDefinitionCrossTargetIds(def.config, sourceCode, namedTrailIds),
|
|
84
|
+
filePath,
|
|
85
|
+
offsetToLine(sourceCode, def.start),
|
|
86
|
+
trailIntentsById
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const checkIntentPropagation = (
|
|
91
|
+
ast: AstNode | null,
|
|
92
|
+
sourceCode: string,
|
|
93
|
+
filePath: string,
|
|
94
|
+
trailIntentsById: ReadonlyMap<string, Intent>
|
|
95
|
+
): readonly WardenDiagnostic[] => {
|
|
96
|
+
if (isTestFile(filePath) || !ast) {
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const namedTrailIds = collectNamedTrailIds(ast);
|
|
101
|
+
return findTrailDefinitions(ast).flatMap((def) =>
|
|
102
|
+
buildDiagnosticsForTrail(
|
|
103
|
+
def,
|
|
104
|
+
sourceCode,
|
|
105
|
+
filePath,
|
|
106
|
+
namedTrailIds,
|
|
107
|
+
trailIntentsById
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const intentPropagation: ProjectAwareWardenRule = {
|
|
113
|
+
check(sourceCode: string, filePath: string): readonly WardenDiagnostic[] {
|
|
114
|
+
const ast = parse(filePath, sourceCode);
|
|
115
|
+
return checkIntentPropagation(
|
|
116
|
+
ast,
|
|
117
|
+
sourceCode,
|
|
118
|
+
filePath,
|
|
119
|
+
ast ? collectTrailIntentsById(ast) : new Map<string, Intent>()
|
|
120
|
+
);
|
|
121
|
+
},
|
|
122
|
+
checkWithContext(
|
|
123
|
+
sourceCode: string,
|
|
124
|
+
filePath: string,
|
|
125
|
+
context: ProjectContext
|
|
126
|
+
): readonly WardenDiagnostic[] {
|
|
127
|
+
const ast = parse(filePath, sourceCode);
|
|
128
|
+
const localTrailIntentsById = ast
|
|
129
|
+
? collectTrailIntentsById(ast)
|
|
130
|
+
: new Map<string, Intent>();
|
|
131
|
+
return checkIntentPropagation(
|
|
132
|
+
ast,
|
|
133
|
+
sourceCode,
|
|
134
|
+
filePath,
|
|
135
|
+
context.trailIntentsById ?? localTrailIntentsById
|
|
136
|
+
);
|
|
137
|
+
},
|
|
138
|
+
description:
|
|
139
|
+
"Warn when a trail declaring intent: 'read' crosses a trail whose normalized intent is write or destroy.",
|
|
140
|
+
name: 'intent-propagation',
|
|
141
|
+
severity: 'warn',
|
|
142
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import {
|
|
2
|
+
collectCrudTableIds,
|
|
3
|
+
collectReconcileTableIds,
|
|
4
|
+
findStoreTableDefinitions,
|
|
5
|
+
offsetToLine,
|
|
6
|
+
parse,
|
|
7
|
+
} from './ast.js';
|
|
8
|
+
import type { AstNode } from './ast.js';
|
|
9
|
+
import { isTestFile } from './scan.js';
|
|
10
|
+
import type {
|
|
11
|
+
ProjectAwareWardenRule,
|
|
12
|
+
ProjectContext,
|
|
13
|
+
WardenDiagnostic,
|
|
14
|
+
} from './types.js';
|
|
15
|
+
|
|
16
|
+
const buildMissingReconcileDiagnostic = (
|
|
17
|
+
tableId: string,
|
|
18
|
+
filePath: string,
|
|
19
|
+
line: number
|
|
20
|
+
): WardenDiagnostic => ({
|
|
21
|
+
filePath,
|
|
22
|
+
line,
|
|
23
|
+
message: `Versioned store table "${tableId}" is used with CRUD factories but has no reconcile trail. Add reconcile(...) to complete the versioned store pattern.`,
|
|
24
|
+
rule: 'missing-reconcile',
|
|
25
|
+
severity: 'warn',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const checkMissingReconcile = (
|
|
29
|
+
ast: AstNode | null,
|
|
30
|
+
sourceCode: string,
|
|
31
|
+
filePath: string,
|
|
32
|
+
crudTableIds: ReadonlySet<string>,
|
|
33
|
+
reconcileTableIds: ReadonlySet<string>
|
|
34
|
+
): readonly WardenDiagnostic[] => {
|
|
35
|
+
if (isTestFile(filePath) || !ast) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const diagnostics: WardenDiagnostic[] = [];
|
|
40
|
+
|
|
41
|
+
for (const definition of findStoreTableDefinitions(ast)) {
|
|
42
|
+
if (
|
|
43
|
+
!definition.versioned ||
|
|
44
|
+
!crudTableIds.has(definition.key) ||
|
|
45
|
+
reconcileTableIds.has(definition.key)
|
|
46
|
+
) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
diagnostics.push(
|
|
51
|
+
buildMissingReconcileDiagnostic(
|
|
52
|
+
definition.name,
|
|
53
|
+
filePath,
|
|
54
|
+
offsetToLine(sourceCode, definition.start)
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return diagnostics;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const missingReconcile: ProjectAwareWardenRule = {
|
|
63
|
+
check(sourceCode: string, filePath: string): readonly WardenDiagnostic[] {
|
|
64
|
+
const ast = parse(filePath, sourceCode);
|
|
65
|
+
return checkMissingReconcile(
|
|
66
|
+
ast,
|
|
67
|
+
sourceCode,
|
|
68
|
+
filePath,
|
|
69
|
+
ast ? collectCrudTableIds(ast) : new Set<string>(),
|
|
70
|
+
ast ? collectReconcileTableIds(ast) : new Set<string>()
|
|
71
|
+
);
|
|
72
|
+
},
|
|
73
|
+
checkWithContext(
|
|
74
|
+
sourceCode: string,
|
|
75
|
+
filePath: string,
|
|
76
|
+
context: ProjectContext
|
|
77
|
+
): readonly WardenDiagnostic[] {
|
|
78
|
+
const ast = parse(filePath, sourceCode);
|
|
79
|
+
const localCrudTableIds = ast
|
|
80
|
+
? collectCrudTableIds(ast)
|
|
81
|
+
: new Set<string>();
|
|
82
|
+
const localReconcileTableIds = ast
|
|
83
|
+
? collectReconcileTableIds(ast)
|
|
84
|
+
: new Set<string>();
|
|
85
|
+
|
|
86
|
+
return checkMissingReconcile(
|
|
87
|
+
ast,
|
|
88
|
+
sourceCode,
|
|
89
|
+
filePath,
|
|
90
|
+
context.crudTableIds ?? localCrudTableIds,
|
|
91
|
+
context.reconcileTableIds ?? localReconcileTableIds
|
|
92
|
+
);
|
|
93
|
+
},
|
|
94
|
+
description:
|
|
95
|
+
'Warn when a versioned store table participates in CRUD factory generation without a matching reconcile trail.',
|
|
96
|
+
name: 'missing-reconcile',
|
|
97
|
+
severity: 'warn',
|
|
98
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { collectCrossTargetTrailIds, parse } from './ast.js';
|
|
2
|
+
import { isTestFile } from './scan.js';
|
|
3
|
+
import {
|
|
4
|
+
findTrailLikeSpecs,
|
|
5
|
+
parseStringLiteral,
|
|
6
|
+
parseZodObjectShape,
|
|
7
|
+
} from './specs.js';
|
|
8
|
+
import type { TrailLikeSpec } from './specs.js';
|
|
9
|
+
import type {
|
|
10
|
+
ProjectAwareWardenRule,
|
|
11
|
+
ProjectContext,
|
|
12
|
+
WardenDiagnostic,
|
|
13
|
+
} from './types.js';
|
|
14
|
+
|
|
15
|
+
/** Check legacy `meta: { internal: true }` convention (mirrors runtime effectiveVisibility). */
|
|
16
|
+
const hasLegacyMetaInternal = (spec: TrailLikeSpec): boolean => {
|
|
17
|
+
const meta = spec.properties.get('meta')?.value ?? '';
|
|
18
|
+
return /(?:^|[{,])\s*internal\s*:\s*true/.test(meta);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const trailVisibility = (spec: TrailLikeSpec): 'internal' | 'public' => {
|
|
22
|
+
if (
|
|
23
|
+
parseStringLiteral(spec.properties.get('visibility')?.value ?? '') ===
|
|
24
|
+
'internal'
|
|
25
|
+
) {
|
|
26
|
+
return 'internal';
|
|
27
|
+
}
|
|
28
|
+
return hasLegacyMetaInternal(spec) ? 'internal' : 'public';
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const hasRequiredCrossInput = (spec: TrailLikeSpec): boolean => {
|
|
32
|
+
const crossInput = spec.properties.get('crossInput');
|
|
33
|
+
if (!crossInput) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const fields = parseZodObjectShape(crossInput.value);
|
|
38
|
+
return [...fields.values()].some((field) => field.required);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const buildMissingVisibilityDiagnostic = (
|
|
42
|
+
trailId: string,
|
|
43
|
+
filePath: string,
|
|
44
|
+
line: number
|
|
45
|
+
): WardenDiagnostic => ({
|
|
46
|
+
filePath,
|
|
47
|
+
line,
|
|
48
|
+
message: `Trail "${trailId}" is crossed elsewhere and declares required crossInput fields, but it is still public. Consider visibility: 'internal' so trailheads do not expose a trail that only works through ctx.cross().`,
|
|
49
|
+
rule: 'missing-visibility',
|
|
50
|
+
severity: 'warn',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const checkMissingVisibility = (
|
|
54
|
+
sourceCode: string,
|
|
55
|
+
filePath: string,
|
|
56
|
+
crossedTrailIds: ReadonlySet<string>
|
|
57
|
+
): readonly WardenDiagnostic[] => {
|
|
58
|
+
if (isTestFile(filePath)) {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const diagnostics: WardenDiagnostic[] = [];
|
|
63
|
+
|
|
64
|
+
for (const spec of findTrailLikeSpecs(sourceCode)) {
|
|
65
|
+
if (
|
|
66
|
+
spec.kind !== 'trail' ||
|
|
67
|
+
trailVisibility(spec) === 'internal' ||
|
|
68
|
+
!crossedTrailIds.has(spec.id) ||
|
|
69
|
+
!hasRequiredCrossInput(spec)
|
|
70
|
+
) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
diagnostics.push(
|
|
75
|
+
buildMissingVisibilityDiagnostic(spec.id, filePath, spec.line)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return diagnostics;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const missingVisibility: ProjectAwareWardenRule = {
|
|
83
|
+
check(sourceCode: string, filePath: string): readonly WardenDiagnostic[] {
|
|
84
|
+
const ast = parse(filePath, sourceCode);
|
|
85
|
+
return checkMissingVisibility(
|
|
86
|
+
sourceCode,
|
|
87
|
+
filePath,
|
|
88
|
+
ast ? collectCrossTargetTrailIds(ast, sourceCode) : new Set<string>()
|
|
89
|
+
);
|
|
90
|
+
},
|
|
91
|
+
checkWithContext(
|
|
92
|
+
sourceCode: string,
|
|
93
|
+
filePath: string,
|
|
94
|
+
context: ProjectContext
|
|
95
|
+
): readonly WardenDiagnostic[] {
|
|
96
|
+
const ast = parse(filePath, sourceCode);
|
|
97
|
+
const localCrossTargetTrailIds = ast
|
|
98
|
+
? collectCrossTargetTrailIds(ast, sourceCode)
|
|
99
|
+
: new Set<string>();
|
|
100
|
+
return checkMissingVisibility(
|
|
101
|
+
sourceCode,
|
|
102
|
+
filePath,
|
|
103
|
+
context.crossTargetTrailIds ?? localCrossTargetTrailIds
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
description:
|
|
107
|
+
'Coach when a crossed trail still looks composition-only because it declares required crossInput but remains public.',
|
|
108
|
+
name: 'missing-visibility',
|
|
109
|
+
severity: 'warn',
|
|
110
|
+
};
|
|
@@ -53,10 +53,6 @@ const hasCrossesProperty = (config: AstNode): boolean =>
|
|
|
53
53
|
*/
|
|
54
54
|
export const noDirectImplInRoute: WardenRule = {
|
|
55
55
|
check(sourceCode: string, filePath: string): readonly WardenDiagnostic[] {
|
|
56
|
-
if (!/\btrail\s*\(/.test(sourceCode)) {
|
|
57
|
-
return [];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
56
|
const ast = parse(filePath, sourceCode);
|
|
61
57
|
if (!ast) {
|
|
62
58
|
return [];
|
|
@@ -31,7 +31,7 @@ export const noDirectImplementationCall: WardenRule = {
|
|
|
31
31
|
filePath,
|
|
32
32
|
line: offsetToLine(sourceCode, node.start),
|
|
33
33
|
message:
|
|
34
|
-
'Use ctx.cross("trailId", input) instead of direct .blaze() calls. Direct implementation access bypasses validation, tracing, and
|
|
34
|
+
'Use ctx.cross("trailId", input) instead of direct .blaze() calls. Direct implementation access bypasses validation, tracing, and layers.',
|
|
35
35
|
rule: 'no-direct-implementation-call',
|
|
36
36
|
severity: 'warn',
|
|
37
37
|
});
|