@jfalava/ts-standard 0.3.3 → 0.3.4

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.
@@ -0,0 +1,36 @@
1
+ # `standard.config.ts`
2
+
3
+ ```ts
4
+ import { defineStandard } from "@jfalava/ts-standard";
5
+
6
+ export default defineStandard({
7
+ // "private" repos gate on Workers Builds and must not have a ci.yml. Default "public".
8
+ visibility: "public",
9
+ // Which column of the standard's script table a package follows. Unlisted packages are "oxc".
10
+ toolchains: { docs: "astro" },
11
+ // What this repo's ci.yml adds to the reference.
12
+ ci: {
13
+ ignoreAdd: ["docs/AGENT.md", "LICENSES/**"], // extra negations in the `code` filter, no "!"
14
+ ignoreRemove: ["**/README.md"], // standard negations this repo counts as code
15
+ filters: ["rust"], // filters beside `code` in the `changes` step
16
+ jobs: ["advisories", "rust"], // jobs beside `changes` and `check`
17
+ env: ["CARGO_TERM_COLOR"], // top-level env keys
18
+ },
19
+ exceptions: [
20
+ {
21
+ rule: "scripts/check-runs-own-checks",
22
+ where: "docs", // package directory ("." for the root) or repo-relative file
23
+ script: "licenses:check", // optional, for script rules
24
+ why: "Needs cargo and the network, which Workers Builds lacks.",
25
+ },
26
+ ],
27
+ });
28
+ ```
29
+
30
+ 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.
31
+
32
+ ## Exceptions
33
+
34
+ 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.
35
+
36
+ An exception that covers nothing is itself an error, `standard/stale-exception`, so the list shrinks when the repo catches up with the standard. An exception for `lint/anti-slop` or `lint/pending` names what it excuses, `<package dir>:<plugin>` or `<package dir>:<rule>`, and matches only that; one without, such as `where: "."`, would excuse a whole package and is an error, `standard/broad-exception`.
package/docs/deploy.md ADDED
@@ -0,0 +1,11 @@
1
+ # Deploy rules
2
+
3
+ These apply to `plan`, `deploy`, `ci:deploy` and `destroy` commands that run `alchemy` or `pulumi`.
4
+
5
+ | Rule | Checks |
6
+ | ------------------------ | ------------------------------------------------------------------------------------------- |
7
+ | `deploy/explicit-target` | The command names its target: `--stage`, `--stack` or a variable assignment in front of it. |
8
+ | `deploy/same-target` | All four scripts in a package name the same target. |
9
+ | `deploy/interactive` | `ci:deploy` passes `--yes`; `deploy` and `destroy` do not. |
10
+ | `deploy/plan` | `plan` is `alchemy plan`, and exists when `deploy` does. |
11
+ | `deploy/no-checks` | `deploy` and `ci:deploy` run none of the check verbs and rewrite no files. |
package/docs/lint.md ADDED
@@ -0,0 +1,33 @@
1
+ # Lint rules
2
+
3
+ Every repo lints over [`@cloudflare/oxlint-config`](https://www.npmjs.com/package/@cloudflare/oxlint-config). The [anti-slop](https://github.com/dmmulroy/anti-slop) rules it does not carry ship in this package as two oxlint JS plugins, built from `oxlint/` (MIT, Dillon Mulroy; see `oxlint/UPSTREAM.md`):
4
+
5
+ | Specifier | Plugin name | Rules |
6
+ | ------------------------------------ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
7
+ | `@jfalava/ts-standard/oxlint` | `anti-slop` | `no-module-mocking`, `require-safety-comment-for-type-assertion` |
8
+ | `@jfalava/ts-standard/oxlint/effect` | `anti-slop-effect` | `no-manual-effect-error-tag`, `no-manual-tag-comparison`, `no-manual-tagged-construction`, `no-service-constructor-imports`, `prefer-effect-match` |
9
+
10
+ Load them by absolute path, so a workspace config that spreads the root one resolves them the same; they need `@oxlint/plugins`, which `pins/toolchain-deps` already requires:
11
+
12
+ ```ts
13
+ import { fileURLToPath } from "node:url";
14
+
15
+ const antiSlop = fileURLToPath(import.meta.resolve("@jfalava/ts-standard/oxlint"));
16
+
17
+ export default defineConfig({
18
+ jsPlugins: [...(preset.jsPlugins ?? []), { name: "anti-slop", specifier: antiSlop }],
19
+ // …
20
+ });
21
+ ```
22
+
23
+ | Rule | Checks |
24
+ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25
+ | `lint/preset` | The root `oxlint.config.ts` imports `@cloudflare/oxlint-config`, splits off its root-only `options` (`const { options: presetOptions, ...preset } = cloudflare`) and spreads them back, and sets `categories.correctness`. No `oxlint.config.ts` uses `extends`. |
26
+ | `lint/anti-slop` | Each package with an `oxlint` script loads its oxlint config as oxlint does (the `-c` file, or the nearest `oxlint.config.ts`) and reads the resolved `jsPlugins` and `rules`. It loads `@jfalava/ts-standard/oxlint` as `anti-slop`. It loads `@jfalava/ts-standard/oxlint/effect` as `anti-slop-effect` exactly when it depends on `effect`. Every rule of a loaded plugin is on or pending, at the top level and in every `overrides` entry: off or `warn` (`0` or `1`) only as `"anti-slop/x": "off", // <findings>` in a file the package's config is built from (the config and the files it imports by relative path), or excepted at `<package dir>:<plugin>/<rule>`. The repo no longer vendors `tools/oxlint/anti-slop`. |
27
+ | `lint/pending` | A warning fails nothing, so a rule the repo's own config files set to `warn` (or `1`), at the top level or in an `overrides` entry, is pending work: it carries its count, as `"x": "warn", // <findings>` in a file the package's config is built from, or is excepted at `<package dir>:<rule>`. Warnings a preset sets, such as `@effect/tsgo`'s diagnostics, are the preset's policy and are not checked. |
28
+
29
+ Known gaps in the two lint rules above:
30
+
31
+ - They read only packages with a script that runs `oxlint`. A `vite-plus` package that lints with `vp lint` is skipped, so its plugins and pending rules go unchecked until the web round covers it.
32
+ - A category set to `warn`, such as `categories: { suspicious: "warn" }`, is not a rule entry, so `lint/pending` does not see it.
33
+ - Counts are not verified against a lint run; a pending entry only has to carry one.
package/docs/pins.md ADDED
@@ -0,0 +1,11 @@
1
+ # Pin rules
2
+
3
+ | Rule | Checks |
4
+ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
5
+ | `pins/package-manager` | The root `packageManager` is `bun@<exact>`. |
6
+ | `pins/exact` | Every catalog entry and dependency is an exact version (`npm:` aliases and SHA-pinned git URLs included), and every `catalog:` reference resolves. |
7
+ | `pins/use-catalog` | In a workspace repo, a dependency that a root catalog lists uses `catalog:`. |
8
+ | `pins/toolchain-deps` | The root has `@cloudflare/oxlint-config`, `@effect/tsgo`, `@oxlint/plugins`, `oxfmt`, `oxlint` and `tsrs`; nothing has `oxlint-tsgolint`; only Astro and Pulumi packages have `typescript`. |
9
+ | `pins/bun-types` | `bun-types` or `@types/bun` is the `packageManager` version. |
10
+ | `pins/prepare` | The root `prepare` is `effect-tsgo patch --no-typescript --tsrs --oxlint`. |
11
+ | `pins/bunfig` | `bunfig.toml` exists, sets `minimumReleaseAge` to at least 86400, and excludes `@effect/tsgo`, its seven platform packages and `@jfalava/ts-standard`. |
@@ -0,0 +1,24 @@
1
+ # Script rules
2
+
3
+ | Rule | Checks |
4
+ | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
5
+ | `scripts/required` | Every package has `check`, `fix`, `lint`, `lint:fix`, `format`, `format:check` and `typecheck`. A workspace root also has `test`. |
6
+ | `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`. |
7
+ | `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`. |
8
+ | `scripts/check-runs-own-checks` | Every `<thing>:check` script is reached from that package's `check`. |
9
+ | `scripts/no-bare-bun-test` | Only `test` and `test:*` call `bun test`; aggregates call `bun run test`. |
10
+ | `scripts/fix-body` | `fix` is `bun run lint:fix && bun run format`. |
11
+ | `scripts/fix-pairs` | Every `lint*:fix` is its `lint*` with `--fix`, or calls the `:fix` variants. |
12
+ | `scripts/format-pair` | `format:check` is `format` in check mode (`--check` in place of `--write`, or appended). |
13
+ | `scripts/lint-type-aware` | Every `oxlint` reached from `lint` in an `oxc` or `astro` package passes `--type-aware --type-check`. |
14
+ | `scripts/lint-unused-directives` | In a workspace repo, every `oxlint` reached from a workspace package's `lint` passes `--report-unused-disable-directives-severity=error`. The preset's `reportUnusedDisableDirectives` is a root-only option. |
15
+ | `scripts/lint-body` | An Astro package's `lint` is `bun run lint:oxlint && bun run lint:astro && bun run lint:docs`. |
16
+ | `scripts/typecheck` | `typecheck` is the toolchain's command. |
17
+ | `scripts/test-runs-once` | `test` does not start watch mode: `vitest run`, not `vitest`. |
18
+ | `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`. |
19
+ | `scripts/no-global-suffix` | No script name ends in `:global`. |
20
+ | `scripts/no-root-shortcuts` | No root script is only `bun run --cwd <pkg> <script>`, except `dev` and the deploy scripts. |
21
+ | `scripts/no-filter` | No `bun run --filter`: it does not pass stdin. |
22
+ | `scripts/no-bunx` | No `bunx` or `bun x`. |
23
+ | `scripts/no-hooks` | No `pre<script>` hooks beside `prepare`. |
24
+ | `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. |
package/docs/setup.md ADDED
@@ -0,0 +1,37 @@
1
+ # Wiring it into a repo
2
+
3
+ 1. Add it, with an exact version as the standard requires:
4
+
5
+ ```sh
6
+ bun add --dev --exact @jfalava/ts-standard
7
+ ```
8
+
9
+ In a workspace repo, put it in the root `catalogs` and reference it as `catalog:`.
10
+
11
+ 2. Exclude the package from the release-age wait in `bunfig.toml`, or every new version waits a day before it installs. Bun matches these entries by exact name, so a scope glob such as `@jfalava/*` excludes nothing. The `pins/bunfig` rule requires this entry:
12
+
13
+ ```toml
14
+ [install]
15
+ minimumReleaseAge = 86400
16
+ minimumReleaseAgeExcludes = [
17
+ "@jfalava/ts-standard",
18
+ # …
19
+ ]
20
+ ```
21
+
22
+ 3. Add the script and end the root `check` with it:
23
+
24
+ ```json
25
+ {
26
+ "scripts": {
27
+ "check": "bun run --workspaces check && bun run standard:check",
28
+ "standard:check": "ts-standard"
29
+ }
30
+ }
31
+ ```
32
+
33
+ In a single-package repo, append `&& bun run standard:check` to `check` after `bun run test`.
34
+
35
+ 4. If the repo differs from the standard anywhere, add a [`standard.config.ts`](configuration.md) at its root. Without one, every rule applies with the defaults.
36
+
37
+ `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.
@@ -0,0 +1,13 @@
1
+ # tsconfig rules
2
+
3
+ The base is `tsconfig.base.json` in a workspace repo and `tsconfig.json` otherwise.
4
+
5
+ | Rule | Checks |
6
+ | ------------------------------------ | ------------------------------------------------------------------------------------------------------ |
7
+ | `tsconfig/base` | The base exists and its `$schema` is `./node_modules/@effect/tsgo/schema.json`. |
8
+ | `tsconfig/effect-plugin` | The base has the `@effect/language-service` plugin entry, and no package tsconfig overrides `plugins`. |
9
+ | `tsconfig/no-emit` | The base sets `noEmit: true`. |
10
+ | `tsconfig/strict-in-base` | The base sets `strict` and `noUncheckedIndexedAccess`; package tsconfigs set no strict flags. |
11
+ | `tsconfig/extends-base` | Each `oxc` or `vite-plus` package has a `tsconfig.json` that extends the base. |
12
+ | `tsconfig/one-per-package` | No `tsconfig.*.json` beside a package's `tsconfig.json`. |
13
+ | `tsconfig/no-ignore-effect-warnings` | No tsconfig sets `ignoreEffectWarningsInTscExitCode: true`. |
@@ -0,0 +1,14 @@
1
+ # Workflow rules
2
+
3
+ | Rule | Checks |
4
+ | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
5
+ | `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. |
6
+ | `workflows/actions-pinned` | Every `uses:` outside the repo is pinned to a 40-character SHA with a `# v…` comment. |
7
+ | `workflows/reference-pins` | Warning. An action the reference also uses is at the reference's SHA. |
8
+ | `workflows/dependabot` | `.github/dependabot.yml` has a `github-actions` entry. |
9
+ | `workflows/hygiene` | Every workflow has top-level `permissions` and a `concurrency` group (reusable workflows excepted), and every job that runs steps has `timeout-minutes`. |
10
+ | `workflows/bun-from-package-manager` | No `setup-bun` step sets `bun-version`. |
11
+ | `workflows/scripts-only` | `run:` steps call bun only as `bun install --frozen-lockfile` or `bun run <script>`, never `bunx`, and never `--ignore-scripts`. |
12
+ | `workflows/release-check` | A tag-triggered workflow runs `bun run check`. |
13
+ | `workflows/release-version` | A tag-triggered workflow checks the tag against the package version (`${GITHUB_REF_NAME#v}`). |
14
+ | `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. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jfalava/ts-standard",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Checks a Bun repo against the TypeScript scripts and workflows standard: package.json scripts, pins, tsconfig, lint setup and GitHub workflows. Also ships the anti-slop oxlint plugins the standard uses.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -13,6 +13,7 @@
13
13
  "files": [
14
14
  "src",
15
15
  "reference",
16
+ "docs",
16
17
  "dist",
17
18
  "oxlint/LICENSE",
18
19
  "oxlint/UPSTREAM.md"