repo-contract 0.1.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 +7 -0
- package/LICENSE +21 -0
- package/README.md +967 -0
- package/dist/.dts/config/define-repo-contract.d.ts +36 -0
- package/dist/.dts/config/define-repo-contract.d.ts.map +1 -0
- package/dist/.dts/config/tokenize-command.d.ts +33 -0
- package/dist/.dts/config/tokenize-command.d.ts.map +1 -0
- package/dist/.dts/config/validate-config.d.ts +32 -0
- package/dist/.dts/config/validate-config.d.ts.map +1 -0
- package/dist/.dts/errors.d.ts +155 -0
- package/dist/.dts/errors.d.ts.map +1 -0
- package/dist/.dts/evidence/build-evidence.d.ts +26 -0
- package/dist/.dts/evidence/build-evidence.d.ts.map +1 -0
- package/dist/.dts/execution/abort-signals.d.ts +29 -0
- package/dist/.dts/execution/abort-signals.d.ts.map +1 -0
- package/dist/.dts/execution/concurrency-pool.d.ts +14 -0
- package/dist/.dts/execution/concurrency-pool.d.ts.map +1 -0
- package/dist/.dts/execution/dependency-scheduler.d.ts +30 -0
- package/dist/.dts/execution/dependency-scheduler.d.ts.map +1 -0
- package/dist/.dts/execution/process-tree.d.ts +48 -0
- package/dist/.dts/execution/process-tree.d.ts.map +1 -0
- package/dist/.dts/execution/run-checks.d.ts +29 -0
- package/dist/.dts/execution/run-checks.d.ts.map +1 -0
- package/dist/.dts/execution/spawn-check.d.ts +30 -0
- package/dist/.dts/execution/spawn-check.d.ts.map +1 -0
- package/dist/.dts/index.d.ts +13 -0
- package/dist/.dts/index.d.ts.map +1 -0
- package/dist/.dts/parsing/parse-json.d.ts +8 -0
- package/dist/.dts/parsing/parse-json.d.ts.map +1 -0
- package/dist/.dts/parsing/parse-output.d.ts +10 -0
- package/dist/.dts/parsing/parse-output.d.ts.map +1 -0
- package/dist/.dts/parsing/parse-text.d.ts +8 -0
- package/dist/.dts/parsing/parse-text.d.ts.map +1 -0
- package/dist/.dts/parsing/parse-yaml.d.ts +21 -0
- package/dist/.dts/parsing/parse-yaml.d.ts.map +1 -0
- package/dist/.dts/policy/run-policies.d.ts +38 -0
- package/dist/.dts/policy/run-policies.d.ts.map +1 -0
- package/dist/.dts/presets/arethetypeswrong.d.ts +39 -0
- package/dist/.dts/presets/arethetypeswrong.d.ts.map +1 -0
- package/dist/.dts/presets/broken-links.d.ts +16 -0
- package/dist/.dts/presets/broken-links.d.ts.map +1 -0
- package/dist/.dts/presets/commitlint.d.ts +22 -0
- package/dist/.dts/presets/commitlint.d.ts.map +1 -0
- package/dist/.dts/presets/dead-code.d.ts +23 -0
- package/dist/.dts/presets/dead-code.d.ts.map +1 -0
- package/dist/.dts/presets/duplication.d.ts +14 -0
- package/dist/.dts/presets/duplication.d.ts.map +1 -0
- package/dist/.dts/presets/e2e.d.ts +4 -0
- package/dist/.dts/presets/e2e.d.ts.map +1 -0
- package/dist/.dts/presets/format.d.ts +4 -0
- package/dist/.dts/presets/format.d.ts.map +1 -0
- package/dist/.dts/presets/index.d.ts +31 -0
- package/dist/.dts/presets/index.d.ts.map +1 -0
- package/dist/.dts/presets/license.d.ts +4 -0
- package/dist/.dts/presets/license.d.ts.map +1 -0
- package/dist/.dts/presets/lint.d.ts +20 -0
- package/dist/.dts/presets/lint.d.ts.map +1 -0
- package/dist/.dts/presets/markdownlint.d.ts +23 -0
- package/dist/.dts/presets/markdownlint.d.ts.map +1 -0
- package/dist/.dts/presets/publint.d.ts +13 -0
- package/dist/.dts/presets/publint.d.ts.map +1 -0
- package/dist/.dts/presets/security-deps.d.ts +4 -0
- package/dist/.dts/presets/security-deps.d.ts.map +1 -0
- package/dist/.dts/presets/security-secrets.d.ts +4 -0
- package/dist/.dts/presets/security-secrets.d.ts.map +1 -0
- package/dist/.dts/presets/shared/error-warning-pass-policy.d.ts +13 -0
- package/dist/.dts/presets/shared/error-warning-pass-policy.d.ts.map +1 -0
- package/dist/.dts/presets/shared/exit-code-fail-rationale.d.ts +23 -0
- package/dist/.dts/presets/shared/exit-code-fail-rationale.d.ts.map +1 -0
- package/dist/.dts/presets/shared/missing-dependency.d.ts +19 -0
- package/dist/.dts/presets/shared/missing-dependency.d.ts.map +1 -0
- package/dist/.dts/presets/shared/read-json-report.d.ts +33 -0
- package/dist/.dts/presets/shared/read-json-report.d.ts.map +1 -0
- package/dist/.dts/presets/shared/terminal-status.d.ts +25 -0
- package/dist/.dts/presets/shared/terminal-status.d.ts.map +1 -0
- package/dist/.dts/presets/shared/vitest-json-policy.d.ts +20 -0
- package/dist/.dts/presets/shared/vitest-json-policy.d.ts.map +1 -0
- package/dist/.dts/presets/stylelint.d.ts +17 -0
- package/dist/.dts/presets/stylelint.d.ts.map +1 -0
- package/dist/.dts/presets/test.d.ts +4 -0
- package/dist/.dts/presets/test.d.ts.map +1 -0
- package/dist/.dts/presets/typecheck.d.ts +4 -0
- package/dist/.dts/presets/typecheck.d.ts.map +1 -0
- package/dist/.dts/run-repo-contract.d.ts +38 -0
- package/dist/.dts/run-repo-contract.d.ts.map +1 -0
- package/dist/.dts/types.d.ts +324 -0
- package/dist/.dts/types.d.ts.map +1 -0
- package/dist/index.cjs +46 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/presets.cjs +30 -0
- package/dist/presets.cjs.map +1 -0
- package/dist/presets.d.cts +1 -0
- package/dist/presets.d.ts +1 -0
- package/dist/presets.js +13 -0
- package/dist/presets.js.map +1 -0
- package/package.json +192 -0
- package/presets/package.json +5 -0
- package/schemas/evidence.schema.json +253 -0
- package/schemas/verdict.schema.json +66 -0
- package/src/config/define-repo-contract.ts +38 -0
- package/src/config/tokenize-command.ts +214 -0
- package/src/config/validate-config.ts +368 -0
- package/src/errors.ts +229 -0
- package/src/evidence/build-evidence.ts +91 -0
- package/src/execution/abort-signals.ts +56 -0
- package/src/execution/concurrency-pool.ts +64 -0
- package/src/execution/dependency-scheduler.ts +216 -0
- package/src/execution/process-tree.ts +107 -0
- package/src/execution/run-checks.ts +348 -0
- package/src/execution/spawn-check.ts +494 -0
- package/src/index.ts +44 -0
- package/src/parsing/parse-json.ts +18 -0
- package/src/parsing/parse-output.ts +26 -0
- package/src/parsing/parse-text.ts +10 -0
- package/src/parsing/parse-yaml.ts +40 -0
- package/src/policy/run-policies.ts +261 -0
- package/src/presets/arethetypeswrong.ts +116 -0
- package/src/presets/broken-links.ts +95 -0
- package/src/presets/commitlint.ts +77 -0
- package/src/presets/dead-code.ts +223 -0
- package/src/presets/duplication.ts +137 -0
- package/src/presets/e2e.ts +144 -0
- package/src/presets/format.ts +25 -0
- package/src/presets/index.ts +30 -0
- package/src/presets/license.ts +90 -0
- package/src/presets/lint.ts +116 -0
- package/src/presets/markdownlint.ts +105 -0
- package/src/presets/publint.ts +38 -0
- package/src/presets/security-deps.ts +142 -0
- package/src/presets/security-secrets.ts +93 -0
- package/src/presets/shared/error-warning-pass-policy.ts +39 -0
- package/src/presets/shared/exit-code-fail-rationale.ts +34 -0
- package/src/presets/shared/missing-dependency.ts +31 -0
- package/src/presets/shared/read-json-report.ts +46 -0
- package/src/presets/shared/terminal-status.ts +70 -0
- package/src/presets/shared/vitest-json-policy.ts +95 -0
- package/src/presets/stylelint.ts +101 -0
- package/src/presets/test.ts +19 -0
- package/src/presets/typecheck.ts +25 -0
- package/src/run-repo-contract.ts +80 -0
- package/src/types.ts +340 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ParsedCheckEntry } from "../evidence/build-evidence.js";
|
|
2
|
+
import type { Evidence, Verdict } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Invokes every check's `policy` against the complete, already-assembled
|
|
5
|
+
* `evidence` and aggregates the results into a `Verdict`. Each check's
|
|
6
|
+
* `PolicyResult` is stored verbatim under `checks[checkId]`; `passed` is
|
|
7
|
+
* `true` only if every check's `outcome` is `"pass"` or `"warn"` -- no
|
|
8
|
+
* check's failure is ever collapsed into another's or into one generic
|
|
9
|
+
* message.
|
|
10
|
+
*
|
|
11
|
+
* Every `policy` call is isolated: the call itself is wrapped in `try/catch`
|
|
12
|
+
* (a policy doesn't have to be `async` to misbehave), and its returned
|
|
13
|
+
* value is `await`-ed inside that same `try`, so a promise that rejects
|
|
14
|
+
* later is caught identically to a synchronous throw. The resolved value is
|
|
15
|
+
* then validated against the `PolicyResult` contract itself (`outcome` is
|
|
16
|
+
* exactly `"pass"`, `"fail"`, or `"warn"`; `rationale` is a string) before
|
|
17
|
+
* it is trusted -- a malformed result is treated exactly like a throw
|
|
18
|
+
* rather than silently coerced into a pass. Every one of these failure
|
|
19
|
+
* modes is wrapped in `PolicyThrewError`, with the original thrown value
|
|
20
|
+
* (or a descriptive validation error, for a malformed result) preserved via
|
|
21
|
+
* `cause` -- never stringified or discarded. Two specific, common mistakes
|
|
22
|
+
* get a more actionable error instead, chosen by `wrapPolicyFailure` (see
|
|
23
|
+
* its own doc comment): reading a `result.output` property on a check that
|
|
24
|
+
* never requested a format (`PolicyReadUnrequestedOutputError`), and reading
|
|
25
|
+
* `result.output.value` on a check whose requested parse actually failed
|
|
26
|
+
* (`PolicyReadFailedParseValueError`) -- both still preserve the original
|
|
27
|
+
* `TypeError` via `cause`, exactly like the plain `PolicyThrewError` case.
|
|
28
|
+
* One policy failing this way never stops any other check's policy from
|
|
29
|
+
* running. If more than one policy fails this way in the same run, this
|
|
30
|
+
* function throws a native `AggregateError` whose `errors` holds one such
|
|
31
|
+
* error per failing check, rather than surfacing only the first one found;
|
|
32
|
+
* if exactly one policy fails, it throws that single error directly.
|
|
33
|
+
* @param entries - each check's id, definition, and final (possibly parsed-output) evidence to invoke its policy against
|
|
34
|
+
* @param evidence - the complete, already-assembled evidence for the whole run, passed to every policy call
|
|
35
|
+
* @returns the aggregated `Verdict` (throws instead if one or more policies failed to produce a valid `PolicyResult`)
|
|
36
|
+
*/
|
|
37
|
+
export declare function runPolicies(entries: readonly ParsedCheckEntry[], evidence: Evidence): Promise<Verdict>;
|
|
38
|
+
//# sourceMappingURL=run-policies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-policies.d.ts","sourceRoot":"","sources":["../../../src/policy/run-policies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAMrE,OAAO,KAAK,EAEV,QAAQ,EAIR,OAAO,EACR,MAAM,aAAa,CAAA;AA4HpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,OAAO,CAAC,CAsFlB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { CheckDefinitionConfig, PolicyResult } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* attw's own `--format json` contract -- not published as a TypeScript type
|
|
4
|
+
* by the tool. `problems` is a flat record keyed by problem kind (e.g.
|
|
5
|
+
* "FalseCJS", "NoResolution"), each entry carrying whichever context fields
|
|
6
|
+
* that kind of problem produces.
|
|
7
|
+
*/
|
|
8
|
+
export interface AttwReport {
|
|
9
|
+
readonly problems?: Record<string, readonly AttwProblem[]>;
|
|
10
|
+
}
|
|
11
|
+
export interface AttwProblem {
|
|
12
|
+
readonly kind: string;
|
|
13
|
+
readonly entrypoint?: string;
|
|
14
|
+
readonly resolutionKind?: string;
|
|
15
|
+
readonly typesFileName?: string;
|
|
16
|
+
readonly implementationFileName?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Interprets an already-parsed attw JSON report -- exported (unlike this
|
|
20
|
+
* package's other internal evaluators) because a repository whose package
|
|
21
|
+
* has enough entrypoints to make attw's own `--format json` output exceed
|
|
22
|
+
* ~64KB can hit a real, reproducible upstream bug: attw truncates its own
|
|
23
|
+
* stdout when it's a pipe (confirmed independently of repo-contract, via
|
|
24
|
+
* plain shell piping) rather than a TTY or regular file. Redirecting attw's
|
|
25
|
+
* output to a file sidesteps that bug; a consumer doing so needs this same
|
|
26
|
+
* interpretation logic without re-deriving it. repo-contract's own
|
|
27
|
+
* `repo-contract.config.ts` does exactly this once it has more than one real
|
|
28
|
+
* entrypoint (see that file's `arethetypeswrong` override).
|
|
29
|
+
* Accepts `unknown` and validates the shape itself: its inputs are always
|
|
30
|
+
* untrusted parsed JSON (a tool's stdout, a report file), and valid JSON of an
|
|
31
|
+
* unexpected shape must produce a clean fail verdict here rather than a
|
|
32
|
+
* `TypeError` in the caller.
|
|
33
|
+
* @param report - the parsed attw JSON report to evaluate.
|
|
34
|
+
* @returns the pass/fail outcome and its rationale.
|
|
35
|
+
*/
|
|
36
|
+
export declare function evaluateAttwReport(report: unknown): PolicyResult;
|
|
37
|
+
/** Published-package type-resolution correctness via `@arethetypeswrong/cli`. */
|
|
38
|
+
export declare const arethetypeswrong: CheckDefinitionConfig;
|
|
39
|
+
//# sourceMappingURL=arethetypeswrong.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arethetypeswrong.d.ts","sourceRoot":"","sources":["../../../src/presets/arethetypeswrong.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAItE;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC,CAAA;CAC3D;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAA;CACzC;AAkBD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CA6BhE;AAUD,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,EAAE,qBAmB9B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CheckDefinitionConfig } from "../types.js";
|
|
2
|
+
/** Options accepted by {@link brokenLinks}. */
|
|
3
|
+
interface BrokenLinksOptions {
|
|
4
|
+
/** File or directory passed straight through to linkinator as its positional target. Defaults to `"."`. */
|
|
5
|
+
readonly start?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Broken-link detection via linkinator, recursing through local files and
|
|
9
|
+
* following both local and remote links. `--skip node_modules` avoids
|
|
10
|
+
* wasting the crawl on vendored files that were never authored content.
|
|
11
|
+
* @param options - configuration for this check; see {@link BrokenLinksOptions}.
|
|
12
|
+
* @returns the configured check.
|
|
13
|
+
*/
|
|
14
|
+
export declare function brokenLinks(options?: BrokenLinksOptions): CheckDefinitionConfig;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=broken-links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broken-links.d.ts","sourceRoot":"","sources":["../../../src/presets/broken-links.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAgBxD,+CAA+C;AAC/C,UAAU,kBAAkB;IAC1B,2GAA2G;IAC3G,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB;AAYD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,qBAAqB,CAuDnF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CheckDefinitionConfig } from "../types.js";
|
|
2
|
+
/** Options accepted by {@link commitlint}. */
|
|
3
|
+
interface CommitlintOptions {
|
|
4
|
+
/** The ref commitlint lints commits *from* (exclusive). Defaults to `"origin/main"`. */
|
|
5
|
+
readonly from?: string;
|
|
6
|
+
/** The ref commitlint lints commits *to* (inclusive). Defaults to `"HEAD"`. */
|
|
7
|
+
readonly to?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Commit-message governance via commitlint, using whatever commitlint
|
|
11
|
+
* config the consumer's own repository already has (commitlint ships no
|
|
12
|
+
* rules of its own -- e.g. `@commitlint/config-conventional`). Exit-code
|
|
13
|
+
* based rather than `--format json`: commitlint has no broadly-documented,
|
|
14
|
+
* stable JSON CLI output, so this preset reads its plain-text report the
|
|
15
|
+
* same way the `format`/`typecheck` presets already do for their tools,
|
|
16
|
+
* rather than relying on an unconfirmed flag.
|
|
17
|
+
* @param options - configuration for this check; see {@link CommitlintOptions}.
|
|
18
|
+
* @returns the configured check.
|
|
19
|
+
*/
|
|
20
|
+
export declare function commitlint(options?: CommitlintOptions): CheckDefinitionConfig;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=commitlint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commitlint.d.ts","sourceRoot":"","sources":["../../../src/presets/commitlint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAKxD,8CAA8C;AAC9C,UAAU,iBAAiB;IACzB,wFAAwF;IACxF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CACrB;AA2BD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,qBAAqB,CA2BjF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CheckDefinitionConfig } from "../types.js";
|
|
2
|
+
/** Options accepted by {@link deadCode}. */
|
|
3
|
+
interface DeadCodeOptions {
|
|
4
|
+
/**
|
|
5
|
+
* devDependency names to exclude from the "unused devDependency" issue
|
|
6
|
+
* category -- e.g. CLI tools knip has no way to see are used, because
|
|
7
|
+
* nothing `import`s them. Round-tripped through knip's own
|
|
8
|
+
* `--reporter-options` flag (see `readReporterOptions`) rather than kept in
|
|
9
|
+
* a closure, so the exempt list this check actually ran with is visible on
|
|
10
|
+
* the recorded command line and in persisted evidence, not just in this
|
|
11
|
+
* file's source. Defaults to an empty list -- repo-contract ships no
|
|
12
|
+
* built-in exemptions; add your own repository's here.
|
|
13
|
+
*/
|
|
14
|
+
readonly exemptUnusedDevDependencies?: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Dead/unused-code detection via knip.
|
|
18
|
+
* @param options - configuration for this check; see {@link DeadCodeOptions}.
|
|
19
|
+
* @returns the configured check.
|
|
20
|
+
*/
|
|
21
|
+
export declare function deadCode(options?: DeadCodeOptions): CheckDefinitionConfig;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=dead-code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dead-code.d.ts","sourceRoot":"","sources":["../../../src/presets/dead-code.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AA8CxD,4CAA4C;AAC5C,UAAU,eAAe;IACvB;;;;;;;;;OASG;IACH,QAAQ,CAAC,2BAA2B,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACzD;AA6DD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,GAAE,eAAoB,GAAG,qBAAqB,CAiG7E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CheckDefinitionConfig } from "../types.js";
|
|
2
|
+
/** Options accepted by {@link duplication}. */
|
|
3
|
+
interface DuplicationOptions {
|
|
4
|
+
/** Directory to scan for duplicated code, passed straight through to jscpd as its positional target. Defaults to `"."` -- narrow it (e.g. `"src"`) to scope the scan to your own source tree. */
|
|
5
|
+
readonly path?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Duplicated-code detection via jscpd.
|
|
9
|
+
* @param options - configuration for this check; see {@link DuplicationOptions}.
|
|
10
|
+
* @returns the configured check.
|
|
11
|
+
*/
|
|
12
|
+
export declare function duplication(options?: DuplicationOptions): CheckDefinitionConfig;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=duplication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplication.d.ts","sourceRoot":"","sources":["../../../src/presets/duplication.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAkCxD,+CAA+C;AAC/C,UAAU,kBAAkB;IAC1B,iMAAiM;IACjM,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACvB;AAgBD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,qBAAqB,CA4EnF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e2e.d.ts","sourceRoot":"","sources":["../../../src/presets/e2e.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AA+ExD,kFAAkF;AAClF,eAAO,MAAM,GAAG,EAAE,qBA+DjB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/presets/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAKxD,sDAAsD;AACtD,eAAO,MAAM,MAAM,EAAE,qBAkBpB,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Curated, growing catalog of preset checks for tools common across
|
|
3
|
+
* TypeScript/JavaScript repositories -- each preset encodes how to execute
|
|
4
|
+
* and interpret a common tool, never a repository's definition of quality
|
|
5
|
+
* (see specs/decisions/0004-public-surface-stays-narrow-no-cli-experimental-presets.md). Import a preset,
|
|
6
|
+
* spread it into your own `checks` record, and override whatever you need
|
|
7
|
+
* -- most often `policy`; a factory preset's options are the preferred way
|
|
8
|
+
* to change what it executes, a direct `run` override is an escape hatch.
|
|
9
|
+
* Never re-exported from the package root (`src/index.ts`) -- presets are
|
|
10
|
+
* an opt-in extra, not part of the core execution/evidence/policy surface
|
|
11
|
+
* those exports describe, and this barrel never re-exports anything from
|
|
12
|
+
* there either; the two stay independent.
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
export { arethetypeswrong } from "./arethetypeswrong.js";
|
|
16
|
+
export { brokenLinks } from "./broken-links.js";
|
|
17
|
+
export { commitlint } from "./commitlint.js";
|
|
18
|
+
export { deadCode } from "./dead-code.js";
|
|
19
|
+
export { duplication } from "./duplication.js";
|
|
20
|
+
export { e2e } from "./e2e.js";
|
|
21
|
+
export { format } from "./format.js";
|
|
22
|
+
export { license } from "./license.js";
|
|
23
|
+
export { lint } from "./lint.js";
|
|
24
|
+
export { markdownlint } from "./markdownlint.js";
|
|
25
|
+
export { publint } from "./publint.js";
|
|
26
|
+
export { securityDeps } from "./security-deps.js";
|
|
27
|
+
export { securitySecrets } from "./security-secrets.js";
|
|
28
|
+
export { stylelint } from "./stylelint.js";
|
|
29
|
+
export { test } from "./test.js";
|
|
30
|
+
export { typecheck } from "./typecheck.js";
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../../src/presets/license.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAuBxD,kDAAkD;AAClD,eAAO,MAAM,OAAO,EAAE,qBAiErB,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CheckDefinitionConfig } from "../types.js";
|
|
2
|
+
/** Options accepted by {@link lint}. */
|
|
3
|
+
interface LintOptions {
|
|
4
|
+
/** Path (or glob) passed straight through to ESLint as its positional target. Defaults to `"."` -- narrow it (e.g. `"src"`) to scope linting to your own source tree. */
|
|
5
|
+
readonly path?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Static analysis via ESLint, using whatever `eslint.config.js` the
|
|
9
|
+
* consumer's own repository already has -- this preset makes no assumption
|
|
10
|
+
* about rule configuration, only about how to run the tool and interpret
|
|
11
|
+
* its JSON output. Severity `2` (error) blocks; severity `1` (warning) is
|
|
12
|
+
* reported but never blocks -- ESLint's own severities already encode that
|
|
13
|
+
* distinction, so this preset just respects it rather than treating every
|
|
14
|
+
* finding as equally blocking.
|
|
15
|
+
* @param options - configuration for this check; see {@link LintOptions}.
|
|
16
|
+
* @returns the configured check.
|
|
17
|
+
*/
|
|
18
|
+
export declare function lint(options?: LintOptions): CheckDefinitionConfig;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../src/presets/lint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AA0BxD,wCAAwC;AACxC,UAAU,WAAW;IACnB,yKAAyK;IACzK,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACvB;AAoBD;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,WAAgB,GAAG,qBAAqB,CAsDrE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CheckDefinitionConfig } from "../types.js";
|
|
2
|
+
/** Options accepted by {@link markdownlint}. */
|
|
3
|
+
interface MarkdownlintOptions {
|
|
4
|
+
/** Glob passed straight through to markdownlint-cli2 as its positional target. Defaults to `"**\/*.md"`. */
|
|
5
|
+
readonly glob?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Markdown structure/style lint via markdownlint-cli2. Unlike this
|
|
9
|
+
* package's other file-based-report presets, the report path is
|
|
10
|
+
* config-driven rather than a CLI flag -- markdownlint-cli2 only writes
|
|
11
|
+
* JSON when its own config file requests it. This preset assumes the
|
|
12
|
+
* consumer's `.markdownlint-cli2.jsonc` includes:
|
|
13
|
+
* ```jsonc
|
|
14
|
+
* "outputFormatters": [["markdownlint-cli2-formatter-json", { "name": "reports/markdownlint.json" }]]
|
|
15
|
+
* ```
|
|
16
|
+
* which also requires the `markdownlint-cli2-formatter-json` package
|
|
17
|
+
* alongside `markdownlint-cli2` itself.
|
|
18
|
+
* @param options - configuration for this check; see {@link MarkdownlintOptions}.
|
|
19
|
+
* @returns the configured check.
|
|
20
|
+
*/
|
|
21
|
+
export declare function markdownlint(options?: MarkdownlintOptions): CheckDefinitionConfig;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=markdownlint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownlint.d.ts","sourceRoot":"","sources":["../../../src/presets/markdownlint.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAmBxD,gDAAgD;AAChD,UAAU,mBAAmB;IAC3B,4GAA4G;IAC5G,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACvB;AAeD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,qBAAqB,CAmDrF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CheckDefinitionConfig } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* publint has no machine-readable output mode -- only a plain-text CLI
|
|
4
|
+
* reporter (see its own `src/cli.js` `formatMessages`). Its process exit
|
|
5
|
+
* code reflects only 'error'-level findings; 'warning'/'suggestion'-level
|
|
6
|
+
* findings never affect it. This preset reads the same three section
|
|
7
|
+
* headers publint's own CLI writes ("Errors:", "Warnings:", "Suggestions:")
|
|
8
|
+
* to distinguish blocking findings from non-blocking ones, without
|
|
9
|
+
* depending on any per-message structure publint doesn't expose. Relevant
|
|
10
|
+
* only to repositories that publish an npm package.
|
|
11
|
+
*/
|
|
12
|
+
export declare const publint: CheckDefinitionConfig;
|
|
13
|
+
//# sourceMappingURL=publint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publint.d.ts","sourceRoot":"","sources":["../../../src/presets/publint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAKxD;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,EAAE,qBAsBrB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-deps.d.ts","sourceRoot":"","sources":["../../../src/presets/security-deps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AA0CxD,yDAAyD;AACzD,eAAO,MAAM,YAAY,EAAE,qBAkG1B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-secrets.d.ts","sourceRoot":"","sources":["../../../src/presets/security-secrets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAsBxD,2CAA2C;AAC3C,eAAO,MAAM,eAAe,EAAE,qBAoE7B,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PolicyResult } from "../../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The shared three-branch shape behind every lint-style preset's pass/warn/fail decision: fail,
|
|
4
|
+
* listing every error, if there are any; else warn, listing every warning, if there are any; else
|
|
5
|
+
* pass -- shared by `lint` (ESLint) and `stylelint`, whose only difference was the tool name
|
|
6
|
+
* substituted into each rationale string.
|
|
7
|
+
* @param toolName - the tool's own display name, substituted into every rationale (e.g. "ESLint", "stylelint").
|
|
8
|
+
* @param errorDetails - one rendered line per error-severity finding.
|
|
9
|
+
* @param warningDetails - one rendered line per warning-severity finding.
|
|
10
|
+
* @returns the fail/warn/pass `PolicyResult`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function errorWarningPassPolicy(toolName: string, errorDetails: readonly string[], warningDetails: readonly string[]): PolicyResult;
|
|
13
|
+
//# sourceMappingURL=error-warning-pass-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-warning-pass-policy.d.ts","sourceRoot":"","sources":["../../../../src/presets/shared/error-warning-pass-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,cAAc,EAAE,SAAS,MAAM,EAAE,GAChC,YAAY,CAsBd"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CheckEvidence } from "../../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A check's captured stdout and stderr, trimmed and joined into one block -- either stream may be
|
|
4
|
+
* empty and is dropped rather than contributing a blank line. Shared by `exitCodeFailRationale`
|
|
5
|
+
* below and by `publint` (which needs the combined text itself, not just a rendered failure
|
|
6
|
+
* message, to detect its own "Warnings:"/"Suggestions:" section headers).
|
|
7
|
+
* @param result - the check's execution evidence (only `stdout`/`stderr` are read).
|
|
8
|
+
* @returns the combined, trimmed stdout+stderr text, or `""` if the tool produced neither.
|
|
9
|
+
*/
|
|
10
|
+
export declare function combinedOutput(result: CheckEvidence): string;
|
|
11
|
+
/**
|
|
12
|
+
* Shared by every preset whose policy is a plain "exitCode 0 = pass, else
|
|
13
|
+
* render captured stdout/stderr (or fall back to an exit-code-only message
|
|
14
|
+
* if the tool produced neither)" -- `format`, `typecheck`, `commitlint`.
|
|
15
|
+
* Each preset still owns its own pass rationale and its own description of
|
|
16
|
+
* what failed; this only renders the shared "here's what the tool printed"
|
|
17
|
+
* half.
|
|
18
|
+
* @param result - the check's execution evidence (only `stdout`/`stderr`/`exitCode` are read).
|
|
19
|
+
* @param description - a present-tense description of the failure, e.g. "Prettier reported formatting failures".
|
|
20
|
+
* @returns `"{description}:\n{output}"` when the tool produced output, or `"{description} (exit code {N})."` otherwise.
|
|
21
|
+
*/
|
|
22
|
+
export declare function exitCodeFailRationale(result: CheckEvidence, description: string): string;
|
|
23
|
+
//# sourceMappingURL=exit-code-fail-rationale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-code-fail-rationale.d.ts","sourceRoot":"","sources":["../../../../src/presets/shared/exit-code-fail-rationale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAI5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAMxF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CheckEvidence, PolicyResult } from "../../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Every preset in `src/presets/*.ts` (except `securityDeps`, which shells out
|
|
4
|
+
* to `npm` itself -- something that cannot be "missing" in any environment
|
|
5
|
+
* capable of running `npm run <script>` at all) calls this first, before its
|
|
6
|
+
* own pass/fail/warn logic. `CheckEvidence.status === "spawn_error"` already
|
|
7
|
+
* distinguishes "the OS couldn't even launch the executable" from "the tool
|
|
8
|
+
* ran and exited non-zero" -- but not every spawn failure means the package
|
|
9
|
+
* is missing (a permission error or an invalid executable format lands here
|
|
10
|
+
* too), so this checks the structured `spawnErrorCode` for `"ENOENT"`
|
|
11
|
+
* specifically rather than treating every spawn error as "not installed."
|
|
12
|
+
* A non-ENOENT spawn error falls through to the preset's normal handling,
|
|
13
|
+
* unchanged, rather than getting a misleading "not installed" message.
|
|
14
|
+
* @param result - the check's raw execution evidence to inspect.
|
|
15
|
+
* @param packageName - the npm package a consumer would install to fix this (may differ from the binary name, e.g. `tsc` comes from `typescript`).
|
|
16
|
+
* @returns an actionable, package-manager-neutral `PolicyResult` if the tool appears to be missing, or `undefined` if the caller should proceed with its own interpretation.
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkDependencyInstalled(result: CheckEvidence, packageName: string): PolicyResult | undefined;
|
|
19
|
+
//# sourceMappingURL=missing-dependency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missing-dependency.d.ts","sourceRoot":"","sources":["../../../../src/presets/shared/missing-dependency.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAEjE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,MAAM,GAClB,YAAY,GAAG,SAAS,CAS1B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PolicyResult } from "../../types.js";
|
|
2
|
+
/** The report, already JSON-parsed and narrowed to `T`, or the fail `PolicyResult` to return verbatim when reading or parsing it failed. See `readJsonReport`. */
|
|
3
|
+
type ReadJsonReportResult<T> = {
|
|
4
|
+
readonly ok: true;
|
|
5
|
+
readonly value: T;
|
|
6
|
+
} | {
|
|
7
|
+
readonly ok: false;
|
|
8
|
+
readonly result: PolicyResult;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Reads and JSON-parses a report a tool wrote to disk rather than printing to stdout -- the "read,
|
|
12
|
+
* fail with one rationale if the read itself fails, fail with a different rationale if the JSON is
|
|
13
|
+
* invalid" shape shared by every preset whose tool has no stdout JSON mode (jscpd,
|
|
14
|
+
* markdownlint-cli2, secretlint). Each failure takes its own caller-supplied rationale rather than a
|
|
15
|
+
* generic shared message, since a missing report and invalid JSON usually point a consumer at a
|
|
16
|
+
* different fix (a misconfigured reporter/output flag vs. a genuinely broken tool run), and each
|
|
17
|
+
* tool's own advice differs (markdownlint's own read-failure rationale, for instance, names the
|
|
18
|
+
* specific config field to check).
|
|
19
|
+
*
|
|
20
|
+
* Takes the read itself as a thunk (`readRaw`), rather than a `path` this function reads from
|
|
21
|
+
* directly, so every call site's own `readFile(LITERAL_PATH, "utf8")` stays written as a literal
|
|
22
|
+
* argument in the caller's own file -- required by this repo's `security/detect-non-literal-fs-filename`
|
|
23
|
+
* policy, which forbids suppressing that rule outright (see policy-config.ts's `eslint.rules["security/*"]`)
|
|
24
|
+
* and would otherwise flag a `path: string` function parameter threaded into `readFile` here as
|
|
25
|
+
* non-literal.
|
|
26
|
+
* @param readRaw - reads the report's raw text (typically `() => readFile(REPORT_PATH, "utf8")`).
|
|
27
|
+
* @param onReadFailed - the rationale to fail with if `readRaw` rejects.
|
|
28
|
+
* @param onParseFailed - the rationale to fail with if the read text isn't valid JSON.
|
|
29
|
+
* @returns `{ ok: true, value }` with the parsed JSON narrowed to `T`, or `{ ok: false, result }` with the fail `PolicyResult` to return verbatim.
|
|
30
|
+
*/
|
|
31
|
+
export declare function readJsonReport<T>(readRaw: () => Promise<string>, onReadFailed: string, onParseFailed: string): Promise<ReadJsonReportResult<T>>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=read-json-report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-json-report.d.ts","sourceRoot":"","sources":["../../../../src/presets/shared/read-json-report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,kKAAkK;AAClK,KAAK,oBAAoB,CAAC,CAAC,IACzB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;CAAE,CAAA;AAElG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAC9B,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAclC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CheckEvidence, PolicyResult } from "../../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The guard every preset needs immediately after `checkDependencyInstalled`
|
|
4
|
+
* and before its own pass/fail logic: a check whose process did not run to a
|
|
5
|
+
* normal exit on its own -- it timed out, was aborted via `options.signal`,
|
|
6
|
+
* was killed by a host `SIGINT`/`SIGTERM`, received an external signal, or
|
|
7
|
+
* failed to spawn for a reason other than a missing executable -- has a
|
|
8
|
+
* `null` `exitCode` and only whatever partial output the tool managed before
|
|
9
|
+
* termination. Interpreting that with an exit-code comparison or a JSON
|
|
10
|
+
* parse would present an operational failure to the consumer as a fabricated
|
|
11
|
+
* tool-specific verdict ("TypeScript reported type errors (exit code null)",
|
|
12
|
+
* "ESLint output could not be parsed as JSON"). This reports the real
|
|
13
|
+
* terminal cause instead.
|
|
14
|
+
*
|
|
15
|
+
* `"completed"` returns `undefined` -- the process reached its own exit and
|
|
16
|
+
* the preset interprets the (possibly non-zero) exit code itself. The
|
|
17
|
+
* ENOENT `"spawn_error"` case is already handled by `checkDependencyInstalled`;
|
|
18
|
+
* this catches the remaining spawn failures (`EACCES`, `ENOEXEC`) that
|
|
19
|
+
* `missing-dependency.ts` documents as falling through.
|
|
20
|
+
* @param result - the check's raw execution evidence to inspect.
|
|
21
|
+
* @param toolName - the tool's own display name for the rationale (e.g. "ESLint", "TypeScript").
|
|
22
|
+
* @returns a fail `PolicyResult` describing the abnormal termination, or `undefined` if the process ran to its own exit and the caller should proceed.
|
|
23
|
+
*/
|
|
24
|
+
export declare function checkTerminatedAbnormally(result: CheckEvidence, toolName: string): PolicyResult | undefined;
|
|
25
|
+
//# sourceMappingURL=terminal-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-status.d.ts","sourceRoot":"","sources":["../../../../src/presets/shared/terminal-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGjE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,MAAM,GACf,YAAY,GAAG,SAAS,CAyC1B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ParsedOutput, PolicyResult } from "../../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Interprets Vitest's own `--reporter=json` output shape -- and nothing
|
|
4
|
+
* else. Shared between the `test` preset (a single, un-categorized
|
|
5
|
+
* `vitest run --reporter=json`) and this repository's own
|
|
6
|
+
* `test-unit`/`test-integration`/`test-property`/`test-e2e` checks, whose
|
|
7
|
+
* `run` splits tests into four mutually exclusive categories via
|
|
8
|
+
* scripts/run-test-category.mjs -- a repository-specific concern this
|
|
9
|
+
* function knows nothing about. Each of those four checks owns its own
|
|
10
|
+
* category-specific semantics on top of this evaluator; this function must
|
|
11
|
+
* stay narrowly scoped to "parse Vitest's JSON reporter shape," never grow
|
|
12
|
+
* into a general "testing policy" abstraction. A category's own
|
|
13
|
+
* `output.success === false` (vitest crashed / produced unparseable output)
|
|
14
|
+
* is kept distinct from a substantive test failure, exactly as every other
|
|
15
|
+
* preset in this package already does via `ParsedOutput.success`.
|
|
16
|
+
* @param output - the vitest check's parsed `--reporter=json` output to evaluate.
|
|
17
|
+
* @returns the pass/fail outcome and its rationale.
|
|
18
|
+
*/
|
|
19
|
+
export declare function evaluateVitestJsonPolicy(output: ParsedOutput<unknown> | undefined): PolicyResult;
|
|
20
|
+
//# sourceMappingURL=vitest-json-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest-json-policy.d.ts","sourceRoot":"","sources":["../../../../src/presets/shared/vitest-json-policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAMhE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,SAAS,GAAG,YAAY,CAsEhG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CheckDefinitionConfig } from "../types.js";
|
|
2
|
+
/** Options accepted by {@link stylelint}. */
|
|
3
|
+
interface StylelintOptions {
|
|
4
|
+
/** Glob passed straight through to stylelint as its positional target. Defaults to `"**\/*.{css,scss}"` -- adjust it for your own stylesheet file extensions (e.g. `.less`, `.vue`, `.svelte`). */
|
|
5
|
+
readonly glob?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* CSS/SCSS lint via stylelint, using whatever stylelint config the
|
|
9
|
+
* consumer's own repository already has. `severity: "error"` blocks;
|
|
10
|
+
* `severity: "warning"` is reported but never blocks, matching how the
|
|
11
|
+
* `lint` preset treats ESLint's own severities.
|
|
12
|
+
* @param options - configuration for this check; see {@link StylelintOptions}.
|
|
13
|
+
* @returns the configured check.
|
|
14
|
+
*/
|
|
15
|
+
export declare function stylelint(options?: StylelintOptions): CheckDefinitionConfig;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=stylelint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylelint.d.ts","sourceRoot":"","sources":["../../../src/presets/stylelint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAqBxD,6CAA6C;AAC7C,UAAU,gBAAgB;IACxB,mMAAmM;IACnM,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,qBAAqB,CAiE/E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../../src/presets/test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAKxD,oFAAoF;AACpF,eAAO,MAAM,IAAI,EAAE,qBAYlB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typecheck.d.ts","sourceRoot":"","sources":["../../../src/presets/typecheck.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAKxD,wCAAwC;AACxC,eAAO,MAAM,SAAS,EAAE,qBAkBvB,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CheckSchema, Evidence, RepoContractConfig, RunRepoContractOptions, Verdict } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Executes every configured check, collects its evidence, optionally parses
|
|
4
|
+
* its output, evaluates every check's repository-owned policy against the
|
|
5
|
+
* complete evidence, and aggregates a verdict. Never calls `process.exit()`
|
|
6
|
+
* -- returns data; the caller decides what to do with `verdict.passed`.
|
|
7
|
+
*
|
|
8
|
+
* Structural configuration problems throw synchronously before any process
|
|
9
|
+
* spawns. Anything only discoverable by attempting execution (a missing
|
|
10
|
+
* binary, a bad `cwd`) becomes evidence on that check (`status:
|
|
11
|
+
* "spawn_error"`), never a throw. A policy function throwing or rejecting
|
|
12
|
+
* rejects this function's own returned promise (`PolicyThrewError`, or an
|
|
13
|
+
* `AggregateError` of them if more than one policy failed this way) --
|
|
14
|
+
* distinct from a policy that ran fine and simply returned a failure
|
|
15
|
+
* string. See `src/errors.ts` for the full distinction.
|
|
16
|
+
*
|
|
17
|
+
* Execution and policy evaluation are strictly phased: every check finishes
|
|
18
|
+
* running and every check's evidence is fully assembled before any policy
|
|
19
|
+
* is invoked (see specs/architecture.md) -- a policy can safely read
|
|
20
|
+
* `ctx.evidence` for any sibling check's result.
|
|
21
|
+
*
|
|
22
|
+
* Deliberately not declared `async`: validation runs and can throw before this function returns
|
|
23
|
+
* anything at all, so a config problem is a genuine synchronous exception to the caller (as
|
|
24
|
+
* documented above and on `InvalidRepoContractConfigError`/`InvalidCheckConfigError`/
|
|
25
|
+
* `DependencyDeclaredLaterError`) -- an `async function`'s body runs to its first `await` still
|
|
26
|
+
* inside the caller's own call stack, but any throw before that point is nonetheless converted by
|
|
27
|
+
* the language into a rejected `Promise`, never surfaced as a synchronous exception. Splitting
|
|
28
|
+
* validation out into this synchronous wrapper, with the rest of the work in the `async` function
|
|
29
|
+
* below, keeps the documented synchronous-throw guarantee actually true rather than aspirational.
|
|
30
|
+
* @param config - the repo-contract configuration to run: its checks, concurrency, and their policies
|
|
31
|
+
* @param options - run options; `options.checks` restricts execution to specific check ids, `options.signal` allows cancelling the run
|
|
32
|
+
* @returns the assembled `evidence` for every check together with the aggregated `verdict`
|
|
33
|
+
*/
|
|
34
|
+
export declare function runRepoContract<const TChecks extends CheckSchema>(config: RepoContractConfig<TChecks>, options?: RunRepoContractOptions): Promise<{
|
|
35
|
+
evidence: Evidence<TChecks>;
|
|
36
|
+
verdict: Verdict<TChecks>;
|
|
37
|
+
}>;
|
|
38
|
+
//# sourceMappingURL=run-repo-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-repo-contract.d.ts","sourceRoot":"","sources":["../../src/run-repo-contract.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,sBAAsB,EACtB,OAAO,EACR,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,eAAe,CAAC,KAAK,CAAC,OAAO,SAAS,WAAW,EAC/D,MAAM,EAAE,kBAAkB,CAAC,OAAO,CAAC,EACnC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC,CAGrE"}
|