@hailstails/hone 0.1.0-pre.6 → 0.1.0-pre.7
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 +22 -8
- package/api/audit.d.ts +3 -0
- package/api/audit.js +10 -0
- package/api/rule-set.js +0 -0
- package/api/testing.d.ts +5 -0
- package/api/testing.js +211 -0
- package/chunks/chunk-3LCKBX5T.js +2134 -0
- package/chunks/{chunk-LOYT2AGY.js → chunk-MYX7GAVM.js} +2 -1
- package/chunks/{chunk-MVK5KFJI.js → chunk-NRXSM7BY.js} +1 -0
- package/chunks/{chunk-XB4PCY3Q.js → chunk-P3NLETF5.js} +1 -1
- package/chunks/{chunk-ET5EBSJX.js → chunk-POZL7G62.js} +1 -1
- package/core/check/tool-command.js +34 -2095
- package/core/conformance/conformance-testing-types.d.ts +28 -0
- package/core/conformance/conformance-types.d.ts +7 -0
- package/docs/extending.md +18 -8
- package/mechanisms/audit/runner/runner.js +3 -3
- package/mechanisms/eslint/runner/runner.js +3 -3
- package/package.json +7 -3
- package/api/audit.mjs +0 -1
- package/api/rule-set.mjs +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RunnerClause } from "../mechanism-port/runner-module-types.js";
|
|
2
|
+
import type { RepoPath } from "../values/repo-path-types.js";
|
|
3
|
+
import type { Result } from "../values/result.js";
|
|
4
|
+
import type { ConformanceFailure } from "./conformance-types.js";
|
|
5
|
+
export type { ConformanceFailure } from "./conformance-types.js";
|
|
6
|
+
export type ClauseRequest = {
|
|
7
|
+
readonly ruleSetRoot: string;
|
|
8
|
+
readonly clause: string;
|
|
9
|
+
};
|
|
10
|
+
export type ConformanceSetupFailureKind = "address-invalid" | "file-invalid" | "rule-set-unloadable" | "clause-not-mechanical" | "runner-unloadable" | "runner-refused";
|
|
11
|
+
export type ConformanceSetupFailure = {
|
|
12
|
+
readonly kind: ConformanceSetupFailureKind;
|
|
13
|
+
readonly detail: string;
|
|
14
|
+
};
|
|
15
|
+
export type CaseUnderTest = {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly file: RepoPath;
|
|
18
|
+
readonly source: string;
|
|
19
|
+
};
|
|
20
|
+
export type ClauseUnderTest = {
|
|
21
|
+
readonly clause: RunnerClause;
|
|
22
|
+
readonly cases: readonly CaseUnderTest[];
|
|
23
|
+
};
|
|
24
|
+
export type ClauseConformanceOf = (request: ClauseRequest) => Promise<Result<readonly ConformanceFailure[], ConformanceSetupFailure>>;
|
|
25
|
+
export type ClauseUnderTestOf = (request: ClauseRequest) => Result<ClauseUnderTest, ConformanceSetupFailure>;
|
|
26
|
+
export type RepoPathOf = (request: {
|
|
27
|
+
readonly file: string;
|
|
28
|
+
}) => Result<RepoPath, ConformanceSetupFailure>;
|
package/docs/extending.md
CHANGED
|
@@ -93,7 +93,7 @@ verdict: fail
|
|
|
93
93
|
- `id` matches the folder name. IDs are two to four capital letters, a dash and a number, with an optional lower-case letter after it.
|
|
94
94
|
- Each clause lists the mechanisms that can check it. Selecting one clause adopts the whole discipline, so its other mechanical clauses must be selected too.
|
|
95
95
|
- `anchor` is `{ "kind": "keyword", "keyword": "..." }` or `{ "kind": "file" }`.
|
|
96
|
-
- `cases` say what the clause must flag and what it must leave alone. They are the clause's contract. `hone check` does not run them against a team's pieces
|
|
96
|
+
- `cases` say what the clause must flag and what it must leave alone. They are the clause's contract. `hone check` does not run them against a team's pieces; the team runs them in its own tests: see [Test a piece](#test-a-piece).
|
|
97
97
|
- A clause with `"kind": "judgement"`, a `summary` and `"enforcedBy": "review"` is applied in review and cannot be selected.
|
|
98
98
|
- `"exceptions": "refused"` on a clause stops any exception record from exempting it.
|
|
99
99
|
|
|
@@ -266,7 +266,7 @@ Hone loads piece modules with Node, which strips the types from a `.ts` file as
|
|
|
266
266
|
|
|
267
267
|
## Type-check the rule set
|
|
268
268
|
|
|
269
|
-
`@hailstails/hone/rule-set`
|
|
269
|
+
`@hailstails/hone/rule-set` holds types only. `@hailstails/hone/audit` holds the walker piece types and one value, `folderScope`. Import types with `import type`. A `tsconfig` for the rule set that matches how Node runs it, `tools/disciplines/acme/tsconfig.pieces.json`:
|
|
270
270
|
|
|
271
271
|
```json
|
|
272
272
|
{
|
|
@@ -306,7 +306,17 @@ A wrong field then fails the type check, for example `Type 'number' is not assig
|
|
|
306
306
|
|
|
307
307
|
Test an ESLint rule with ESLint's own `RuleTester`, importing the rule the plugin exports, such as `noConsoleCalls`, and giving it the clause's `flag` cases as `invalid` and its `allow` cases as `valid`. Run on its own with `node`, `RuleTester` prints nothing when the cases hold and throws on the first that does not; under a test runner that defines `describe` and `it`, it reports each case as a test.
|
|
308
308
|
|
|
309
|
-
Test an audit piece
|
|
309
|
+
Test an audit piece with `@hailstails/hone/testing`. `clauseConformanceOf` loads the installed audit runner, binds the clause from the rule set as `hone check` binds it, and runs every `flag` and `allow` case through the piece:
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
import { clauseConformanceOf } from "@hailstails/hone/testing";
|
|
313
|
+
|
|
314
|
+
const conformance = await clauseConformanceOf({ ruleSetRoot: "tools/disciplines/acme", clause: "acme/ACME-2#scratch-files" });
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
A relative `ruleSetRoot` is read from the working directory. `{ outcome: "ok", value: [] }` means the piece met every case. Each entry in a longer list names a case, the lines it expects and the lines the piece flagged. `{ outcome: "failed", error: { kind, detail } }` means the cases could not run, for example `rule-set-unloadable` for a clause the audit mechanism may not check.
|
|
318
|
+
|
|
319
|
+
Checks of your own call the piece directly. `clauseUnderTestOf` returns the same bound clause and each case's `name`, `file` and `source`, ready for `check.prepare` and `prepareFile`; `repoPathOf` makes the `RepoPath` for any other file, such as one whose `readText` fails with `file-unreadable`. `folderScope` from `@hailstails/hone/audit` tells a piece whether a file sits in a generated folder. Hone does not run these tests; the team runs them with its own test runner.
|
|
310
320
|
|
|
311
321
|
## Exceptions
|
|
312
322
|
|
|
@@ -325,22 +335,22 @@ Without that setting the entry also needs a `whyChain`, and without one it is re
|
|
|
325
335
|
|
|
326
336
|
## What is stable
|
|
327
337
|
|
|
328
|
-
|
|
338
|
+
Two requirements are decided and not yet built. Each will make some rule sets that pass today fail:
|
|
329
339
|
|
|
330
|
-
- **Cases are enforced.** `hone check` will run each selected team clause's `cases` against its piece, and fail the run as `nonconforming` when the piece misses a `flag` case or flags an `allow` case.
|
|
331
340
|
- **A rule page is required.** A selected team discipline without `rules/<ID>/README.md` will fail to load.
|
|
332
|
-
- **Pieces keep to import boundaries.** A team piece will be refused if it imports from anywhere but its own piece folder, its discipline's `rules/<ID>` folder, `@hailstails/hone/rule-set`, `@hailstails/hone/audit` and its mechanism's toolchain package (`eslint` or `typescript`), with values only from its own piece folder
|
|
341
|
+
- **Pieces keep to import boundaries.** A team piece will be refused if it imports from anywhere but its own piece folder, its discipline's `rules/<ID>` folder, `@hailstails/hone/rule-set`, `@hailstails/hone/audit` and its mechanism's toolchain package (`eslint` or `typescript`), with values only from its own piece folder and `folderScope` from `@hailstails/hone/audit`. The rule is about a piece's run-time code: a piece's own tests may also import `@hailstails/hone/testing`.
|
|
333
342
|
|
|
334
|
-
To be ready now:
|
|
343
|
+
To be ready now: write each discipline's `README.md`, and import nothing from Hone in a piece but types from `@hailstails/hone/rule-set` and `@hailstails/hone/audit` and `folderScope`.
|
|
335
344
|
|
|
336
345
|
| Part | Status |
|
|
337
346
|
| --- | --- |
|
|
338
347
|
| `ruleSets`, the address `[<ruleSet>/]<ID>#<clause>`, `hone` reserved | Stable |
|
|
339
348
|
| The folder layout `rules/<ID>/` and `mechanisms/<mechanism>/<ID>/` | Stable, with `rules/<ID>/README.md` becoming required |
|
|
340
|
-
| `discipline.json` and `piece.json` version 1, and the ESLint piece `settings` with the namespace rule | Stable file formats
|
|
349
|
+
| `discipline.json` and `piece.json` version 1, and the ESLint piece `settings` with the namespace rule | Stable file formats |
|
|
341
350
|
| `@hailstails/hone/rule-set` | Stable |
|
|
342
351
|
| Exception records for team clauses | Stable |
|
|
343
352
|
| `@hailstails/hone/audit` and the walker piece contract | Experimental: may change in a minor release |
|
|
353
|
+
| `@hailstails/hone/testing` | Experimental: may change in a minor release |
|
|
344
354
|
| A rule set named by a package name, such as `"acme": "@acme/disciplines"` | Not supported: name its repository path instead, as under [TypeScript pieces under Node](#typescript-pieces-under-node) |
|
|
345
355
|
| A new mechanism from outside Hone | Not supported |
|
|
346
356
|
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
hitSchema,
|
|
8
8
|
runnerResultSchema
|
|
9
|
-
} from "../../../chunks/chunk-
|
|
9
|
+
} from "../../../chunks/chunk-MYX7GAVM.js";
|
|
10
10
|
import {
|
|
11
11
|
createDefaultPackageLocationPort,
|
|
12
12
|
installRootOfRunnerEntry,
|
|
13
13
|
toolchainBoundStandaloneRunner
|
|
14
|
-
} from "../../../chunks/chunk-
|
|
14
|
+
} from "../../../chunks/chunk-P3NLETF5.js";
|
|
15
15
|
import {
|
|
16
16
|
gatheredOutcomes
|
|
17
17
|
} from "../../../chunks/chunk-LDQUT742.js";
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
loadedPeer,
|
|
25
25
|
moduleExtensionOf,
|
|
26
26
|
moduleFileForm
|
|
27
|
-
} from "../../../chunks/chunk-
|
|
27
|
+
} from "../../../chunks/chunk-NRXSM7BY.js";
|
|
28
28
|
import {
|
|
29
29
|
external_exports,
|
|
30
30
|
sameClauseAddress
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
eslintConfigLookupSchema,
|
|
3
3
|
parsedJson
|
|
4
|
-
} from "../../../chunks/chunk-
|
|
4
|
+
} from "../../../chunks/chunk-POZL7G62.js";
|
|
5
5
|
import {
|
|
6
6
|
createDefaultPackageLocationPort,
|
|
7
7
|
installRootOfRunnerEntry,
|
|
8
8
|
toolchainBoundEmbeddedRunner
|
|
9
|
-
} from "../../../chunks/chunk-
|
|
9
|
+
} from "../../../chunks/chunk-P3NLETF5.js";
|
|
10
10
|
import {
|
|
11
11
|
gatheredOutcomes,
|
|
12
12
|
listedOutcome
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
moduleFileForm,
|
|
29
29
|
repoPathSchema,
|
|
30
30
|
versionSupport
|
|
31
|
-
} from "../../../chunks/chunk-
|
|
31
|
+
} from "../../../chunks/chunk-NRXSM7BY.js";
|
|
32
32
|
import {
|
|
33
33
|
TOOL_IDENTITY,
|
|
34
34
|
clauseAddressText,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hailstails/hone",
|
|
3
|
-
"version": "0.1.0-pre.
|
|
3
|
+
"version": "0.1.0-pre.7",
|
|
4
4
|
"description": "Checks a repository against the disciplines it selects, applies its recorded exceptions and prints one verdict.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"disciplines",
|
|
@@ -30,11 +30,15 @@
|
|
|
30
30
|
"./package.json": "./package.json",
|
|
31
31
|
"./audit": {
|
|
32
32
|
"types": "./api/audit.d.ts",
|
|
33
|
-
"default": "./api/audit.
|
|
33
|
+
"default": "./api/audit.js"
|
|
34
34
|
},
|
|
35
35
|
"./rule-set": {
|
|
36
36
|
"types": "./api/rule-set.d.ts",
|
|
37
|
-
"default": "./api/rule-set.
|
|
37
|
+
"default": "./api/rule-set.js"
|
|
38
|
+
},
|
|
39
|
+
"./testing": {
|
|
40
|
+
"types": "./api/testing.d.ts",
|
|
41
|
+
"default": "./api/testing.js"
|
|
38
42
|
},
|
|
39
43
|
"./mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js": "./mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js",
|
|
40
44
|
"./mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js": "./mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js",
|
package/api/audit.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/api/rule-set.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|