@jfalava/ts-standard 0.0.0-stage → 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/README.md CHANGED
@@ -1,3 +1,198 @@
1
- # Temporary Holding Version
1
+ # @jfalava/ts-standard
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Checks a Bun repo against the TypeScript scripts and workflows standard: the `package.json` scripts of the root and every workspace, version pins, `bunfig.toml`, the tsconfig files and the GitHub workflows. It reads files and changes nothing.
4
+
5
+ It is a standalone checker, not an oxlint plugin, because oxlint only lints JavaScript and TypeScript: given a `package.json`, a `tsconfig.json` or a workflow, oxlint 1.95.0 reports `No files found to lint`, and its plugin API has no hook for other file types.
6
+
7
+ ## Wiring it into a repo
8
+
9
+ 1. Add it, with an exact version as the standard requires:
10
+
11
+ ```sh
12
+ bun add --dev --exact @jfalava/ts-standard
13
+ ```
14
+
15
+ In a workspace repo, put it in the root `catalogs` and reference it as `catalog:`.
16
+
17
+ 2. Exclude the scope from the release-age wait in `bunfig.toml`, or every new version waits a day before it installs. The `pins/bunfig` rule requires this entry:
18
+
19
+ ```toml
20
+ [install]
21
+ minimumReleaseAge = 86400
22
+ minimumReleaseAgeExcludes = [
23
+ "@jfalava/*",
24
+ # …
25
+ ]
26
+ ```
27
+
28
+ 3. Add the script and end the root `check` with it:
29
+
30
+ ```json
31
+ {
32
+ "scripts": {
33
+ "check": "bun run --workspaces check && bun run standard:check",
34
+ "standard:check": "ts-standard"
35
+ }
36
+ }
37
+ ```
38
+
39
+ In a single-package repo, append `&& bun run standard:check` to `check` after `bun run test`.
40
+
41
+ 4. If the repo differs from the standard anywhere, add a `standard.config.ts` at its root. Without one, every rule applies with the defaults.
42
+
43
+ `ts-standard [dir] [--config <file>] [--json]` checks `dir` (default `.`) with `<dir>/standard.config.ts`. It exits 1 when an error is left, and 0 when only warnings are.
44
+
45
+ ## `standard.config.ts`
46
+
47
+ ```ts
48
+ import { defineStandard } from "@jfalava/ts-standard";
49
+
50
+ export default defineStandard({
51
+ // "private" repos gate on Workers Builds and must not have a ci.yml. Default "public".
52
+ visibility: "public",
53
+ // Which column of the standard's script table a package follows. Unlisted packages are "oxc".
54
+ toolchains: { docs: "astro" },
55
+ // What this repo's ci.yml adds to the reference.
56
+ ci: {
57
+ ignoreAdd: ["docs/AGENT.md", "LICENSES/**"], // extra negations in the `code` filter, no "!"
58
+ ignoreRemove: ["**/README.md"], // standard negations this repo counts as code
59
+ filters: ["rust"], // filters beside `code` in the `changes` step
60
+ jobs: ["advisories", "rust"], // jobs beside `changes` and `check`
61
+ env: ["CARGO_TERM_COLOR"], // top-level env keys
62
+ },
63
+ exceptions: [
64
+ {
65
+ rule: "scripts/check-runs-own-checks",
66
+ where: "docs", // package directory ("." for the root) or repo-relative file
67
+ script: "licenses:check", // optional, for script rules
68
+ why: "Needs cargo and the network, which Workers Builds lacks.",
69
+ },
70
+ ],
71
+ });
72
+ ```
73
+
74
+ Toolchains set what `typecheck` must be: `effect-tsgo tsrs --noEmit` for `oxc` and `vite-plus`, `astro check` for `astro`, and `tsc --noEmit` for `pulumi`. `astro` and `pulumi` packages may also depend on `typescript`, and are not held to the tsconfig base rules.
75
+
76
+ ### Exceptions
77
+
78
+ An exception covers every finding with the same `rule` whose `where` and `script` match. Omitting `where` or `script` matches any. A `where` of a file also covers its line findings, such as `.github/workflows/ci.yml:33`. Each needs a `why`; keep it in step with the exceptions table in the repo's README.
79
+
80
+ An exception that covers nothing is itself an error, `standard/stale-exception`, so the list shrinks when the repo catches up with the standard.
81
+
82
+ ## Rules
83
+
84
+ Every rule is an error except `workflows/reference-pins`, which is a warning: it prints and does not fail.
85
+
86
+ A package is a workspace package in a workspace repo, or the root in a single-package repo.
87
+
88
+ ### Scripts
89
+
90
+ | Rule | Checks |
91
+ | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
92
+ | `scripts/required` | Every package has `check`, `fix`, `lint`, `lint:fix`, `format`, `format:check` and `typecheck`. A workspace root also has `test`. |
93
+ | `scripts/check-body` | A package's `check` is `bun run lint && bun run format:check && bun run typecheck && bun run test` (`test` only if it has one), followed only by `bun run <thing>:check`. |
94
+ | `scripts/check-read-only` | Nothing reached from any `check`, following `bun run`, `--cwd` and `--workspaces`, writes files: no `--fix`, `--write`, bare `oxfmt` or `vp fmt`. |
95
+ | `scripts/check-runs-own-checks` | Every `<thing>:check` script is reached from that package's `check`. |
96
+ | `scripts/no-bare-bun-test` | Only `test` and `test:*` call `bun test`; aggregates call `bun run test`. |
97
+ | `scripts/fix-body` | `fix` is `bun run lint:fix && bun run format`. |
98
+ | `scripts/fix-pairs` | Every `lint*:fix` is its `lint*` with `--fix`, or calls the `:fix` variants. |
99
+ | `scripts/format-pair` | `format:check` is `format` in check mode (`--check` in place of `--write`, or appended). |
100
+ | `scripts/lint-type-aware` | Every `oxlint` reached from `lint` in an `oxc` or `astro` package passes `--type-aware --type-check`. |
101
+ | `scripts/lint-body` | An Astro package's `lint` is `bun run lint:oxlint && bun run lint:astro && bun run lint:docs`. |
102
+ | `scripts/typecheck` | `typecheck` is the toolchain's command. |
103
+ | `scripts/test-runs-once` | `test` does not start watch mode: `vitest run`, not `vitest`. |
104
+ | `scripts/root-fan-out` | Each root verb fans out with `bun run --workspaces`; `check` without `--if-present`, the others with it. Only a repo-wide prerequisite such as `bun run build:types` may run before the fan-out. Every package has a `check`. |
105
+ | `scripts/no-global-suffix` | No script name ends in `:global`. |
106
+ | `scripts/no-root-shortcuts` | No root script is only `bun run --cwd <pkg> <script>`, except `dev` and the deploy scripts. |
107
+ | `scripts/no-filter` | No `bun run --filter`: it does not pass stdin. |
108
+ | `scripts/no-bunx` | No `bunx` or `bun x`. |
109
+ | `scripts/no-hooks` | No `pre<script>` hooks beside `prepare`. |
110
+ | `scripts/ci-build` | The root `ci:build` is `bun run check` or `bun run check && bun run build`, it exists when `ci:deploy` does, and no package has one. |
111
+
112
+ ### Deploy
113
+
114
+ These apply to `plan`, `deploy`, `ci:deploy` and `destroy` commands that run `alchemy` or `pulumi`.
115
+
116
+ | Rule | Checks |
117
+ | ------------------------ | ------------------------------------------------------------------------------------------- |
118
+ | `deploy/explicit-target` | The command names its target: `--stage`, `--stack` or a variable assignment in front of it. |
119
+ | `deploy/same-target` | All four scripts in a package name the same target. |
120
+ | `deploy/interactive` | `ci:deploy` passes `--yes`; `deploy` and `destroy` do not. |
121
+ | `deploy/plan` | `plan` is `alchemy plan`, and exists when `deploy` does. |
122
+ | `deploy/no-checks` | `deploy` and `ci:deploy` run none of the check verbs and rewrite no files. |
123
+
124
+ ### Pins
125
+
126
+ | Rule | Checks |
127
+ | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
128
+ | `pins/package-manager` | The root `packageManager` is `bun@<exact>`. |
129
+ | `pins/exact` | Every catalog entry and dependency is an exact version (`npm:` aliases and SHA-pinned git URLs included), and every `catalog:` reference resolves. |
130
+ | `pins/use-catalog` | In a workspace repo, a dependency that a root catalog lists uses `catalog:`. |
131
+ | `pins/toolchain-deps` | The root has `@effect/tsgo`, `@oxlint/plugins`, `oxfmt`, `oxlint` and `tsrs`; nothing has `oxlint-tsgolint`; only Astro and Pulumi packages have `typescript`. |
132
+ | `pins/bun-types` | `bun-types` or `@types/bun` is the `packageManager` version. |
133
+ | `pins/prepare` | The root `prepare` is `effect-tsgo patch --no-typescript --tsrs --oxlint`. |
134
+ | `pins/bunfig` | `bunfig.toml` exists, sets `minimumReleaseAge` to at least 86400, and excludes `@effect/tsgo`, its seven platform packages and `@jfalava/*`. |
135
+
136
+ ### tsconfig
137
+
138
+ The base is `tsconfig.base.json` in a workspace repo and `tsconfig.json` otherwise.
139
+
140
+ | Rule | Checks |
141
+ | ------------------------------------ | ------------------------------------------------------------------------------------------------------ |
142
+ | `tsconfig/base` | The base exists and its `$schema` is `./node_modules/@effect/tsgo/schema.json`. |
143
+ | `tsconfig/effect-plugin` | The base has the `@effect/language-service` plugin entry, and no package tsconfig overrides `plugins`. |
144
+ | `tsconfig/no-emit` | The base sets `noEmit: true`. |
145
+ | `tsconfig/strict-in-base` | The base sets `strict` and `noUncheckedIndexedAccess`; package tsconfigs set no strict flags. |
146
+ | `tsconfig/extends-base` | Each `oxc` or `vite-plus` package has a `tsconfig.json` that extends the base. |
147
+ | `tsconfig/one-per-package` | No `tsconfig.*.json` beside a package's `tsconfig.json`. |
148
+ | `tsconfig/no-ignore-effect-warnings` | No tsconfig sets `ignoreEffectWarningsInTscExitCode: true`. |
149
+
150
+ ### Workflows
151
+
152
+ | Rule | Checks |
153
+ | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
154
+ | `workflows/ci-reference` | A public repo has `ci.yml` and a private one does not. `ci.yml` equals `reference/ci.yml` once the additions in `ci` are taken out, ignoring action refs. Filter differences name the pattern. |
155
+ | `workflows/actions-pinned` | Every `uses:` outside the repo is pinned to a 40-character SHA with a `# v…` comment. |
156
+ | `workflows/reference-pins` | Warning. An action the reference also uses is at the reference's SHA. |
157
+ | `workflows/dependabot` | `.github/dependabot.yml` has a `github-actions` entry. |
158
+ | `workflows/hygiene` | Every workflow has top-level `permissions` and a `concurrency` group (reusable workflows excepted), and every job that runs steps has `timeout-minutes`. |
159
+ | `workflows/bun-from-package-manager` | No `setup-bun` step sets `bun-version`. |
160
+ | `workflows/scripts-only` | `run:` steps call bun only as `bun install --frozen-lockfile` or `bun run <script>`, never `bunx`, and never `--ignore-scripts`. |
161
+ | `workflows/release-check` | A tag-triggered workflow runs `bun run check`. |
162
+ | `workflows/release-version` | A tag-triggered workflow checks the tag against the package version (`${GITHUB_REF_NAME#v}`). |
163
+ | `workflows/release-build` | A tag-triggered workflow calls `build:<target>` scripts, and every matrix target exists as a script in the package it runs in. |
164
+
165
+ ## Developing
166
+
167
+ `bun run check` is the gate; `bun run fix` rewrites. The tests in `test/check.test.ts` run the checker on copies of six repos' files (`test/fixtures/repos`, with the commits in `test/fixtures/README.md`) against reviewed results in `test/golden/`, and on three fixtures built to break specific rules. After a rule change, compare the new output with the golden by hand before updating it.
168
+
169
+ `reference/ci.yml` is the shared `ci.yml`, copied from lazyotp. Update it here first; every repo's `workflows/ci-reference` then reports the difference until its copy matches.
170
+
171
+ ## Releasing
172
+
173
+ Bump `version` in `package.json`, commit, then tag and push `v<version>`. `.github/workflows/release.yml` checks that the tag matches, runs `bun run check`, and publishes to npm through trusted publishing, with a provenance attestation and no stored npm token.
174
+
175
+ The first version cannot go through the workflow: npm attaches a trusted publisher only to a package that already exists. See the setup below.
176
+
177
+ ### npm setup (once)
178
+
179
+ 1. On npmjs.com, enable two-factor authentication on the account that owns the `@jfalava` scope.
180
+ 2. Create the package with one version from a logged-in npm CLI (npm 11.15.0 or later, Node 22.14.0 or later), from a clean checkout of the tagged commit:
181
+
182
+ ```sh
183
+ npm login
184
+ npm publish --access public
185
+ ```
186
+
187
+ Or stage it instead, which creates the package without a live release: `npm stage publish`, then approve it with 2FA through `npm stage approve <stage-id>` or the **Staged Packages** tab. Until approval the package shows a public `0.0.0-stage` placeholder.
188
+
189
+ 3. Open npmjs.com → Packages → `@jfalava/ts-standard` → Settings → Trusted publishing, choose **GitHub Actions**, and enter:
190
+ - Organization or user: `jfalava`
191
+ - Repository: `ts-standard`
192
+ - Workflow filename: `release.yml`
193
+ - Environment name: empty
194
+ - Allowed actions: **Allow npm publish** (new configurations allow only `npm stage publish` by default, and the workflow runs `npm publish`)
195
+ 4. Push the next `v<version>` tag within 2 days. A new trusted publisher that has not published successfully within 2 days expires and must be deleted and recreated. The tag of the version published by hand can be pushed at any time: its release run finds that version on npm and skips the publish.
196
+ 5. Once that release has published, set Settings → Publishing access to **Require two-factor authentication and disallow tokens**, and revoke any npm token used in step 2.
197
+
198
+ npm does not check these values when they are saved. A mismatch, such as a different workflow filename, fails only at publish time, often as a 404. `repository.url` in `package.json` must stay `git+https://github.com/jfalava/ts-standard.git`.
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "@jfalava/ts-standard",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Checks a Bun repo against the TypeScript scripts and workflows standard: package.json scripts, pins, tsconfig and GitHub workflows.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/jfalava/ts-standard.git"
8
+ },
9
+ "bin": {
10
+ "ts-standard": "./src/cli.ts"
11
+ },
12
+ "files": [
13
+ "src",
14
+ "reference"
15
+ ],
16
+ "type": "module",
17
+ "exports": {
18
+ ".": "./src/config.ts"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "scripts": {
24
+ "check": "bun run lint && bun run format:check && bun run typecheck && bun run test && bun run standard:check",
25
+ "fix": "bun run lint:fix && bun run format",
26
+ "format": "oxfmt",
27
+ "format:check": "oxfmt --check",
28
+ "lint": "oxlint --type-aware --type-check",
29
+ "lint:fix": "oxlint --type-aware --type-check --fix",
30
+ "prepare": "effect-tsgo patch --no-typescript --tsrs --oxlint",
31
+ "standard:check": "bun src/cli.ts",
32
+ "test": "bun test",
33
+ "typecheck": "effect-tsgo tsrs --noEmit"
34
+ },
35
+ "devDependencies": {
36
+ "@effect/tsgo": "0.74.1",
37
+ "@oxlint/plugins": "1.95.0",
38
+ "bun-types": "1.4.5",
39
+ "oxfmt": "0.80.0",
40
+ "oxlint": "1.95.0",
41
+ "tsrs": "7.1.0-beta.tsrs5"
42
+ },
43
+ "packageManager": "bun@1.4.5"
44
+ }
@@ -0,0 +1,64 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["**"]
6
+ pull_request:
7
+
8
+ concurrency:
9
+ group: ci-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ # Decides whether `check` runs. A skipped `check` still satisfies the branch rule, which a
17
+ # workflow skipped by `paths-ignore` would not. Every path counts as code except the ones
18
+ # negated below. On a pull request the diff is against the base branch, on a push to the
19
+ # default branch against the previous push, and on any other branch against its merge
20
+ # base with the default branch.
21
+ #
22
+ # `check` is skipped only when this job reports `code` as false. If this job fails, its
23
+ # output is empty and `check` runs anyway, so the branch rule needs only `check`.
24
+ changes:
25
+ runs-on: ubuntu-latest
26
+ timeout-minutes: 5
27
+ permissions:
28
+ contents: read
29
+ pull-requests: read
30
+ outputs:
31
+ code: ${{ steps.filter.outputs.code }}
32
+ steps:
33
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
34
+ - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
35
+ id: filter
36
+ with:
37
+ predicate-quantifier: some-with-excludes
38
+ filters: |
39
+ code:
40
+ - "**"
41
+ - "!**/README.md"
42
+ - "!**/AGENTS.md"
43
+ - "!**/CLAUDE.md"
44
+ - "!LICENSE*"
45
+ - "!.agents/**"
46
+ - "!.zed/**"
47
+ - "!.vscode/**"
48
+ - "!.github/dependabot.yml"
49
+
50
+ check:
51
+ needs: changes
52
+ if: ${{ !cancelled() && needs.changes.outputs.code != 'false' }}
53
+ runs-on: ubuntu-latest
54
+ timeout-minutes: 15
55
+ steps:
56
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
57
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
58
+ - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
59
+ with:
60
+ path: ~/.bun/install/cache
61
+ key: bun-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('bun.lock') }}
62
+ restore-keys: bun-${{ runner.os }}-${{ runner.arch }}-
63
+ - run: bun install --frozen-lockfile
64
+ - run: bun run check
package/src/check.ts ADDED
@@ -0,0 +1,54 @@
1
+ import type { Exception, StandardConfig } from "./config.ts";
2
+ import type { Finding } from "./finding.ts";
3
+ import { pinRules } from "./pins.ts";
4
+ import { loadRepo } from "./repo.ts";
5
+ import { scriptRules } from "./scripts.ts";
6
+ import { workflowRules } from "./workflows.ts";
7
+
8
+ export type Severity = "error" | "warn";
9
+
10
+ /** Rules that print but do not fail. Every other rule is an error. */
11
+ const WARN_RULES: ReadonlySet<string> = new Set(["workflows/reference-pins"]);
12
+
13
+ export const severityOf = (rule: string): Severity => (WARN_RULES.has(rule) ? "warn" : "error");
14
+
15
+ export interface Result {
16
+ readonly repo: string;
17
+ /** Findings no exception covers, plus exceptions that cover nothing. */
18
+ readonly errors: readonly Finding[];
19
+ readonly warnings: readonly Finding[];
20
+ /** How many findings an exception covered. */
21
+ readonly excepted: number;
22
+ }
23
+
24
+ const matches = (e: Exception, f: Finding): boolean =>
25
+ e.rule === f.rule &&
26
+ (e.where === undefined || e.where === f.where || f.where.startsWith(`${e.where}:`)) &&
27
+ (e.script === undefined || e.script === f.script);
28
+
29
+ /** Runs every rule against the repo at `root`. Reads files only. */
30
+ export const check = (root: string, config: StandardConfig): Result => {
31
+ const repo = loadRepo(root, config);
32
+ const findings = [...scriptRules(repo), ...pinRules(repo), ...workflowRules(repo)];
33
+ const exceptions = config.exceptions ?? [];
34
+ const used = new Set<Exception>();
35
+ const open = findings.filter((f) => {
36
+ const e = exceptions.find((x) => matches(x, f));
37
+ if (e) used.add(e);
38
+ return !e;
39
+ });
40
+ const stale: Finding[] = exceptions
41
+ .filter((e) => !used.has(e))
42
+ .map((e) => ({
43
+ rule: "standard/stale-exception",
44
+ where: e.where ?? "*",
45
+ script: e.script,
46
+ message: `exception for \`${e.rule}\` matches nothing; remove it`,
47
+ }));
48
+ return {
49
+ repo: repo.name,
50
+ errors: [...open.filter((f) => severityOf(f.rule) === "error"), ...stale],
51
+ warnings: open.filter((f) => severityOf(f.rule) === "warn"),
52
+ excepted: findings.length - open.length,
53
+ };
54
+ };
package/src/cli.ts ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env bun
2
+ // `ts-standard [dir] [--config file] [--json]`: read-only. Exits 1 when an error is left after the
3
+ // repo's exceptions, including an exception that matches nothing. Warnings print and pass.
4
+ import { existsSync } from "node:fs";
5
+ import { join, resolve } from "node:path";
6
+
7
+ import { check } from "./check.ts";
8
+ import type { StandardConfig } from "./config.ts";
9
+ import type { Finding } from "./finding.ts";
10
+
11
+ const args = process.argv.slice(2);
12
+ const configIdx = args.indexOf("--config");
13
+ const dirArg = args.find((a, i) => !a.startsWith("--") && (configIdx < 0 || i !== configIdx + 1));
14
+ const root = resolve(dirArg ?? ".");
15
+ const configArg = configIdx >= 0 ? args[configIdx + 1] : undefined;
16
+ const configPath = configArg === undefined ? join(root, "standard.config.ts") : resolve(configArg);
17
+ const config: StandardConfig = existsSync(configPath) ? (await import(configPath)).default : {};
18
+
19
+ const result = check(root, config);
20
+
21
+ const line = (level: string, f: Finding) =>
22
+ `${level} ${f.rule} ${f.where}${f.script === undefined ? "" : ` [${f.script}]`} ${f.message}`;
23
+
24
+ if (args.includes("--json")) {
25
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
26
+ } else {
27
+ const out = [
28
+ ...result.errors.map((f) => line("error", f)),
29
+ ...result.warnings.map((f) => line("warn ", f)),
30
+ `${result.repo}: ${result.errors.length} error(s), ${result.warnings.length} warning(s), ${result.excepted} excepted`,
31
+ ];
32
+ process.stdout.write(`${out.join("\n")}\n`);
33
+ }
34
+ process.exit(result.errors.length > 0 ? 1 : 0);
package/src/config.ts ADDED
@@ -0,0 +1,41 @@
1
+ // The public entry point: what a repo's `standard.config.ts` imports. It has no imports of its
2
+ // own, so a consumer's typecheck reads only this file, whatever its tsconfig flags are.
3
+
4
+ /** Which column of the standard's script table a package follows. */
5
+ export type Toolchain = "oxc" | "astro" | "pulumi" | "vite-plus";
6
+
7
+ /** A documented exception. It must match a finding, or it is reported as stale. */
8
+ export interface Exception {
9
+ /** Rule id, such as "scripts/check-runs-own-checks". */
10
+ readonly rule: string;
11
+ /** Package directory ("." for the root) or repo-relative file. Omit to match anywhere. */
12
+ readonly where?: string;
13
+ /** Script name, for script rules. Omit to match every script. */
14
+ readonly script?: string;
15
+ /** Why the repo differs. Keep it in step with the README's exceptions table. */
16
+ readonly why: string;
17
+ }
18
+
19
+ export interface StandardConfig {
20
+ /** Public repos gate on `ci.yml`; private ones gate on Workers Builds and have none. Default "public". */
21
+ readonly visibility?: "public" | "private";
22
+ /** Package directory to toolchain. Packages not listed are "oxc". */
23
+ readonly toolchains?: Readonly<Record<string, Toolchain>>;
24
+ /** What this repo's `ci.yml` adds to the reference. */
25
+ readonly ci?: {
26
+ /** Extra negations in the `code` filter, without the leading "!". */
27
+ readonly ignoreAdd?: readonly string[];
28
+ /** Standard negations this repo counts as code, without the leading "!". */
29
+ readonly ignoreRemove?: readonly string[];
30
+ /** Extra filters in the `changes` step, beside `code`. */
31
+ readonly filters?: readonly string[];
32
+ /** Extra jobs beside `changes` and `check`. */
33
+ readonly jobs?: readonly string[];
34
+ /** Extra top-level `env` keys. */
35
+ readonly env?: readonly string[];
36
+ };
37
+ readonly exceptions?: readonly Exception[];
38
+ }
39
+
40
+ /** Identity function that types a `standard.config.ts`. */
41
+ export const defineStandard = (config: StandardConfig): StandardConfig => config;
package/src/finding.ts ADDED
@@ -0,0 +1,8 @@
1
+ /** One way a repo differs from the standard. Severity comes from the rule (`severityOf`). */
2
+ export interface Finding {
3
+ readonly rule: string;
4
+ /** Package directory or repo-relative file. */
5
+ readonly where: string;
6
+ readonly script?: string | undefined;
7
+ readonly message: string;
8
+ }