@ontrails/warden 1.0.0-beta.2 → 1.0.0-beta.22
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 +508 -6
- package/README.md +77 -26
- package/bin/warden.ts +50 -0
- package/package.json +27 -5
- package/src/adapter-check.ts +136 -0
- package/src/ast.ts +28 -0
- package/src/cli.ts +1374 -103
- package/src/command.ts +953 -0
- package/src/config.ts +184 -0
- package/src/draft.ts +22 -0
- package/src/drift.ts +106 -22
- package/src/fix.ts +120 -0
- package/src/formatters.ts +79 -9
- package/src/guide.ts +245 -0
- package/src/index.ts +206 -14
- package/src/project-context.ts +163 -0
- package/src/resolve.ts +530 -0
- package/src/rules/activation-orphan.ts +97 -0
- package/src/rules/ast.ts +3176 -85
- package/src/rules/circular-refs.ts +154 -0
- package/src/rules/composes-declarations.ts +704 -0
- package/src/rules/context-no-surface-types.ts +68 -8
- package/src/rules/contour-exists.ts +251 -0
- package/src/rules/contour-ids.ts +15 -0
- package/src/rules/dead-internal-trail.ts +154 -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 +288 -0
- package/src/rules/example-valid.ts +401 -0
- package/src/rules/fires-declarations.ts +758 -0
- package/src/rules/implementation-returns-result.ts +1265 -95
- package/src/rules/incomplete-accessor-for-standard-op.ts +272 -0
- package/src/rules/incomplete-crud.ts +580 -0
- package/src/rules/index.ts +219 -18
- package/src/rules/intent-propagation.ts +127 -0
- package/src/rules/layer-field-name-drift.ts +96 -0
- package/src/rules/metadata.ts +654 -0
- package/src/rules/missing-reconcile.ts +98 -0
- package/src/rules/missing-visibility.ts +110 -0
- package/src/rules/no-destructured-compose.ts +192 -0
- package/src/rules/no-dev-permit-in-source.ts +99 -0
- package/src/rules/no-direct-implementation-call.ts +7 -7
- package/src/rules/no-legacy-layer-imports.ts +211 -0
- package/src/rules/no-native-error-result.ts +111 -0
- package/src/rules/no-redundant-result-error-wrap.ts +331 -0
- package/src/rules/no-retired-cross-vocabulary.ts +194 -0
- package/src/rules/no-sync-result-assumption.ts +1134 -99
- package/src/rules/no-throw-in-detour-recover.ts +225 -0
- package/src/rules/no-throw-in-implementation.ts +10 -9
- package/src/rules/no-top-level-surface.ts +389 -0
- package/src/rules/on-references-exist.ts +194 -0
- package/src/rules/orphaned-signal.ts +150 -0
- package/src/rules/owner-projection-parity.ts +146 -0
- package/src/rules/permit-governance.ts +25 -0
- package/src/rules/public-export-example-coverage.ts +553 -0
- package/src/rules/public-internal-deep-imports.ts +517 -0
- package/src/rules/public-output-schema.ts +29 -0
- package/src/rules/public-union-output-discriminants.ts +150 -0
- package/src/rules/read-intent-fires.ts +187 -0
- package/src/rules/reference-exists.ts +98 -0
- package/src/rules/registry-names.ts +145 -0
- package/src/rules/resolved-import-boundary.ts +146 -0
- package/src/rules/resource-declarations.ts +704 -0
- package/src/rules/resource-exists.ts +179 -0
- package/src/rules/resource-id-grammar.ts +65 -0
- package/src/rules/resource-mock-coverage.ts +115 -0
- package/src/rules/scan.ts +38 -25
- package/src/rules/scheduled-destroy-intent.ts +44 -0
- package/src/rules/signal-graph-coaching.ts +191 -0
- package/src/rules/specs.ts +9 -5
- package/src/rules/static-resource-accessor-preference.ts +657 -0
- package/src/rules/surface-facet-coherence.ts +370 -0
- package/src/rules/trail-versioning-source.ts +1094 -0
- package/src/rules/trail-versioning-topo.ts +172 -0
- package/src/rules/types.ts +270 -6
- package/src/rules/unmaterialized-activation-source.ts +84 -0
- package/src/rules/unreachable-detour-shadowing.ts +344 -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/rules/webhook-route-collision.ts +243 -0
- package/src/trails/activation-orphan.trail.ts +84 -0
- package/src/trails/circular-refs.trail.ts +29 -0
- package/src/trails/composes-declarations.trail.ts +22 -0
- package/src/trails/context-no-surface-types.trail.ts +21 -0
- package/src/trails/contour-exists.trail.ts +21 -0
- package/src/trails/dead-internal-trail.trail.ts +26 -0
- package/src/trails/deprecation-without-guidance.trail.ts +21 -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 +23 -0
- package/src/trails/fork-without-preserved-blaze.trail.ts +31 -0
- package/src/trails/implementation-returns-result.trail.ts +20 -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 +78 -0
- package/src/trails/intent-propagation.trail.ts +30 -0
- package/src/trails/layer-field-name-drift.trail.ts +39 -0
- package/src/trails/marker-schema-unsupported.trail.ts +23 -0
- package/src/trails/missing-reconcile.trail.ts +33 -0
- package/src/trails/missing-visibility.trail.ts +22 -0
- package/src/trails/no-destructured-compose.trail.ts +44 -0
- package/src/trails/no-dev-permit-in-source.trail.ts +16 -0
- package/src/trails/no-direct-implementation-call.trail.ts +16 -0
- package/src/trails/no-legacy-layer-imports.trail.ts +41 -0
- package/src/trails/no-native-error-result.trail.ts +18 -0
- package/src/trails/no-redundant-result-error-wrap.trail.ts +55 -0
- package/src/trails/no-retired-cross-vocabulary.trail.ts +42 -0
- package/src/trails/no-sync-result-assumption.trail.ts +19 -0
- package/src/trails/no-throw-in-detour-recover.trail.ts +24 -0
- package/src/trails/no-throw-in-implementation.trail.ts +20 -0
- package/src/trails/no-top-level-surface.trail.ts +43 -0
- package/src/trails/on-references-exist.trail.ts +21 -0
- package/src/trails/orphaned-signal.trail.ts +36 -0
- package/src/trails/owner-projection-parity.trail.ts +26 -0
- package/src/trails/pending-force.trail.ts +21 -0
- package/src/trails/permit-governance.trail.ts +51 -0
- package/src/trails/prefer-schema-inference.trail.ts +21 -0
- package/src/trails/public-export-example-coverage.trail.ts +16 -0
- package/src/trails/public-internal-deep-imports.trail.ts +94 -0
- package/src/trails/public-output-schema.trail.ts +55 -0
- package/src/trails/public-union-output-discriminants.trail.ts +33 -0
- package/src/trails/read-intent-fires.trail.ts +20 -0
- package/src/trails/reference-exists.trail.ts +25 -0
- package/src/trails/resolved-import-boundary.trail.ts +109 -0
- package/src/trails/resource-declarations.trail.ts +25 -0
- package/src/trails/resource-exists.trail.ts +27 -0
- package/src/trails/resource-id-grammar.trail.ts +39 -0
- package/src/trails/resource-mock-coverage.trail.ts +40 -0
- package/src/trails/run.ts +162 -0
- package/src/trails/scheduled-destroy-intent.trail.ts +56 -0
- package/src/trails/schema.ts +194 -0
- package/src/trails/signal-graph-coaching.trail.ts +77 -0
- package/src/trails/static-resource-accessor-preference.trail.ts +25 -0
- package/src/trails/surface-facet-coherence.trail.ts +25 -0
- package/src/trails/topo.ts +6 -0
- package/src/trails/unmaterialized-activation-source.trail.ts +72 -0
- package/src/trails/unreachable-detour-shadowing.trail.ts +45 -0
- package/src/trails/valid-describe-refs.trail.ts +18 -0
- package/src/trails/valid-detour-contract.trail.ts +71 -0
- package/src/trails/version-gap.trail.ts +35 -0
- package/src/trails/version-pinned-compose.trail.ts +23 -0
- package/src/trails/version-without-examples.trail.ts +38 -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/webhook-route-collision.trail.ts +50 -0
- package/src/trails/wrap-rule.ts +213 -0
- package/src/workspaces.ts +238 -0
- package/.turbo/turbo-build.log +0 -1
- package/.turbo/turbo-lint.log +0 -3
- package/.turbo/turbo-typecheck.log +0 -1
- package/dist/cli.d.ts +0 -46
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -221
- package/dist/cli.js.map +0 -1
- package/dist/drift.d.ts +0 -26
- package/dist/drift.d.ts.map +0 -1
- package/dist/drift.js +0 -27
- package/dist/drift.js.map +0 -1
- package/dist/formatters.d.ts +0 -29
- package/dist/formatters.d.ts.map +0 -1
- package/dist/formatters.js +0 -87
- package/dist/formatters.js.map +0 -1
- package/dist/index.d.ts +0 -26
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -26
- package/dist/index.js.map +0 -1
- package/dist/rules/ast.d.ts +0 -41
- package/dist/rules/ast.d.ts.map +0 -1
- package/dist/rules/ast.js +0 -163
- package/dist/rules/ast.js.map +0 -1
- package/dist/rules/context-no-surface-types.d.ts +0 -12
- package/dist/rules/context-no-surface-types.d.ts.map +0 -1
- package/dist/rules/context-no-surface-types.js +0 -96
- package/dist/rules/context-no-surface-types.js.map +0 -1
- package/dist/rules/implementation-returns-result.d.ts +0 -13
- package/dist/rules/implementation-returns-result.d.ts.map +0 -1
- package/dist/rules/implementation-returns-result.js +0 -231
- package/dist/rules/implementation-returns-result.js.map +0 -1
- package/dist/rules/index.d.ts +0 -22
- package/dist/rules/index.d.ts.map +0 -1
- package/dist/rules/index.js +0 -41
- package/dist/rules/index.js.map +0 -1
- package/dist/rules/no-direct-impl-in-route.d.ts +0 -12
- package/dist/rules/no-direct-impl-in-route.d.ts.map +0 -1
- package/dist/rules/no-direct-impl-in-route.js +0 -46
- package/dist/rules/no-direct-impl-in-route.js.map +0 -1
- package/dist/rules/no-direct-implementation-call.d.ts +0 -12
- package/dist/rules/no-direct-implementation-call.d.ts.map +0 -1
- package/dist/rules/no-direct-implementation-call.js +0 -39
- package/dist/rules/no-direct-implementation-call.js.map +0 -1
- package/dist/rules/no-sync-result-assumption.d.ts +0 -6
- package/dist/rules/no-sync-result-assumption.d.ts.map +0 -1
- package/dist/rules/no-sync-result-assumption.js +0 -98
- package/dist/rules/no-sync-result-assumption.js.map +0 -1
- package/dist/rules/no-throw-in-detour-target.d.ts +0 -12
- package/dist/rules/no-throw-in-detour-target.d.ts.map +0 -1
- package/dist/rules/no-throw-in-detour-target.js +0 -87
- package/dist/rules/no-throw-in-detour-target.js.map +0 -1
- package/dist/rules/no-throw-in-implementation.d.ts +0 -9
- package/dist/rules/no-throw-in-implementation.d.ts.map +0 -1
- package/dist/rules/no-throw-in-implementation.js +0 -34
- package/dist/rules/no-throw-in-implementation.js.map +0 -1
- package/dist/rules/prefer-schema-inference.d.ts +0 -7
- package/dist/rules/prefer-schema-inference.d.ts.map +0 -1
- package/dist/rules/prefer-schema-inference.js +0 -86
- package/dist/rules/prefer-schema-inference.js.map +0 -1
- package/dist/rules/scan.d.ts +0 -8
- package/dist/rules/scan.d.ts.map +0 -1
- package/dist/rules/scan.js +0 -32
- package/dist/rules/scan.js.map +0 -1
- package/dist/rules/specs.d.ts +0 -29
- package/dist/rules/specs.d.ts.map +0 -1
- package/dist/rules/specs.js +0 -192
- package/dist/rules/specs.js.map +0 -1
- package/dist/rules/structure.d.ts +0 -13
- package/dist/rules/structure.d.ts.map +0 -1
- package/dist/rules/structure.js +0 -142
- package/dist/rules/structure.js.map +0 -1
- package/dist/rules/types.d.ts +0 -52
- package/dist/rules/types.d.ts.map +0 -1
- package/dist/rules/types.js +0 -2
- package/dist/rules/types.js.map +0 -1
- package/dist/rules/valid-describe-refs.d.ts +0 -7
- package/dist/rules/valid-describe-refs.d.ts.map +0 -1
- package/dist/rules/valid-describe-refs.js +0 -51
- package/dist/rules/valid-describe-refs.js.map +0 -1
- package/dist/rules/valid-detour-refs.d.ts +0 -6
- package/dist/rules/valid-detour-refs.d.ts.map +0 -1
- package/dist/rules/valid-detour-refs.js +0 -116
- package/dist/rules/valid-detour-refs.js.map +0 -1
- package/src/__tests__/cli.test.ts +0 -198
- package/src/__tests__/drift.test.ts +0 -74
- package/src/__tests__/formatters.test.ts +0 -157
- package/src/__tests__/implementation-returns-result.test.ts +0 -75
- package/src/__tests__/no-direct-implementation-call.test.ts +0 -83
- package/src/__tests__/no-sync-result-assumption.test.ts +0 -85
- package/src/__tests__/no-throw-in-detour-target.test.ts +0 -78
- package/src/__tests__/prefer-schema-inference.test.ts +0 -84
- package/src/__tests__/rules.test.ts +0 -188
- package/src/__tests__/valid-describe-refs.test.ts +0 -60
- package/src/rules/no-direct-impl-in-route.ts +0 -77
- package/src/rules/no-throw-in-detour-target.ts +0 -150
- package/src/rules/valid-detour-refs.ts +0 -187
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
package/dist/formatters.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CI-oriented formatters for warden reports.
|
|
3
|
-
*
|
|
4
|
-
* Each formatter takes a `WardenReport` and produces output suited to a
|
|
5
|
-
* specific CI environment: GitHub Actions annotations, structured JSON,
|
|
6
|
-
* or a concise markdown summary.
|
|
7
|
-
*/
|
|
8
|
-
/** Map warden severity to GitHub Actions annotation level. */
|
|
9
|
-
const ghLevel = {
|
|
10
|
-
error: 'error',
|
|
11
|
-
warn: 'warning',
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Produce GitHub Actions workflow command annotations, one per diagnostic.
|
|
15
|
-
*
|
|
16
|
-
* Severity mapping: `error` to `::error`, `warn` to `::warning`.
|
|
17
|
-
* Drift staleness is emitted as a single `::error` annotation when detected.
|
|
18
|
-
*/
|
|
19
|
-
export const formatGitHubAnnotations = (report) => {
|
|
20
|
-
const lines = [];
|
|
21
|
-
for (const d of report.diagnostics) {
|
|
22
|
-
const level = ghLevel[d.severity];
|
|
23
|
-
lines.push(`::${level} file=${d.filePath},line=${String(d.line)}::${d.rule}: ${d.message}`);
|
|
24
|
-
}
|
|
25
|
-
if (report.drift?.stale) {
|
|
26
|
-
lines.push('::error::drift: surface.lock is stale (regenerate with `trails survey generate`)');
|
|
27
|
-
}
|
|
28
|
-
return lines.join('\n');
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Produce a structured JSON string from the report.
|
|
32
|
-
*
|
|
33
|
-
* Includes a `summary` object with error, warning, and suggestion counts
|
|
34
|
-
* for easy consumption by downstream tooling.
|
|
35
|
-
*/
|
|
36
|
-
export const formatJson = (report) => {
|
|
37
|
-
const summary = {
|
|
38
|
-
errors: report.errorCount,
|
|
39
|
-
suggestions: 0,
|
|
40
|
-
warnings: report.warnCount,
|
|
41
|
-
};
|
|
42
|
-
return JSON.stringify({
|
|
43
|
-
diagnostics: report.diagnostics,
|
|
44
|
-
drift: report.drift,
|
|
45
|
-
passed: report.passed,
|
|
46
|
-
summary,
|
|
47
|
-
}, null, 2);
|
|
48
|
-
};
|
|
49
|
-
/** Format a diagnostic as a markdown list item. */
|
|
50
|
-
const diagnosticLine = (d) => `- \`${d.filePath}:${String(d.line)}\` — ${d.rule}: ${d.message}`;
|
|
51
|
-
/** Render a severity group as a headed markdown section, or empty array. */
|
|
52
|
-
const severitySection = (heading, diagnostics) => {
|
|
53
|
-
if (diagnostics.length === 0) {
|
|
54
|
-
return [];
|
|
55
|
-
}
|
|
56
|
-
return ['', `### ${heading}`, ...diagnostics.map(diagnosticLine)];
|
|
57
|
-
};
|
|
58
|
-
/** Render a drift section if stale, otherwise empty array. */
|
|
59
|
-
const driftSection = (drift) => {
|
|
60
|
-
if (!drift?.stale) {
|
|
61
|
-
return [];
|
|
62
|
-
}
|
|
63
|
-
return [
|
|
64
|
-
'',
|
|
65
|
-
'### Drift',
|
|
66
|
-
'- surface.lock is stale (regenerate with `trails survey generate`)',
|
|
67
|
-
];
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Produce a concise markdown summary suitable for a GitHub job summary or PR comment.
|
|
71
|
-
*
|
|
72
|
-
* Groups diagnostics by severity and includes drift status when relevant.
|
|
73
|
-
*/
|
|
74
|
-
export const formatSummary = (report) => {
|
|
75
|
-
const result = report.passed ? 'PASS' : 'FAIL';
|
|
76
|
-
const errors = report.diagnostics.filter((d) => d.severity === 'error');
|
|
77
|
-
const warnings = report.diagnostics.filter((d) => d.severity === 'warn');
|
|
78
|
-
return [
|
|
79
|
-
'## Warden Report',
|
|
80
|
-
'',
|
|
81
|
-
`**Result: ${result}** | ${String(report.errorCount)} errors, ${String(report.warnCount)} warnings`,
|
|
82
|
-
...severitySection('Errors', errors),
|
|
83
|
-
...severitySection('Warnings', warnings),
|
|
84
|
-
...driftSection(report.drift),
|
|
85
|
-
].join('\n');
|
|
86
|
-
};
|
|
87
|
-
//# sourceMappingURL=formatters.js.map
|
package/dist/formatters.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,8DAA8D;AAC9D,MAAM,OAAO,GAAmC;IAC9C,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,SAAS;CAChB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAAoB,EAAU,EAAE;IACtE,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QAClC,KAAK,CAAC,IAAI,CACR,KAAK,KAAK,SAAS,CAAC,CAAC,QAAQ,SAAS,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAChF,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC;QACxB,KAAK,CAAC,IAAI,CACR,kFAAkF,CACnF,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAoB,EAAU,EAAE;IACzD,MAAM,OAAO,GAAG;QACd,MAAM,EAAE,MAAM,CAAC,UAAU;QACzB,WAAW,EAAE,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC,SAAS;KAC3B,CAAC;IAEF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C;IACxE,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC;IAEzE,OAAO;QACL,kBAAkB;QAClB,EAAE;QACF,aAAa,MAAM,QAAQ,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW;QACnG,GAAG,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC;QACpC,GAAG,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC;QACxC,GAAG,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC;KAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC,CAAC"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Warden - Governance package for Trails.
|
|
3
|
-
*
|
|
4
|
-
* Provides lint rules, drift detection, and a CLI runner to enforce
|
|
5
|
-
* contract-first discipline at development time.
|
|
6
|
-
*
|
|
7
|
-
* Package: `@ontrails/warden`
|
|
8
|
-
*/
|
|
9
|
-
export type { ProjectAwareWardenRule, ProjectContext, WardenDiagnostic, WardenRule, WardenSeverity, } from './rules/index.js';
|
|
10
|
-
export { noThrowInImplementation } from './rules/no-throw-in-implementation.js';
|
|
11
|
-
export { contextNoSurfaceTypes } from './rules/context-no-surface-types.js';
|
|
12
|
-
export { validDetourRefs } from './rules/valid-detour-refs.js';
|
|
13
|
-
export { noDirectImplInRoute } from './rules/no-direct-impl-in-route.js';
|
|
14
|
-
export { noDirectImplementationCall } from './rules/no-direct-implementation-call.js';
|
|
15
|
-
export { noSyncResultAssumption } from './rules/no-sync-result-assumption.js';
|
|
16
|
-
export { implementationReturnsResult } from './rules/implementation-returns-result.js';
|
|
17
|
-
export { noThrowInDetourTarget } from './rules/no-throw-in-detour-target.js';
|
|
18
|
-
export { preferSchemaInference } from './rules/prefer-schema-inference.js';
|
|
19
|
-
export { validDescribeRefs } from './rules/valid-describe-refs.js';
|
|
20
|
-
export { wardenRules } from './rules/index.js';
|
|
21
|
-
export type { WardenOptions, WardenReport } from './cli.js';
|
|
22
|
-
export { formatWardenReport, runWarden } from './cli.js';
|
|
23
|
-
export { formatGitHubAnnotations, formatJson, formatSummary, } from './formatters.js';
|
|
24
|
-
export type { DriftResult } from './drift.js';
|
|
25
|
-
export { checkDrift } from './drift.js';
|
|
26
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EACV,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,cAAc,GACf,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EACL,uBAAuB,EACvB,UAAU,EACV,aAAa,GACd,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Warden - Governance package for Trails.
|
|
3
|
-
*
|
|
4
|
-
* Provides lint rules, drift detection, and a CLI runner to enforce
|
|
5
|
-
* contract-first discipline at development time.
|
|
6
|
-
*
|
|
7
|
-
* Package: `@ontrails/warden`
|
|
8
|
-
*/
|
|
9
|
-
// Individual rules
|
|
10
|
-
export { noThrowInImplementation } from './rules/no-throw-in-implementation.js';
|
|
11
|
-
export { contextNoSurfaceTypes } from './rules/context-no-surface-types.js';
|
|
12
|
-
export { validDetourRefs } from './rules/valid-detour-refs.js';
|
|
13
|
-
export { noDirectImplInRoute } from './rules/no-direct-impl-in-route.js';
|
|
14
|
-
export { noDirectImplementationCall } from './rules/no-direct-implementation-call.js';
|
|
15
|
-
export { noSyncResultAssumption } from './rules/no-sync-result-assumption.js';
|
|
16
|
-
export { implementationReturnsResult } from './rules/implementation-returns-result.js';
|
|
17
|
-
export { noThrowInDetourTarget } from './rules/no-throw-in-detour-target.js';
|
|
18
|
-
export { preferSchemaInference } from './rules/prefer-schema-inference.js';
|
|
19
|
-
export { validDescribeRefs } from './rules/valid-describe-refs.js';
|
|
20
|
-
// Rule registry
|
|
21
|
-
export { wardenRules } from './rules/index.js';
|
|
22
|
-
export { formatWardenReport, runWarden } from './cli.js';
|
|
23
|
-
// CI formatters
|
|
24
|
-
export { formatGitHubAnnotations, formatJson, formatSummary, } from './formatters.js';
|
|
25
|
-
export { checkDrift } from './drift.js';
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH,mBAAmB;AACnB,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,gBAAgB;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/C,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzD,gBAAgB;AAChB,OAAO,EACL,uBAAuB,EACvB,UAAU,EACV,aAAa,GACd,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/rules/ast.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared AST utilities for warden rules.
|
|
3
|
-
*
|
|
4
|
-
* Uses oxc-parser for native-speed TypeScript parsing. Provides a lightweight
|
|
5
|
-
* walker and helpers for finding trail implementation bodies.
|
|
6
|
-
*/
|
|
7
|
-
export interface AstNode {
|
|
8
|
-
readonly type: string;
|
|
9
|
-
readonly start: number;
|
|
10
|
-
readonly end: number;
|
|
11
|
-
readonly key?: {
|
|
12
|
-
readonly name?: string;
|
|
13
|
-
};
|
|
14
|
-
readonly value?: AstNode;
|
|
15
|
-
readonly body?: AstNode | readonly AstNode[];
|
|
16
|
-
readonly [key: string]: unknown;
|
|
17
|
-
}
|
|
18
|
-
/** Parse TypeScript source into an AST. Returns null on parse failure. */
|
|
19
|
-
export declare const parse: (filePath: string, sourceCode: string) => AstNode | null;
|
|
20
|
-
/** Walk an AST node tree, calling `visit` on every node. */
|
|
21
|
-
export declare const walk: (node: unknown, visit: (node: AstNode) => void) => void;
|
|
22
|
-
/** Find the byte offset's line number (1-based) in source code. */
|
|
23
|
-
export declare const offsetToLine: (sourceCode: string, offset: number) => number;
|
|
24
|
-
/** Find all `implementation:` property values in an AST. */
|
|
25
|
-
export declare const findImplementationBodies: (ast: AstNode) => AstNode[];
|
|
26
|
-
export interface TrailDefinition {
|
|
27
|
-
/** Trail ID string, e.g. "entity.show" */
|
|
28
|
-
readonly id: string;
|
|
29
|
-
/** "trail" or "hike" */
|
|
30
|
-
readonly kind: string;
|
|
31
|
-
/** The config object argument (second arg to trail/hike call) */
|
|
32
|
-
readonly config: AstNode;
|
|
33
|
-
/** Start offset of the call expression */
|
|
34
|
-
readonly start: number;
|
|
35
|
-
}
|
|
36
|
-
/** Check if a node is a call to `.implementation()` on some object. */
|
|
37
|
-
export declare const isImplementationCall: (node: AstNode) => boolean;
|
|
38
|
-
export declare const findTrailDefinitions: (ast: AstNode) => TrailDefinition[];
|
|
39
|
-
/** Find a Property node by key name inside an ObjectExpression config. */
|
|
40
|
-
export declare const findConfigProperty: (config: AstNode, propertyName: string) => AstNode | null;
|
|
41
|
-
//# sourceMappingURL=ast.d.ts.map
|
package/dist/rules/ast.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/rules/ast.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,WAAW,OAAO;IACtB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,CAAC;AAMF,0EAA0E;AAC1E,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,OAAO,EACf,cAAc,MAAM,KACnB,OAAO,GAAG,IAcZ,CAAC"}
|
package/dist/rules/ast.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared AST utilities for warden rules.
|
|
3
|
-
*
|
|
4
|
-
* Uses oxc-parser for native-speed TypeScript parsing. Provides a lightweight
|
|
5
|
-
* walker and helpers for finding trail implementation bodies.
|
|
6
|
-
*/
|
|
7
|
-
import { parseSync } from 'oxc-parser';
|
|
8
|
-
// ---------------------------------------------------------------------------
|
|
9
|
-
// Parser
|
|
10
|
-
// ---------------------------------------------------------------------------
|
|
11
|
-
/** Parse TypeScript source into an AST. Returns null on parse failure. */
|
|
12
|
-
export const parse = (filePath, sourceCode) => {
|
|
13
|
-
try {
|
|
14
|
-
const result = parseSync(filePath, sourceCode, { sourceType: 'module' });
|
|
15
|
-
return result.program;
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
// Walker
|
|
23
|
-
// ---------------------------------------------------------------------------
|
|
24
|
-
/** Walk an AST node tree, calling `visit` on every node. */
|
|
25
|
-
export const walk = (node, visit) => {
|
|
26
|
-
if (!node || typeof node !== 'object') {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const n = node;
|
|
30
|
-
if (n.type) {
|
|
31
|
-
visit(n);
|
|
32
|
-
}
|
|
33
|
-
for (const val of Object.values(n)) {
|
|
34
|
-
if (Array.isArray(val)) {
|
|
35
|
-
for (const item of val) {
|
|
36
|
-
walk(item, visit);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else if (val && typeof val === 'object' && val.type) {
|
|
40
|
-
walk(val, visit);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
|
-
// Helpers
|
|
46
|
-
// ---------------------------------------------------------------------------
|
|
47
|
-
/** Find the byte offset's line number (1-based) in source code. */
|
|
48
|
-
export const offsetToLine = (sourceCode, offset) => {
|
|
49
|
-
let line = 1;
|
|
50
|
-
for (let i = 0; i < offset && i < sourceCode.length; i += 1) {
|
|
51
|
-
if (sourceCode[i] === '\n') {
|
|
52
|
-
line += 1;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return line;
|
|
56
|
-
};
|
|
57
|
-
/** Find all `implementation:` property values in an AST. */
|
|
58
|
-
export const findImplementationBodies = (ast) => {
|
|
59
|
-
const bodies = [];
|
|
60
|
-
walk(ast, (node) => {
|
|
61
|
-
if (node.type === 'Property' &&
|
|
62
|
-
node.key?.name === 'implementation' &&
|
|
63
|
-
node.value) {
|
|
64
|
-
bodies.push(node.value);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
return bodies;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Find all `trail("id", { ... })` and `hike("id", { ... })` call sites.
|
|
71
|
-
*
|
|
72
|
-
* Returns the trail ID, kind, and config object node for each definition.
|
|
73
|
-
*/
|
|
74
|
-
const TRAIL_CALLEE_NAMES = new Set(['trail', 'hike']);
|
|
75
|
-
const getTrailCalleeName = (node) => {
|
|
76
|
-
if (node.type !== 'CallExpression') {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
const callee = node['callee'];
|
|
80
|
-
if (!callee || callee.type !== 'Identifier') {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
const { name } = callee;
|
|
84
|
-
return name && TRAIL_CALLEE_NAMES.has(name) ? name : null;
|
|
85
|
-
};
|
|
86
|
-
const extractTrailArgs = (node) => {
|
|
87
|
-
const args = node['arguments'];
|
|
88
|
-
if (!args || args.length < 2) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
const [idArg, configArg] = args;
|
|
92
|
-
if (!idArg || !configArg) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
return { configArg, idArg };
|
|
96
|
-
};
|
|
97
|
-
const extractTrailDefinition = (node) => {
|
|
98
|
-
const calleeName = getTrailCalleeName(node);
|
|
99
|
-
if (!calleeName) {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
const trailArgs = extractTrailArgs(node);
|
|
103
|
-
if (!trailArgs) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
const trailId = trailArgs.idArg.value;
|
|
107
|
-
if (!trailId) {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
config: trailArgs.configArg,
|
|
112
|
-
id: trailId,
|
|
113
|
-
kind: calleeName,
|
|
114
|
-
start: node.start,
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
/** Check if a node is a call to `.implementation()` on some object. */
|
|
118
|
-
export const isImplementationCall = (node) => {
|
|
119
|
-
if (node.type !== 'CallExpression') {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
const callee = node['callee'];
|
|
123
|
-
if (!callee) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
if (callee.type !== 'StaticMemberExpression' &&
|
|
127
|
-
callee.type !== 'MemberExpression') {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
const prop = callee.property;
|
|
131
|
-
return (prop?.type === 'Identifier' &&
|
|
132
|
-
prop.name === 'implementation');
|
|
133
|
-
};
|
|
134
|
-
export const findTrailDefinitions = (ast) => {
|
|
135
|
-
const definitions = [];
|
|
136
|
-
walk(ast, (node) => {
|
|
137
|
-
const def = extractTrailDefinition(node);
|
|
138
|
-
if (def) {
|
|
139
|
-
definitions.push(def);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
return definitions;
|
|
143
|
-
};
|
|
144
|
-
// ---------------------------------------------------------------------------
|
|
145
|
-
// Config property extraction helpers
|
|
146
|
-
// ---------------------------------------------------------------------------
|
|
147
|
-
/** Find a Property node by key name inside an ObjectExpression config. */
|
|
148
|
-
export const findConfigProperty = (config, propertyName) => {
|
|
149
|
-
if (config.type !== 'ObjectExpression') {
|
|
150
|
-
return null;
|
|
151
|
-
}
|
|
152
|
-
const properties = config['properties'];
|
|
153
|
-
if (!properties) {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
for (const prop of properties) {
|
|
157
|
-
if (prop.type === 'Property' && prop.key?.name === propertyName) {
|
|
158
|
-
return prop;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return null;
|
|
162
|
-
};
|
|
163
|
-
//# sourceMappingURL=ast.js.map
|
package/dist/rules/ast.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/rules/ast.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAgBvC,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,0EAA0E;AAC1E,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,QAAgB,EAAE,UAAkB,EAAkB,EAAE;IAC5E,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;QACzE,OAAO,MAAM,CAAC,OAA6B,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAEF,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,4DAA4D;AAC5D,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAa,EAAE,KAA8B,EAAQ,EAAE;IAC1E,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO;IACT,CAAC;IACD,MAAM,CAAC,GAAG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AAM,WAAW,GAAsB,EAAE,CAAC;IAE1C,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;QACjB,MAAM,GAAG,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,GAAG,EAAE,CAAC;YACR,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,8EAA8E;AAC9E,qCAAqC;AACrC,8EAA8E;AAE9E,0EAA0E;AAC1E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,MAAe,EACf,YAAoB,EACJ,EAAE;IAClB,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAmC,CAAC;IAC1E,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC9B,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;YAChE,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Detects imports of surface-specific modules and types in trail files.
|
|
3
|
-
*
|
|
4
|
-
* Uses AST parsing for accurate detection — no false positives from
|
|
5
|
-
* imports in comments or strings.
|
|
6
|
-
*/
|
|
7
|
-
import type { WardenRule } from './types.js';
|
|
8
|
-
/**
|
|
9
|
-
* Detects imports of surface-specific types in trail implementation files.
|
|
10
|
-
*/
|
|
11
|
-
export declare const contextNoSurfaceTypes: WardenRule;
|
|
12
|
-
//# sourceMappingURL=context-no-surface-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-no-surface-types.d.ts","sourceRoot":"","sources":["../../src/rules/context-no-surface-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAoB,UAAU,EAAE,MAAM,YAAY,CAAC;AAgH/D;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,UA0BnC,CAAC"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Detects imports of surface-specific modules and types in trail files.
|
|
3
|
-
*
|
|
4
|
-
* Uses AST parsing for accurate detection — no false positives from
|
|
5
|
-
* imports in comments or strings.
|
|
6
|
-
*/
|
|
7
|
-
import { offsetToLine, parse, walk } from './ast.js';
|
|
8
|
-
const SURFACE_MODULES = new Set([
|
|
9
|
-
'express',
|
|
10
|
-
'hono',
|
|
11
|
-
'fastify',
|
|
12
|
-
'@modelcontextprotocol/sdk',
|
|
13
|
-
'node:http',
|
|
14
|
-
'node:https',
|
|
15
|
-
'@hono/node-server',
|
|
16
|
-
'koa',
|
|
17
|
-
]);
|
|
18
|
-
const SURFACE_TYPE_NAMES = new Set([
|
|
19
|
-
'Request',
|
|
20
|
-
'Response',
|
|
21
|
-
'NextFunction',
|
|
22
|
-
'McpSession',
|
|
23
|
-
'McpCallToolRequest',
|
|
24
|
-
'IncomingMessage',
|
|
25
|
-
'ServerResponse',
|
|
26
|
-
]);
|
|
27
|
-
const makeDiag = (filePath, sourceCode, node, message) => ({
|
|
28
|
-
filePath,
|
|
29
|
-
line: offsetToLine(sourceCode, node.start),
|
|
30
|
-
message,
|
|
31
|
-
rule: 'context-no-surface-types',
|
|
32
|
-
severity: 'error',
|
|
33
|
-
});
|
|
34
|
-
const findSurfaceTypeName = (specifiers) => {
|
|
35
|
-
for (const spec of specifiers) {
|
|
36
|
-
const name = spec.imported?.name ?? spec.local?.name;
|
|
37
|
-
if (name && SURFACE_TYPE_NAMES.has(name)) {
|
|
38
|
-
return name;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return undefined;
|
|
42
|
-
};
|
|
43
|
-
const getImportModuleName = (node) => {
|
|
44
|
-
if (node.type !== 'ImportDeclaration') {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
const source = node['source'];
|
|
48
|
-
return source?.value ?? null;
|
|
49
|
-
};
|
|
50
|
-
const checkSpecifiersForSurfaceTypes = (node, filePath, sourceCode) => {
|
|
51
|
-
const specifiers = node['specifiers'];
|
|
52
|
-
if (!specifiers) {
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
const typeName = findSurfaceTypeName(specifiers);
|
|
56
|
-
if (!typeName) {
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
return makeDiag(filePath, sourceCode, node, `Do not import surface type "${typeName}" in trail implementation files.`);
|
|
60
|
-
};
|
|
61
|
-
const classifyImport = (node, filePath, sourceCode) => {
|
|
62
|
-
const moduleName = getImportModuleName(node);
|
|
63
|
-
if (!moduleName) {
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
if (SURFACE_MODULES.has(moduleName)) {
|
|
67
|
-
return makeDiag(filePath, sourceCode, node, `Do not import from surface module "${moduleName}" in trail implementation files.`);
|
|
68
|
-
}
|
|
69
|
-
return checkSpecifiersForSurfaceTypes(node, filePath, sourceCode);
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Detects imports of surface-specific types in trail implementation files.
|
|
73
|
-
*/
|
|
74
|
-
export const contextNoSurfaceTypes = {
|
|
75
|
-
check(sourceCode, filePath) {
|
|
76
|
-
if (!/\b(?:trail|hike)\s*\(/.test(sourceCode)) {
|
|
77
|
-
return [];
|
|
78
|
-
}
|
|
79
|
-
const ast = parse(filePath, sourceCode);
|
|
80
|
-
if (!ast) {
|
|
81
|
-
return [];
|
|
82
|
-
}
|
|
83
|
-
const diagnostics = [];
|
|
84
|
-
walk(ast, (node) => {
|
|
85
|
-
const diag = classifyImport(node, filePath, sourceCode);
|
|
86
|
-
if (diag) {
|
|
87
|
-
diagnostics.push(diag);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
return diagnostics;
|
|
91
|
-
},
|
|
92
|
-
description: 'Disallow surface-specific type imports (Request, Response, McpSession, etc.) in trail implementation files.',
|
|
93
|
-
name: 'context-no-surface-types',
|
|
94
|
-
severity: 'error',
|
|
95
|
-
};
|
|
96
|
-
//# sourceMappingURL=context-no-surface-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-no-surface-types.js","sourceRoot":"","sources":["../../src/rules/context-no-surface-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGrD,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,SAAS;IACT,MAAM;IACN,SAAS;IACT,2BAA2B;IAC3B,WAAW;IACX,YAAY;IACZ,mBAAmB;IACnB,KAAK;CACN,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,SAAS;IACT,UAAU;IACV,cAAc;IACd,YAAY;IACZ,oBAAoB;IACpB,iBAAiB;IACjB,gBAAgB;CACjB,CAAC,CAAC;AAaH,MAAM,QAAQ,GAAG,CACf,QAAgB,EAChB,UAAkB,EAClB,IAAa,EACb,OAAe,EACG,EAAE,CAAC,CAAC;IACtB,QAAQ;IACR,IAAI,EAAE,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC;IAC1C,OAAO;IACP,IAAI,EAAE,0BAA0B;IAChC,QAAQ,EAAE,OAAO;CAClB,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,CAC1B,UAAsC,EAClB,EAAE;IACtB,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,E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IAAI,EACJ,sCAAsC,UAAU,kCAAkC,CACnF,CAAC;IACJ,CAAC;IAED,OAAO,8BAA8B,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAe;IAC/C,KAAK,CAAC,UAAkB,EAAE,QAAgB;QACxC,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACxC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,WAAW,GAAuB,EAAE,CAAC;QAC3C,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;YACjB,MAAM,IAAI,GAAG,cAAc,CAAC,IAAe,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;YACnE,IAAI,IAAI,EAAE,CAAC;gBACT,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,WAAW,EACT,6GAA6G;IAC/G,IAAI,EAAE,0BAA0B;IAEhC,QAAQ,EAAE,OAAO;CAClB,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Finds implementations that return raw values instead of `Result`.
|
|
3
|
-
*
|
|
4
|
-
* Uses AST parsing to find `implementation:` bodies and check that
|
|
5
|
-
* every return statement returns Result.ok(), Result.err(), ctx.follow(),
|
|
6
|
-
* or a tracked Result-typed variable.
|
|
7
|
-
*/
|
|
8
|
-
import type { WardenRule } from './types.js';
|
|
9
|
-
/**
|
|
10
|
-
* Finds implementations that return raw values instead of `Result`.
|
|
11
|
-
*/
|
|
12
|
-
export declare const implementationReturnsResult: WardenRule;
|
|
13
|
-
//# sourceMappingURL=implementation-returns-result.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"implementation-returns-result.d.ts","sourceRoot":"","sources":["../../src/rules/implementation-returns-result.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,KAAK,EAAoB,UAAU,EAAE,MAAM,YAAY,CAAC;AAkT/D;;GAEG;AACH,eAAO,MAAM,2BAA2B,EAAE,UAiBzC,CAAC"}
|