@hailstails/hone 0.1.0-pre.8 → 1.0.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/ADOPTING.md +2 -2
- package/CHANGELOG.md +12 -0
- package/MIGRATING.md +1 -1
- package/README.md +13 -11
- package/api/audit.js +0 -1
- package/api/testing.js +8 -9
- package/chunks/chunk-5X2BR42Y.js +117 -0
- package/chunks/{chunk-NRXSM7BY.js → chunk-LHVFZMXD.js} +10 -7
- package/chunks/{chunk-5LCLBXP7.js → chunk-NILRE23T.js} +1 -1
- package/chunks/{chunk-P3NLETF5.js → chunk-OKQHVZLO.js} +1 -1
- package/chunks/{chunk-POZL7G62.js → chunk-OVEQ37JQ.js} +40 -37
- package/chunks/chunk-RNXPEK2U.js +77 -0
- package/chunks/{chunk-XXLMIBLS.js → chunk-XE6RNNZB.js} +162 -143
- package/chunks/{chunk-WPRR2MPJ.js → chunk-YL6WR3QW.js} +5 -5
- package/core/check/tool-command.js +20 -20
- package/mechanisms/audit/CD-1/any-cast.js +0 -1
- package/mechanisms/audit/CD-10/throws-in-tests.js +0 -1
- package/mechanisms/audit/CD-14/class-syntax.js +0 -1
- package/mechanisms/audit/CD-15/loops.js +0 -1
- package/mechanisms/audit/CD-17/clock-sources.js +0 -1
- package/mechanisms/audit/CD-19/import-boundaries.js +2 -3
- package/mechanisms/audit/CD-2/cast-expressions.js +0 -1
- package/mechanisms/audit/CD-23/export-test-sibling.js +0 -1
- package/mechanisms/audit/CD-25/dependency-isolation.js +0 -1
- package/mechanisms/audit/CD-26/module-mocking.js +0 -1
- package/mechanisms/audit/CD-27/test-body-logic.js +0 -1
- package/mechanisms/audit/CD-3/compiler-overrides.js +2 -861
- package/mechanisms/audit/CD-43/boolean-signatures.js +0 -1
- package/mechanisms/audit/CD-44/parameter-mutation.js +0 -1
- package/mechanisms/audit/CD-47/hermetic-git-spawns.js +0 -1
- package/mechanisms/audit/CD-5/comments-directives.js +3 -4
- package/mechanisms/audit/CD-6/identifier-names.js +0 -1
- package/mechanisms/audit/CD-7/categorical-paths.js +0 -1
- package/mechanisms/audit/CD-7a/factory-return-types.js +0 -1
- package/mechanisms/audit/CD-8/switch-defaults.js +0 -1
- package/mechanisms/audit/runner/runner.js +31 -27
- package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +0 -1
- package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +0 -2
- package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +0 -1
- package/mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js +0 -1
- package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +0 -2
- package/mechanisms/eslint/CD-40/cd40/cd40.eslint-plugin.js +0 -1
- package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +0 -2
- package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +0 -2
- package/mechanisms/eslint/CD-44/cd44/cd44.eslint-plugin.js +0 -1
- package/mechanisms/eslint/CD-6/cd6/cd6.eslint-plugin.js +0 -1
- package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +0 -2
- package/mechanisms/eslint/runner/README.md +1 -1
- package/mechanisms/eslint/runner/runner.js +58 -2532
- package/package.json +6 -2
- package/THIRD-PARTY-NOTICES.md +0 -354
- package/chunks/chunk-MYX7GAVM.js +0 -73
- package/chunks/chunk-NCDYOPHG.js +0 -19832
- package/chunks/chunk-NZLE2WMY.js +0 -35
package/ADOPTING.md
CHANGED
|
@@ -14,7 +14,7 @@ It must print `v22.18.0` or a later 22.x, or `v24.0.0` or later. A rule set of y
|
|
|
14
14
|
|
|
15
15
|
## 2. Install the Hone package
|
|
16
16
|
|
|
17
|
-
Hone ships as one npm package tarball
|
|
17
|
+
Hone ships as one npm package tarball of built JavaScript, so it needs no TypeScript support from Node. It has three dependencies of its own, `zod`, `jsonc-parser` and `@eslint/plugin-kit`, each declared as a caret range starting at the version Hone is tested on, which the package manager installs from the registry. Your repository's lockfile, and any override you set, decides which release inside each range is installed, so you can take a patched release of one of them without waiting for a new Hone.
|
|
18
18
|
|
|
19
19
|
**The npm package is named `@hailstails/hone`.** The unscoped name `hone` on npm belongs to an unrelated package: never run `npm install hone`. The package `@hailstails/hone` installs one command, `hone`. Its tarball is named `hailstails-hone-<version>.tgz`, the file name `npm pack` gives a scoped package. Its first pre-release was released under the old name `honed`; [MIGRATING.md](MIGRATING.md#11-moving-from-honed-to-hailstailshone) says how to move from it.
|
|
20
20
|
|
|
@@ -34,7 +34,7 @@ pnpm add -D --save-exact @hailstails/hone@<version>
|
|
|
34
34
|
|
|
35
35
|
Pin the exact version. Commands, flags and files may change between pre-releases, and an install by tag can record a range in `package.json`, such as `^` and the version, which a later install without the lockfile, or an update, moves to a newer pre-release that nobody chose. With an exact pin, the version changes only when you change it (step 10). Check the name before you run it: `@hailstails/hone`, never the unscoped `hone`. With Yarn, add `@hailstails/hone@<version>` exactly with its own `add -D` command at the workspace root. `next` can trail the newest GitHub release for a while; [README.md](README.md#developing-hone) says how a version reaches npm.
|
|
36
36
|
|
|
37
|
-
The alternative is a tarball, copied into the repository so every teammate and CI runner installs the same
|
|
37
|
+
The alternative is a tarball, copied into the repository so every teammate and CI runner installs the same Hone without the registry. Its three dependencies still come from the registry, or the mirror your package manager uses, at releases inside the ranges the tarball's `package.json` declares, and the repository's lockfile records which. This page writes its location as `<hone-tarball>`: a path such as `vendor/hailstails-hone/hailstails-hone-<version>.tgz`, or an `https://` URL your team serves it from. Download the tarball attached to the latest [GitHub release](https://github.com/HailsTails/hone/releases), or build it from a pinned commit as below.
|
|
38
38
|
|
|
39
39
|
To build the tarball yourself, use Node.js 22.18 or later with [corepack](https://nodejs.org/api/corepack.html) available, which provides the pnpm version `package.json` pins, and pick the commit to pin, such as the latest on [`main`](https://github.com/HailsTails/hone/commits/main). Then run, with that commit's SHA in place of `<pinned-sha>`:
|
|
40
40
|
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Every release of Hone, newest first. `pnpm run release-pull-request` writes each new section from the commits merged to `main` since the previous release tag, whose subjects are the squash-merged pull request titles; README.md's Compatibility section says what each kind of release may change. The sections below were written by hand from the merged pull requests when the changelog started.
|
|
4
4
|
|
|
5
|
+
## 1.0.0
|
|
6
|
+
|
|
7
|
+
### Other changes
|
|
8
|
+
|
|
9
|
+
- size each release by plain semver so a stable release leaves the zero major (#120)
|
|
10
|
+
|
|
11
|
+
## 0.1.0-pre.9
|
|
12
|
+
|
|
13
|
+
### Fixes
|
|
14
|
+
|
|
15
|
+
- publish zod, jsonc-parser and @eslint/plugin-kit as caret-range dependencies instead of bundling them (#125)
|
|
16
|
+
|
|
5
17
|
## 0.1.0-pre.8
|
|
6
18
|
|
|
7
19
|
### Fixes
|
package/MIGRATING.md
CHANGED
|
@@ -223,7 +223,7 @@ To move:
|
|
|
223
223
|
3. **Repoint every command.** In scripts, CI and the pre-push hook, replace `node tools/discipline-core/core/check/check-command.ts --repo .` with `npm run --silent hone:check`, and `project-command.ts` with `npm run --silent hone:project`. Pass options after `--` with npm, as in `npm run --silent hone:check -- --base-revision origin/main`, and straight after the script name with pnpm, as in `pnpm run --silent hone:check --base-revision origin/main`. A hook or gate that reads the verdict line needs the warning in [ADOPTING.md](ADOPTING.md#5-run-the-check) step 5. Point agent instructions at `node_modules/@hailstails/hone/rules/`.
|
|
224
224
|
4. **Repoint your own pieces and tests.** Nothing outside the package's public entries can be imported now:
|
|
225
225
|
- A piece that imported types or `folderScope` from the copy, such as from `walker-piece.ts` or `source-scope.ts`, imports them from `@hailstails/hone/audit`.
|
|
226
|
-
- A piece that read JSON with comments through the copy's `jsonc-parse.ts` calls TypeScript's own parser on the syntax API that `prepare` hands it: `syntaxApi.parseConfigFileTextToJson(file, text)` returns the parsed value as `config`, and sets `error` when it cannot parse the text. Do not import `jsonc-parser`: it is
|
|
226
|
+
- A piece that read JSON with comments through the copy's `jsonc-parse.ts` calls TypeScript's own parser on the syntax API that `prepare` hands it: `syntaxApi.parseConfigFileTextToJson(file, text)` returns the parsed value as `config`, and sets `error` when it cannot parse the text. Do not import `jsonc-parser`: it is Hone's own dependency, not one the repository declares, so a strict package manager such as pnpm does not resolve it from a piece, and a piece imports only what [docs/extending.md](docs/extending.md#what-is-stable) lists.
|
|
227
227
|
- For a file it cannot parse, a piece returns `{ outcome: "failed", error: { kind: "file-unparseable", file, detail } }`. The check then stops with `load failure: runner-failed audit file-unparseable <file> <detail>` and exit `2`.
|
|
228
228
|
- Case tests use `clauseConformanceOf` from `@hailstails/hone/testing`, as [docs/extending.md](docs/extending.md#test-a-piece) shows.
|
|
229
229
|
- A test that called the copy's check or governance functions directly, such as `runCheck` or `applyGovernance`, has no entry to call: run the `hone check` command against a repository the test sets up, and assert on its report and exit code.
|
package/README.md
CHANGED
|
@@ -227,7 +227,7 @@ At the repository root; absent means no exceptions. Each entry names a selected
|
|
|
227
227
|
|
|
228
228
|
## Installing
|
|
229
229
|
|
|
230
|
-
Hone installs as one npm package, `@hailstails/hone`, installed from npm at an exact version, `@hailstails/hone@<version>` with `--save-exact`, downloaded as the tarball `hailstails-hone-<version>.tgz` attached to a GitHub release, or built by `pnpm run pack-package` into `artefacts/hailstails-hone-<version>.tgz`, the file name `npm pack` gives the scoped package, and added to the repository root as a development dependency; [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 has the steps. The package is plain JavaScript
|
|
230
|
+
Hone installs as one npm package, `@hailstails/hone`, installed from npm at an exact version, `@hailstails/hone@<version>` with `--save-exact`, downloaded as the tarball `hailstails-hone-<version>.tgz` attached to a GitHub release, or built by `pnpm run pack-package` into `artefacts/hailstails-hone-<version>.tgz`, the file name `npm pack` gives the scoped package, and added to the repository root as a development dependency; [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 has the steps. The package is plain JavaScript holding only Hone's own code. It declares `zod`, `jsonc-parser` and `@eslint/plugin-kit` as `dependencies`, each as a caret range starting at the version `pnpm-lock.yaml` locks, so the package manager installs them from the registry, and the repository's own audit tools see them as it does any other dependency. Which release inside each range is installed is decided by the repository's own lockfile and overrides, so a patched release can be taken without waiting for a new Hone. It declares the toolchain as `peerDependencies`, `typescript` required and the ESLint packages optional, and exposes one command, `hone`, whose subcommands `hone check` and `hone project` are described under Commands. It ships the rule data and pages, both mechanisms, the review methods and the why-chain contract, and no TypeScript source, only the declaration files of the public type entries below.
|
|
231
231
|
|
|
232
232
|
With the ESLint mechanism selected, a packaged install's projection imports each piece by package name, `@hailstails/hone/mechanisms/eslint/<DisciplineId>/...`, so the repository's ESLint must resolve the package from the repository root. Hone compares the committed projection `disciplines.eslint.mjs` byte for byte with what `hone project` would write now.
|
|
233
233
|
|
|
@@ -248,7 +248,7 @@ Each resolves with `moduleResolution` `"nodenext"` or `"bundler"`. `install-proo
|
|
|
248
248
|
- Windows, Linux, macOS or WSL. Hone keeps absolute paths in the platform's own form and repository paths in POSIX form, as git reports them.
|
|
249
249
|
- The package: Node `^22.18.0 || >=24` (its `engines.node`). It is plain JavaScript, so Node never strips types from it, and from 22.18.0 Node strips types from a rule set's `.ts` piece modules, within the limits [ADOPTING.md](ADOPTING.md#1-check-the-prerequisites) lists.
|
|
250
250
|
- git 2.24 or later. Older git rejects `--end-of-options`, so the changed-file query fails and forfeiture is reported unmeasured.
|
|
251
|
-
- Hone's own packages, `zod`, `jsonc-parser` and `@eslint/plugin-kit`,
|
|
251
|
+
- Hone's own packages, `zod`, `jsonc-parser` and `@eslint/plugin-kit`, declared in `dependencies` as caret ranges whose floor is the version `pnpm-lock.yaml` locks, which is the version Hone is tested on. A caret range keeps to one major version, and for a `0.x` package to one minor. The repository's package manager installs a release inside each range, and the packages it depends on, where Hone resolves it; the repository's lockfile, and any override it sets, decides which release. They are implementation details: nothing of theirs crosses into the repository's code or configuration. A repository that uses `zod` itself may share one copy with Hone when its version is inside Hone's range, as package managers do for compatible versions, and otherwise keeps its own copy beside Hone's.
|
|
252
252
|
- The repository's own toolchain, declared as `peerDependencies`: `typescript` `>=4.8.4 <7.0.0`, a required peer because every audit clause needs it, and for the ESLint mechanism the optional peers `eslint` `^9.28.0 || ^10.0.0`, `@typescript-eslint/parser` `^8.56.0` and `@typescript-eslint/eslint-plugin` `^8.56.0`. npm 7 and later install a missing required peer on their own, so declare `typescript` at the root at the version the repository uses. Each floor is the oldest release Hone is tested on: TypeScript 4.8 is the oldest whose syntax API the audit uses (`getModifiers`), ESLint 9.28.0 the first 9.x with every bulk-suppressions option a carve-out kept in `eslint-suppressions.json` relies on (`--pass-on-unpruned-suppressions` came last), and typescript-eslint 8.56.0 the first whose peer range accepts ESLint 10. TypeScript stops below 7 because TypeScript 7's compiler API is a different one. Yarn Plug'n'Play is not supported.
|
|
253
253
|
|
|
254
254
|
Hone loads the toolchain by Node's own resolution, upward from the install directory, which is the same resolution the pieces' plugin modules get when the team's ESLint loads the projection. Hone's query of the team's configuration, its governance run and the pieces therefore all use one copy, the repository's. Keep the toolchain resolvable from the repository root: declare it in the root `package.json` (in a pnpm workspace, `pnpm add -Dw`). A package may install a different ESLint for its own lint script; Hone's verdict still comes from the root's, its governance behaviour is the same on either supported line, and the pieces that wrap native rules wrap the root's copies there too. Hone's tests run the governance path and every piece's shared cases on four ESLint lines, 9.28.0 and 10.0.0 with typescript-eslint 8.56.0 and 9.39.5 and 10.11.0 with 8.71.2, and the audit pieces' shared cases on TypeScript 4.8.4 and 6.0.3; the in-process consumer fixtures run on ESLint 10.11.0, and `install-proof` runs real consumers on each floor.
|
|
@@ -266,8 +266,7 @@ Hone's version numbers follow semantic versioning under these rules:
|
|
|
266
266
|
- Renaming or removing a clause address, a config key in `disciplines.json` or `discipline-exceptions.json`, or a CLI flag, or changing what one means, is a major release. Adding one with a safe default is not.
|
|
267
267
|
- A change to what [the output contract](docs/output-contract.md) says a tool can parse is a major release: the command and option names, the exit codes and streams, the report's sections, outputs and verdict lines, the load failure kinds, and each line's leading fields up to its first value that may hold a space. What it marks not stable, such as the help text, the wording of `arguments-invalid` and `readFirst` lines and the repair text after a load failure's values, may change in a minor release, and a minor release may add a section, a kind of line or an option.
|
|
268
268
|
- A breaking change to a type in `@hailstails/hone/rule-set` is a major release. `@hailstails/hone/audit` is experimental: its types may change in a minor release until it is marked stable.
|
|
269
|
-
-
|
|
270
|
-
- A pre-release previews the release it is numbered towards and is published under the `next` dist-tag. A change of any size can land between two pre-releases of the same release, and the changelog lists it.
|
|
269
|
+
- A pre-release previews the release it is numbered towards and is published under the `next` dist-tag. A change no larger than the one a pre-release is numbered towards lands in that release's next pre-release; a larger one starts the line of the larger version it calls for. The changelog lists each change either way.
|
|
271
270
|
|
|
272
271
|
`disciplines.json` and `discipline-exceptions.json` follow the same rules. A new key with a safe default, where nothing changes for an adopter who does not set it, is not breaking and can arrive in a minor release. A new required key with no safe default is breaking, and so is a change that makes a file that loads today stop loading or mean something else; both wait for a major release.
|
|
273
272
|
|
|
@@ -306,11 +305,11 @@ This repository is self-contained: it holds its own configuration and its own lo
|
|
|
306
305
|
| `lint` | Biome with `lint.biome.json` |
|
|
307
306
|
| `test` | Vitest with `vitest.config.ts` |
|
|
308
307
|
| `check` | all three in that order |
|
|
309
|
-
| `build-package` | `node scripts/build-package.ts`:
|
|
308
|
+
| `build-package` | `node scripts/build-package.ts`: compiles Hone's own code with esbuild into `dist/`, leaving each declared peer and dependency to be imported by name, and adds the published `package.json`, which declares the dependencies at the ranges `package.json` declares, and the shipped documents and data. It fails if a dependency is not declared as a caret range of one release, if that range's floor is not the version the lock's root importer holds, or if the lock does not hold it, if an output imports anything but a `node:` builtin, a declared peer or a declared dependency, if an output carries an installed package's code, if a command or runner is not emitted at its own path with its own code, or if a shipped page links to a file the package does not ship. The tool's name, package name, command name, shipped rule-set name, reserved ESLint namespace, description, GitHub repository and the unrelated npm name to warn against live in `core/values/tool-identity.ts`, which the build, the install proof, the release text, the command's usage line and the ESLint runner all read. The reserved namespace is its own field, independent of the package name |
|
|
310
309
|
| `pack-package` | `node scripts/pack-package.ts`: builds `dist/` and packs it with `npm pack` into `artefacts/hailstails-hone-<version>.tgz`, named by the `version` in `package.json` |
|
|
311
310
|
| `package-determinism` | `node scripts/check-package-determinism.ts`: builds and packs twice into separate temporary roots and fails naming any file that differs, or when the two packed tarballs differ |
|
|
312
311
|
| `self-check` | `node scripts/self-check.ts check --repo .`: runs Hone's own check on this repository with `disciplines.json` and `discipline-exceptions.json`; pass `--base-revision <rev>` after the script name. See [Core's check on itself](#hones-check-on-itself) |
|
|
313
|
-
| `install-proof` | `node scripts/install-proof.ts`: packs the package once into a temporary tarball and installs it with pnpm into six CommonJS consumers in an OS temporary directory outside the working tree, each copied from its folder under `tests/test-fixtures/consumer-proof/`, which holds only what that consumer's action needs. Each consumer exists for one thing only an installed package shows. The audit consumer, on TypeScript 4.8.4, runs `check` through the installed bin and expects its finding. The ESLint 9.28.0 and 10.0.0 consumers run `project`, expect a projection importing the piece by package name, and expect its finding from `check`. The consumer without `eslint` expects `toolchain-unavailable`. These four run with type stripping off. The team consumer is the example [docs/extending.md](docs/extending.md) follows. On TypeScript 4.8.4 it type-checks a wrong team piece, rule set and ESLint piece settings with its own `tsc`, as described under Public type entries, and expects the three errors. On the development versions, TypeScript 6.0.3, ESLint 10.11.0 and typescript-eslint 8.71.2, it also type-checks its rule set under `nodenext` and `bundler` and a CommonJS file, then runs both commands with type stripping on: its `.ts` pieces load through the installed package and give one finding from each mechanism under the team's `acme/` prefix. Its root says `"type": "commonjs"`, the hard case, so its rule set carries its own `"type": "module"` `package.json`. Each consumer declares its toolchain at exact pins in its own `devDependencies`, as an adopter does: TypeScript 4.8.4 alone for the audit consumer, the consumer without `eslint` and the team consumer on 4.8.4; ESLint 9.28.0 or 10.0.0 with typescript-eslint 8.56.0 and TypeScript 4.8.4 for the two ESLint consumers; and the development versions for the team consumer. It declares the tarball beside them, pins the pnpm version this repository's `package.json` pins, and waits this repository's `minimumReleaseAge`. pnpm's store shares each toolchain package between consumers. The proof prints where pnpm put the installed package and expects the report to name its pages through the consumer's `node_modules/@hailstails/hone` instead, and it runs `check` through the package script with its options after `--`, as an adopter's pre-push hook does. A pass once a violation is removed, rule-set naming, plugin namespaces, settings overrides and per-package ESLint configs are proven by unit and in-process tests instead. The temporary directory is removed afterwards |
|
|
312
|
+
| `install-proof` | `node scripts/install-proof.ts`: packs the package once into a temporary tarball and installs it with pnpm into six CommonJS consumers in an OS temporary directory outside the working tree, each copied from its folder under `tests/test-fixtures/consumer-proof/`, which holds only what that consumer's action needs. Each consumer exists for one thing only an installed package shows. The audit consumer, on TypeScript 4.8.4, runs `check` through the installed bin and expects its finding. The ESLint 9.28.0 and 10.0.0 consumers run `project`, expect a projection importing the piece by package name, and expect its finding from `check`. The consumer without `eslint` expects `toolchain-unavailable`. These four run with type stripping off. The team consumer is the example [docs/extending.md](docs/extending.md) follows. On TypeScript 4.8.4 it type-checks a wrong team piece, rule set and ESLint piece settings with its own `tsc`, as described under Public type entries, and expects the three errors. On the development versions, TypeScript 6.0.3, ESLint 10.11.0 and typescript-eslint 8.71.2, it also type-checks its rule set under `nodenext` and `bundler` and a CommonJS file, then runs both commands with type stripping on: its `.ts` pieces load through the installed package and give one finding from each mechanism under the team's `acme/` prefix. Its root says `"type": "commonjs"`, the hard case, so its rule set carries its own `"type": "module"` `package.json`. Each consumer declares its toolchain at exact pins in its own `devDependencies`, as an adopter does: TypeScript 4.8.4 alone for the audit consumer, the consumer without `eslint` and the team consumer on 4.8.4; ESLint 9.28.0 or 10.0.0 with typescript-eslint 8.56.0 and TypeScript 4.8.4 for the two ESLint consumers; and the development versions for the team consumer. It declares the tarball beside them, pins the pnpm version this repository's `package.json` pins, and waits this repository's `minimumReleaseAge`. pnpm's store shares each toolchain package between consumers. The proof prints where pnpm put the installed package, checks that each of Hone's dependencies is installed beside it at a release inside its published range, and expects the report to name its pages through the consumer's `node_modules/@hailstails/hone` instead, and it runs `check` through the package script with its options after `--`, as an adopter's pre-push hook does. A pass once a violation is removed, rule-set naming, plugin namespaces, settings overrides and per-package ESLint configs are proven by unit and in-process tests instead. The temporary directory is removed afterwards |
|
|
314
313
|
| `pull-request-title` | `node scripts/pull-request-title-command.ts <title>`: passes a title shaped as a Conventional Commits subject, `type(scope)!: description`, and fails any other with the expected form. See [Versions and releases](#versions-and-releases) |
|
|
315
314
|
| `release-pull-request` | `node scripts/release-pull-request-command.ts [pre-release\|stable]`: writes the next release's section into `CHANGELOG.md` and its version into `package.json`, in the working tree only. See [Versions and releases](#versions-and-releases) |
|
|
316
315
|
|
|
@@ -326,13 +325,16 @@ Continuous integration runs `check`, `build-package`, `package-determinism` and
|
|
|
326
325
|
|
|
327
326
|
Pull requests are squash-merged, and the pull request's title becomes the commit's subject on `main`. The `pull-request-title` check requires that title to be a Conventional Commits subject: `type(scope)!: description`, where the scope is optional and lowercase, `!` marks a breaking change as [Compatibility](#compatibility) defines it, and the type is one of `feat`, `fix`, `perf`, `revert`, `docs`, `refactor`, `test`, `build`, `ci`, `chore` or `style`. Reverting behaviour that has been released is breaking, so its title is `revert!:`; `revert:` without `!` is for undoing a change that has not been released, and counts as a patch. A title that changes the ESLint projection says that adopters must run `hone project`, since the title becomes the changelog entry. `.github/dependabot.yml` leaves Dependabot's routine version updates off and gives its security pull requests a conventional title with the type `build` and a scope, such as `build(deps):`. It covers the GitHub Actions the workflows use and, through the `npm` ecosystem, which is how Dependabot names pnpm, the JavaScript dependencies in `pnpm-lock.yaml`. A security release published in the last three days can be held back by the minimum release age when pnpm resolves it.
|
|
328
327
|
|
|
329
|
-
To prepare a release, create a new branch at the tip of `main` and run `pnpm run release-pull-request` on it before anything is committed to it. It finds the highest release tag `v<version>` merged into `HEAD`, reads the full message of every commit after it, and works out the next version. It needs
|
|
328
|
+
To prepare a release, create a new branch at the tip of `main` and run `pnpm run release-pull-request` on it before anything is committed to it. It finds the highest release tag `v<version>` merged into `HEAD`, reads the full message of every commit after it, and works out the next version by semantic versioning alone. It sizes the release from every commit since the latest stable release tag, or, when no release is stable, since the earliest release tag, so a pre-release line is sized by all it holds and not only by what followed its last pre-release. It needs the commits since the tag it sizes from, which include those after the latest tag, to be the straight line of squash-merged commits that `main` holds, so it refuses, changing nothing and naming the commits, when any of them is a merge commit, since a merge brings in changes whose subjects it cannot size. It works out the version like this:
|
|
330
329
|
|
|
331
|
-
- A subject with `!`, or a message with a `BREAKING CHANGE:` or `BREAKING-CHANGE:` footer line, is a major change, `feat` a minor change, and every other subject a patch.
|
|
332
|
-
- On a
|
|
333
|
-
-
|
|
330
|
+
- A subject with `!`, or a message with a `BREAKING CHANGE:` or `BREAKING-CHANGE:` footer line, is a major change, `feat` a minor change, and every other subject a patch. The largest change decides the release.
|
|
331
|
+
- On a stable release, the change increments the version: a patch increments the patch number, a minor the minor number with the patch reset to 0, and a major the major number with both others reset to 0.
|
|
332
|
+
- On a pre-release, a change no larger than the one the pre-release is numbered towards moves to the next pre-release number; a larger one starts the larger version's first pre-release, numbered `-pre.1`.
|
|
333
|
+
- The release stays on the latest tag's channel, so after a stable release the next is stable unless asked otherwise. Pass `pre-release` to start a pre-release line from a stable one, numbered towards the version the change would give, and `stable` to finish a pre-release line as its stable version.
|
|
334
334
|
|
|
335
|
-
|
|
335
|
+
The first stable release is made the same way. The `0.1.0` pre-release line holds breaking changes, so on the branch for that release `pnpm run release-pull-request stable` finishes the line with major version 1, minor and patch 0, and every release after it follows the rules above.
|
|
336
|
+
|
|
337
|
+
It then writes a section for that version at the top of `CHANGELOG.md`, grouping the subjects under Breaking changes, Features, Fixes and Other changes, and sets `version` in `package.json`. It refuses, changing nothing, when no subject follows the latest tag, when a merge commit follows the latest tag or the tag it sizes from, when `package.json` is not at the tag's version, or when the changelog already has the new version. A subject that is not a Conventional Commits subject is named on standard error and counted as a patch under Other changes, or as a major under Breaking changes when its message has a breaking footer, so check its place before opening the pull request. If writing the second file fails, it restores the first. The script only edits those two files: it never commits, tags, pushes or publishes. Open the release pull request with the title `chore(release): <version>`. Merging it is the release: no tag is pushed by hand and nothing is run after the merge. `.github/CODEOWNERS` makes the owner, `@HailsTails`, the code owner of `package.json`, `CHANGELOG.md`, `.github/workflows/`, `.github/CODEOWNERS` itself, the `scripts/release-*` scripts, `scripts/published-manifest.ts`, which writes the published `package.json`, `core/values/tool-identity.ts`, which names the package and its repository, and `pnpm-workspace.yaml`, which holds the `minimumReleaseAge` the release job installs under, so a release pull request, or any change to how a release is made, needs her code-owner approval before it can merge. That also covers every change to `package.json`, dependency updates included, since the version a release is triggered by lives there.
|
|
336
338
|
|
|
337
339
|
`CHANGELOG.md` names versions, so it stays in the repository and out of the package; the shipped pages link to it on GitHub.
|
|
338
340
|
|
package/api/audit.js
CHANGED
package/api/testing.js
CHANGED
|
@@ -5,28 +5,26 @@ import {
|
|
|
5
5
|
loadRunner,
|
|
6
6
|
rejectedCall,
|
|
7
7
|
runnerInvalidOutput
|
|
8
|
-
} from "../chunks/chunk-
|
|
8
|
+
} from "../chunks/chunk-XE6RNNZB.js";
|
|
9
9
|
import {
|
|
10
10
|
caseVerdictSchema,
|
|
11
11
|
runnerResultSchema
|
|
12
|
-
} from "../chunks/chunk-
|
|
12
|
+
} from "../chunks/chunk-RNXPEK2U.js";
|
|
13
13
|
import {
|
|
14
14
|
readDisciplineFile,
|
|
15
15
|
readPieceFile
|
|
16
|
-
} from "../chunks/chunk-
|
|
16
|
+
} from "../chunks/chunk-OVEQ37JQ.js";
|
|
17
17
|
import {
|
|
18
18
|
createDefaultFileTextPort,
|
|
19
19
|
createDefaultModuleLoaderPort,
|
|
20
20
|
createDefaultPathPort,
|
|
21
21
|
moduleExtensionOf,
|
|
22
22
|
repoPathSchema
|
|
23
|
-
} from "../chunks/chunk-
|
|
23
|
+
} from "../chunks/chunk-LHVFZMXD.js";
|
|
24
24
|
import {
|
|
25
25
|
clauseAddressSchema,
|
|
26
|
-
external_exports,
|
|
27
26
|
mechanismIdSchema
|
|
28
|
-
} from "../chunks/chunk-
|
|
29
|
-
import "../chunks/chunk-NZLE2WMY.js";
|
|
27
|
+
} from "../chunks/chunk-5X2BR42Y.js";
|
|
30
28
|
|
|
31
29
|
// core/conformance/clause-under-test.ts
|
|
32
30
|
var setupFailed = (error) => ({ outcome: "failed", error });
|
|
@@ -95,8 +93,9 @@ var repoPathOf = (request) => {
|
|
|
95
93
|
};
|
|
96
94
|
|
|
97
95
|
// core/conformance/conformance.ts
|
|
96
|
+
import { z } from "zod";
|
|
98
97
|
var caseVerdictsResultSchema = runnerResultSchema({
|
|
99
|
-
value:
|
|
98
|
+
value: z.array(caseVerdictSchema).readonly()
|
|
100
99
|
});
|
|
101
100
|
var lineSet = (request) => [...new Set(request.lines)].toSorted((left, right) => left - right);
|
|
102
101
|
var verdictsNaming = (request) => request.verdicts.filter((verdict) => verdict.caseName === request.caseName);
|
|
@@ -128,7 +127,7 @@ var caseConformance = (request) => {
|
|
|
128
127
|
var conformanceOf = (request) => {
|
|
129
128
|
const parsed = caseVerdictsResultSchema.safeParse(request.returned);
|
|
130
129
|
if (!parsed.success) {
|
|
131
|
-
return runnerInvalidOutput({ detail:
|
|
130
|
+
return runnerInvalidOutput({ detail: z.prettifyError(parsed.error) });
|
|
132
131
|
}
|
|
133
132
|
if (parsed.data.outcome === "failed") {
|
|
134
133
|
return parsed.data;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// core/values/identifiers.ts
|
|
2
|
+
import { z as z2 } from "zod";
|
|
3
|
+
|
|
4
|
+
// core/values/branded-schema.ts
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
var brandedTextSchema = (request) => request.text.transform((text, context) => {
|
|
7
|
+
if (request.isBranded(text)) {
|
|
8
|
+
return text;
|
|
9
|
+
}
|
|
10
|
+
context.addIssue({ code: "custom", message: request.refusal });
|
|
11
|
+
return z.NEVER;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// core/values/identifiers.ts
|
|
15
|
+
var RULE_SET_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
16
|
+
var DISCIPLINE_ID_PATTERN = /^[A-Z]{2,4}-[0-9]+[a-z]?$/;
|
|
17
|
+
var CLAUSE_ID_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
18
|
+
var MECHANISM_ID_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
19
|
+
var NOT_AN_IDENTIFIER = "not an identifier of its kind";
|
|
20
|
+
var NOT_RUN = "not-run";
|
|
21
|
+
var NOT_ADOPTED = "not-adopted";
|
|
22
|
+
var RESERVED_CLAUSE_STATES = /* @__PURE__ */ new Map([
|
|
23
|
+
[NOT_RUN, "a clause adopted with its mechanism not run"],
|
|
24
|
+
[NOT_ADOPTED, "a clause a repository does not adopt"]
|
|
25
|
+
]);
|
|
26
|
+
var isRuleSetName = (text) => RULE_SET_NAME_PATTERN.test(text);
|
|
27
|
+
var isDisciplineId = (text) => DISCIPLINE_ID_PATTERN.test(text);
|
|
28
|
+
var isClauseId = (text) => CLAUSE_ID_PATTERN.test(text);
|
|
29
|
+
var isMechanismId = (text) => MECHANISM_ID_PATTERN.test(text) && !RESERVED_CLAUSE_STATES.has(text);
|
|
30
|
+
var ruleSetNameSchema = brandedTextSchema({
|
|
31
|
+
text: z2.string().regex(RULE_SET_NAME_PATTERN),
|
|
32
|
+
isBranded: isRuleSetName,
|
|
33
|
+
refusal: NOT_AN_IDENTIFIER
|
|
34
|
+
});
|
|
35
|
+
var disciplineIdSchema = brandedTextSchema({
|
|
36
|
+
text: z2.string().regex(DISCIPLINE_ID_PATTERN),
|
|
37
|
+
isBranded: isDisciplineId,
|
|
38
|
+
refusal: NOT_AN_IDENTIFIER
|
|
39
|
+
});
|
|
40
|
+
var clauseIdSchema = brandedTextSchema({
|
|
41
|
+
text: z2.string().regex(CLAUSE_ID_PATTERN),
|
|
42
|
+
isBranded: isClauseId,
|
|
43
|
+
refusal: NOT_AN_IDENTIFIER
|
|
44
|
+
});
|
|
45
|
+
var mechanismIdSchema = brandedTextSchema({
|
|
46
|
+
text: z2.string().regex(MECHANISM_ID_PATTERN).superRefine((text, context) => {
|
|
47
|
+
const reservedFor = RESERVED_CLAUSE_STATES.get(text);
|
|
48
|
+
if (reservedFor !== void 0) {
|
|
49
|
+
context.addIssue({ code: "custom", message: `"${text}" is reserved for ${reservedFor}, so it cannot name a mechanism` });
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
isBranded: isMechanismId,
|
|
53
|
+
refusal: NOT_AN_IDENTIFIER
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// core/values/clause-address.ts
|
|
57
|
+
import { z as z3 } from "zod";
|
|
58
|
+
|
|
59
|
+
// core/values/tool-identity.ts
|
|
60
|
+
var identified = (identity) => identity;
|
|
61
|
+
var TOOL_IDENTITY = identified({
|
|
62
|
+
name: "Hone",
|
|
63
|
+
packageName: "@hailstails/hone",
|
|
64
|
+
command: "hone",
|
|
65
|
+
ownRuleSet: "hone",
|
|
66
|
+
reservedEslintNamespace: "hone-core",
|
|
67
|
+
description: "Checks a repository against the disciplines it selects, applies its recorded exceptions and prints one verdict.",
|
|
68
|
+
repository: "https://github.com/HailsTails/hone",
|
|
69
|
+
unrelatedNpmPackage: "hone"
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// core/values/clause-address.ts
|
|
73
|
+
var TOOL_RULE_SET = TOOL_IDENTITY.ownRuleSet;
|
|
74
|
+
var CLAUSE_ADDRESS_TEXT = /^(?:(?<ruleSet>[^/#]+)\/)?(?<discipline>[^/#]+)#(?<clause>[^/#]+)$/;
|
|
75
|
+
var clauseAddressObjectSchema = z3.object({
|
|
76
|
+
ruleSet: z3.union([
|
|
77
|
+
z3.literal(TOOL_RULE_SET),
|
|
78
|
+
z3.object({
|
|
79
|
+
name: ruleSetNameSchema.refine((name) => name !== TOOL_RULE_SET)
|
|
80
|
+
})
|
|
81
|
+
]),
|
|
82
|
+
discipline: disciplineIdSchema,
|
|
83
|
+
clause: clauseIdSchema
|
|
84
|
+
});
|
|
85
|
+
var clauseAddressSchema = z3.string().transform((text, context) => {
|
|
86
|
+
const parts = CLAUSE_ADDRESS_TEXT.exec(text)?.groups;
|
|
87
|
+
if (parts === void 0) {
|
|
88
|
+
context.addIssue({
|
|
89
|
+
code: "custom",
|
|
90
|
+
message: "is not a clause address of the form [<ruleSet>/]<discipline>#<clause>"
|
|
91
|
+
});
|
|
92
|
+
return z3.NEVER;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
ruleSet: parts.ruleSet === void 0 || parts.ruleSet === TOOL_RULE_SET ? TOOL_RULE_SET : { name: parts.ruleSet },
|
|
96
|
+
discipline: parts.discipline,
|
|
97
|
+
clause: parts.clause
|
|
98
|
+
};
|
|
99
|
+
}).pipe(clauseAddressObjectSchema);
|
|
100
|
+
var clauseAddressText = (request) => request.address.ruleSet === TOOL_RULE_SET ? `${request.address.discipline}#${request.address.clause}` : `${request.address.ruleSet.name}/${request.address.discipline}#${request.address.clause}`;
|
|
101
|
+
var sameClauseAddress = (request) => clauseAddressText({ address: request.left }) === clauseAddressText({ address: request.right }) ? "same" : "different";
|
|
102
|
+
|
|
103
|
+
export {
|
|
104
|
+
brandedTextSchema,
|
|
105
|
+
NOT_RUN,
|
|
106
|
+
NOT_ADOPTED,
|
|
107
|
+
ruleSetNameSchema,
|
|
108
|
+
disciplineIdSchema,
|
|
109
|
+
clauseIdSchema,
|
|
110
|
+
mechanismIdSchema,
|
|
111
|
+
TOOL_IDENTITY,
|
|
112
|
+
TOOL_RULE_SET,
|
|
113
|
+
clauseAddressObjectSchema,
|
|
114
|
+
clauseAddressSchema,
|
|
115
|
+
clauseAddressText,
|
|
116
|
+
sameClauseAddress
|
|
117
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
brandedTextSchema
|
|
3
|
-
|
|
4
|
-
} from "./chunk-NCDYOPHG.js";
|
|
2
|
+
brandedTextSchema
|
|
3
|
+
} from "./chunk-5X2BR42Y.js";
|
|
5
4
|
|
|
6
5
|
// core/platform-ports/file-system-port.ts
|
|
7
6
|
import { accessSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -100,10 +99,11 @@ import platformPath, { posix, win32 } from "node:path";
|
|
|
100
99
|
import { fileURLToPath } from "node:url";
|
|
101
100
|
|
|
102
101
|
// core/values/absolute-path.ts
|
|
102
|
+
import { z } from "zod";
|
|
103
103
|
var POSIX_ROOT_DRIVE_ROOT_OR_SHARE_ROOT = /^(?:\/|[A-Za-z]:[\\/]|\\\\[^\\/]+[\\/][^\\/]+[\\/])/;
|
|
104
104
|
var isAbsolutePath = (text) => POSIX_ROOT_DRIVE_ROOT_OR_SHARE_ROOT.test(text);
|
|
105
105
|
var absolutePathSchema = brandedTextSchema({
|
|
106
|
-
text:
|
|
106
|
+
text: z.string().regex(POSIX_ROOT_DRIVE_ROOT_OR_SHARE_ROOT),
|
|
107
107
|
isBranded: isAbsolutePath,
|
|
108
108
|
refusal: "not an absolute path"
|
|
109
109
|
});
|
|
@@ -270,13 +270,14 @@ var MODULE_EXTENSIONS = [SOURCE_MODULE_EXTENSION, BUILT_MODULE_EXTENSION];
|
|
|
270
270
|
var moduleFileForm = (request) => MODULE_EXTENSIONS.some((extension) => request.text.endsWith(extension)) ? "module-file" : "not-module-file";
|
|
271
271
|
|
|
272
272
|
// core/values/repo-path.ts
|
|
273
|
+
import { z as z2 } from "zod";
|
|
273
274
|
var UNWALKABLE_SEGMENTS = ["", ".", ".."];
|
|
274
275
|
var LEADING_DRIVE_LETTER = /^[A-Za-z]:/;
|
|
275
276
|
var LINE_BREAK_OR_NUL = /[\n\r\0]/;
|
|
276
277
|
var NOT_A_REPO_PATH = "not a repo-relative path";
|
|
277
278
|
var isRepoPathText = (request) => !request.text.startsWith("/") && !LEADING_DRIVE_LETTER.test(request.text) && !request.text.includes("\\") && !LINE_BREAK_OR_NUL.test(request.text) && request.text.split("/").every((segment) => !UNWALKABLE_SEGMENTS.includes(segment)) ? "repo-path" : "not-repo-path";
|
|
278
279
|
var isRepoPath = (text) => isRepoPathText({ text }) === "repo-path";
|
|
279
|
-
var repoPathTextSchema =
|
|
280
|
+
var repoPathTextSchema = z2.string().superRefine((text, context) => {
|
|
280
281
|
if (isRepoPathText({ text }) === "not-repo-path") {
|
|
281
282
|
context.addIssue({ code: "custom", message: NOT_A_REPO_PATH });
|
|
282
283
|
}
|
|
@@ -285,11 +286,12 @@ var brandedRepoPathSchema = (request) => brandedTextSchema({ text: request.text,
|
|
|
285
286
|
var repoPathSchema = brandedRepoPathSchema({ text: repoPathTextSchema });
|
|
286
287
|
|
|
287
288
|
// core/mechanism-port/toolchain-requirement.ts
|
|
289
|
+
import { z as z3 } from "zod";
|
|
288
290
|
var RELEASE_PATTERN = /^(\d+)\.(\d+)\.(\d+)$/;
|
|
289
291
|
var NOT_INSTALLED = "not installed";
|
|
290
292
|
var MODULE_NOT_FOUND = "ERR_MODULE_NOT_FOUND";
|
|
291
293
|
var BACKSLASH = /\\/g;
|
|
292
|
-
var moduleErrorSchema =
|
|
294
|
+
var moduleErrorSchema = z3.object({ code: z3.string(), message: z3.string() });
|
|
293
295
|
var releaseParts = (request) => {
|
|
294
296
|
const match = RELEASE_PATTERN.exec(request.version);
|
|
295
297
|
return match === null ? void 0 : [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
@@ -388,10 +390,11 @@ var loadedPeer = (request) => Promise.resolve().then(() => request.location.loca
|
|
|
388
390
|
);
|
|
389
391
|
|
|
390
392
|
// core/values/snippet.ts
|
|
393
|
+
import { z as z4 } from "zod";
|
|
391
394
|
var SNIPPET_LIMIT = 200;
|
|
392
395
|
var CUT_MARK = "\u2026";
|
|
393
396
|
var cutToLimit = (request) => `${request.characters.slice(0, SNIPPET_LIMIT).join("")}${CUT_MARK}`;
|
|
394
|
-
var snippetSchema =
|
|
397
|
+
var snippetSchema = z4.string().transform((text) => {
|
|
395
398
|
const characters = Array.from(text);
|
|
396
399
|
return characters.length > SNIPPET_LIMIT ? cutToLimit({ characters }) : text;
|
|
397
400
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createDefaultPathPort,
|
|
3
3
|
installRootAboveEntry
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LHVFZMXD.js";
|
|
5
5
|
|
|
6
6
|
// core/mechanism-port/toolchain-bound-runner.ts
|
|
7
7
|
var builtOnce = (request) => request.toolchain.then((loaded) => loaded.outcome === "failed" ? loaded : { outcome: "ok", value: request.runnerOf(loaded.value) });
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
repoPathSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LHVFZMXD.js";
|
|
4
4
|
import {
|
|
5
5
|
clauseIdSchema,
|
|
6
6
|
disciplineIdSchema,
|
|
7
|
-
external_exports,
|
|
8
7
|
mechanismIdSchema
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5X2BR42Y.js";
|
|
10
9
|
|
|
11
10
|
// core/values/parsed-json.ts
|
|
12
11
|
var parsedJson = (request) => {
|
|
@@ -21,6 +20,9 @@ var parsedJson = (request) => {
|
|
|
21
20
|
}
|
|
22
21
|
};
|
|
23
22
|
|
|
23
|
+
// core/rule-set-reader/rule-set-reader.ts
|
|
24
|
+
import { z } from "zod";
|
|
25
|
+
|
|
24
26
|
// core/values/json-kind.ts
|
|
25
27
|
var JSON_KIND_NAMES = {
|
|
26
28
|
string: "a string",
|
|
@@ -78,11 +80,11 @@ var readVersionOneJson = (request) => {
|
|
|
78
80
|
};
|
|
79
81
|
var entryCount = (entries) => entries.length > 0 ? "some" : "empty";
|
|
80
82
|
var textDistinctness = (texts) => new Set(texts).size === texts.length ? "distinct" : "repeated";
|
|
81
|
-
var sourceCaseSchema =
|
|
82
|
-
name:
|
|
83
|
+
var sourceCaseSchema = z.object({
|
|
84
|
+
name: z.string(),
|
|
83
85
|
fileName: repoPathSchema,
|
|
84
|
-
source:
|
|
85
|
-
expectedLines:
|
|
86
|
+
source: z.string(),
|
|
87
|
+
expectedLines: z.array(z.number())
|
|
86
88
|
});
|
|
87
89
|
var flagCaseSchema = sourceCaseSchema.refine(
|
|
88
90
|
(sourceCase) => entryCount(sourceCase.expectedLines) === "some",
|
|
@@ -92,40 +94,40 @@ var allowCaseSchema = sourceCaseSchema.refine(
|
|
|
92
94
|
(sourceCase) => entryCount(sourceCase.expectedLines) === "empty",
|
|
93
95
|
{ error: "an allow case names expected lines" }
|
|
94
96
|
);
|
|
95
|
-
var anchorKindSchema =
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
var anchorKindSchema = z.discriminatedUnion("kind", [
|
|
98
|
+
z.object({ kind: z.literal("keyword"), keyword: z.string() }),
|
|
99
|
+
z.object({ kind: z.literal("file") })
|
|
98
100
|
]);
|
|
99
|
-
var clauseDefinitionSchema =
|
|
100
|
-
|
|
101
|
-
kind:
|
|
101
|
+
var clauseDefinitionSchema = z.discriminatedUnion("kind", [
|
|
102
|
+
z.object({
|
|
103
|
+
kind: z.literal("mechanical"),
|
|
102
104
|
id: clauseIdSchema,
|
|
103
|
-
summary:
|
|
104
|
-
mechanisms:
|
|
105
|
+
summary: z.string(),
|
|
106
|
+
mechanisms: z.array(mechanismIdSchema).refine((entries) => entryCount(entries) === "some", { error: "a mechanical clause names no mechanism" }),
|
|
105
107
|
anchor: anchorKindSchema,
|
|
106
|
-
exceptions:
|
|
107
|
-
cases:
|
|
108
|
-
flag:
|
|
109
|
-
allow:
|
|
108
|
+
exceptions: z.enum(["allowed", "refused"]).default("allowed"),
|
|
109
|
+
cases: z.object({
|
|
110
|
+
flag: z.array(flagCaseSchema).refine((entries) => entryCount(entries) === "some", { error: "a mechanical clause has no flag case" }),
|
|
111
|
+
allow: z.array(allowCaseSchema).refine((entries) => entryCount(entries) === "some", { error: "a mechanical clause has no allow case" })
|
|
110
112
|
})
|
|
111
113
|
}),
|
|
112
|
-
|
|
113
|
-
kind:
|
|
114
|
+
z.object({
|
|
115
|
+
kind: z.literal("judgement"),
|
|
114
116
|
id: clauseIdSchema,
|
|
115
|
-
summary:
|
|
116
|
-
enforcedBy:
|
|
117
|
+
summary: z.string(),
|
|
118
|
+
enforcedBy: z.literal("review")
|
|
117
119
|
})
|
|
118
120
|
]);
|
|
119
|
-
var disciplineFileSchema =
|
|
120
|
-
version:
|
|
121
|
+
var disciplineFileSchema = z.object({
|
|
122
|
+
version: z.literal(SUPPORTED_VERSION),
|
|
121
123
|
id: disciplineIdSchema,
|
|
122
|
-
clauses:
|
|
124
|
+
clauses: z.array(clauseDefinitionSchema).refine((clauses) => textDistinctness(clauses.map((clause) => clause.id)) === "distinct", {
|
|
123
125
|
error: "two clauses share an id"
|
|
124
126
|
})
|
|
125
127
|
});
|
|
126
|
-
var clauseSettingDeclarationSchema =
|
|
127
|
-
default:
|
|
128
|
-
choices:
|
|
128
|
+
var clauseSettingDeclarationSchema = z.strictObject({
|
|
129
|
+
default: z.json(),
|
|
130
|
+
choices: z.array(z.json()).min(1).optional()
|
|
129
131
|
}).superRefine((declaration, context) => {
|
|
130
132
|
if (declaration.choices === void 0) return;
|
|
131
133
|
const defaultKind = jsonKindOf({ value: declaration.default });
|
|
@@ -136,15 +138,15 @@ var clauseSettingDeclarationSchema = external_exports.strictObject({
|
|
|
136
138
|
context.addIssue({ code: "custom", path: ["default"], message: "the default must be one of the choices" });
|
|
137
139
|
}
|
|
138
140
|
});
|
|
139
|
-
var pieceFileSchema =
|
|
140
|
-
version:
|
|
141
|
+
var pieceFileSchema = z.object({
|
|
142
|
+
version: z.literal(SUPPORTED_VERSION),
|
|
141
143
|
discipline: disciplineIdSchema,
|
|
142
144
|
mechanism: mechanismIdSchema,
|
|
143
|
-
clauses:
|
|
144
|
-
|
|
145
|
+
clauses: z.array(
|
|
146
|
+
z.object({
|
|
145
147
|
clause: clauseIdSchema,
|
|
146
|
-
settings:
|
|
147
|
-
clauseSettings:
|
|
148
|
+
settings: z.unknown(),
|
|
149
|
+
clauseSettings: z.record(z.string().min(1), clauseSettingDeclarationSchema).default({})
|
|
148
150
|
})
|
|
149
151
|
).refine((entries) => textDistinctness(entries.map((entry) => entry.clause)) === "distinct", {
|
|
150
152
|
error: "two entries name the same clause"
|
|
@@ -152,7 +154,7 @@ var pieceFileSchema = external_exports.object({
|
|
|
152
154
|
});
|
|
153
155
|
var isContentRefusal = (issue) => issue.code === "custom";
|
|
154
156
|
var schemaRefusal = (request) => {
|
|
155
|
-
const detail =
|
|
157
|
+
const detail = z.prettifyError(request.error);
|
|
156
158
|
return request.error.issues.every(isContentRefusal) ? { kind: "rule-set-invalid", path: request.path, detail } : { kind: "file-malformed", path: request.path, detail };
|
|
157
159
|
};
|
|
158
160
|
var ruleSetInvalid = (request) => ({
|
|
@@ -229,7 +231,8 @@ var readPieceFile = (request) => {
|
|
|
229
231
|
};
|
|
230
232
|
|
|
231
233
|
// core/values/eslint-config-lookup.ts
|
|
232
|
-
|
|
234
|
+
import { z as z2 } from "zod";
|
|
235
|
+
var eslintConfigLookupSchema = z2.enum(["nearest-to-file", "repository-root"]);
|
|
233
236
|
|
|
234
237
|
export {
|
|
235
238
|
JSON_KIND_NAMES,
|