@hailstails/hone 0.1.0-pre.5 → 0.1.0-pre.6
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 +151 -42
- package/MIGRATING.md +55 -4
- package/README.md +98 -35
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/chunks/chunk-5LCLBXP7.js +76 -0
- package/chunks/{chunk-IIMK5BCL.js → chunk-ET5EBSJX.js} +15 -13
- package/chunks/{chunk-7PVPPH4C.js → chunk-LDQUT742.js} +3 -1
- package/chunks/{chunk-VUG3DJHN.js → chunk-LOYT2AGY.js} +8 -9
- package/chunks/{chunk-HVABJ7T4.js → chunk-MVK5KFJI.js} +72 -12
- package/chunks/{chunk-SWPCKTJV.js → chunk-NCDYOPHG.js} +7340 -2124
- package/chunks/{chunk-7OVV6NEU.js → chunk-WPRR2MPJ.js} +1 -1
- package/chunks/{chunk-YBWVUDIG.js → chunk-XB4PCY3Q.js} +1 -1
- package/core/check/tool-command.js +938 -313
- package/docs/adding-a-discipline-or-mechanism.md +27 -14
- package/docs/extending.md +4 -3
- package/docs/output-contract.md +326 -0
- package/mechanisms/audit/CD-19/import-boundaries.js +3 -3
- package/mechanisms/audit/CD-2/piece.json +6 -1
- package/mechanisms/audit/CD-5/comments-directives.js +10 -26
- package/mechanisms/audit/runner/README.md +3 -2
- package/mechanisms/audit/runner/runner.js +97 -35
- package/mechanisms/eslint/CD-2/README.md +12 -0
- package/mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js +16 -0
- package/mechanisms/eslint/CD-2/piece.json +25 -0
- package/mechanisms/eslint/runner/README.md +12 -5
- package/mechanisms/eslint/runner/runner.js +900 -242
- package/methods/README.md +2 -0
- package/methods/assessment-template.md +35 -0
- package/methods/lenses/clean-architecture.md +2 -2
- package/methods/lenses/decomposition.md +2 -2
- package/methods/lenses/defended-on-intent.md +7 -7
- package/methods/lenses/di-discipline.md +38 -26
- package/methods/lenses/errors-as-data.md +2 -2
- package/methods/lenses/function-first.md +2 -2
- package/methods/lenses/naming.md +2 -2
- package/methods/lenses/test-discipline.md +15 -13
- package/methods/lenses/type-soundness.md +2 -2
- package/methods/lenses/zod-boundary.md +2 -2
- package/package.json +2 -1
- package/rules/CD-1/CHECKS.md +37 -0
- package/rules/CD-1/README.md +17 -32
- package/rules/CD-10/CHECKS.md +49 -0
- package/rules/CD-10/README.md +21 -49
- package/rules/CD-11/CHECKS.md +13 -0
- package/rules/CD-11/README.md +14 -8
- package/rules/CD-12/CHECKS.md +13 -0
- package/rules/CD-12/README.md +14 -8
- package/rules/CD-13/CHECKS.md +13 -0
- package/rules/CD-13/README.md +14 -8
- package/rules/CD-14/CHECKS.md +49 -0
- package/rules/CD-14/README.md +22 -48
- package/rules/CD-15/CHECKS.md +40 -0
- package/rules/CD-15/README.md +22 -40
- package/rules/CD-16/CHECKS.md +7 -0
- package/rules/CD-16/README.md +3 -5
- package/rules/CD-17/CHECKS.md +37 -0
- package/rules/CD-17/README.md +17 -31
- package/rules/CD-18/CHECKS.md +13 -0
- package/rules/CD-18/README.md +15 -9
- package/rules/CD-19/CHECKS.md +49 -0
- package/rules/CD-19/README.md +18 -44
- package/rules/CD-2/CHECKS.md +56 -0
- package/rules/CD-2/README.md +18 -35
- package/rules/CD-2/discipline.json +68 -0
- package/rules/CD-20/CHECKS.md +7 -0
- package/rules/CD-20/README.md +3 -5
- package/rules/CD-21/CHECKS.md +13 -0
- package/rules/CD-21/README.md +14 -9
- package/rules/CD-22/CHECKS.md +13 -0
- package/rules/CD-22/README.md +13 -8
- package/rules/CD-23/CHECKS.md +35 -0
- package/rules/CD-23/README.md +14 -29
- package/rules/CD-24/CHECKS.md +7 -0
- package/rules/CD-24/README.md +3 -5
- package/rules/CD-25/CHECKS.md +38 -0
- package/rules/CD-25/README.md +20 -32
- package/rules/CD-26/CHECKS.md +36 -0
- package/rules/CD-26/README.md +18 -31
- package/rules/CD-27/CHECKS.md +45 -0
- package/rules/CD-27/README.md +18 -40
- package/rules/CD-28/CHECKS.md +13 -0
- package/rules/CD-28/README.md +14 -8
- package/rules/CD-29/CHECKS.md +13 -0
- package/rules/CD-29/README.md +12 -8
- package/rules/CD-3/CHECKS.md +42 -0
- package/rules/CD-3/README.md +20 -42
- package/rules/CD-30/CHECKS.md +13 -0
- package/rules/CD-30/README.md +13 -8
- package/rules/CD-31/CHECKS.md +13 -0
- package/rules/CD-31/README.md +12 -8
- package/rules/CD-32/CHECKS.md +13 -0
- package/rules/CD-32/README.md +13 -8
- package/rules/CD-33/CHECKS.md +13 -0
- package/rules/CD-33/README.md +13 -8
- package/rules/CD-34/CHECKS.md +13 -0
- package/rules/CD-34/README.md +12 -8
- package/rules/CD-39/CHECKS.md +13 -0
- package/rules/CD-39/README.md +13 -8
- package/rules/CD-4/CHECKS.md +13 -0
- package/rules/CD-4/README.md +15 -8
- package/rules/CD-40/CHECKS.md +39 -0
- package/rules/CD-40/README.md +17 -33
- package/rules/CD-41/CHECKS.md +54 -0
- package/rules/CD-41/README.md +23 -54
- package/rules/CD-42/CHECKS.md +47 -0
- package/rules/CD-42/README.md +19 -47
- package/rules/CD-43/CHECKS.md +37 -0
- package/rules/CD-43/README.md +15 -31
- package/rules/CD-44/CHECKS.md +48 -0
- package/rules/CD-44/README.md +20 -48
- package/rules/CD-45/CHECKS.md +13 -0
- package/rules/CD-45/README.md +14 -8
- package/rules/CD-46/CHECKS.md +7 -0
- package/rules/CD-46/README.md +16 -4
- package/rules/CD-47/CHECKS.md +37 -0
- package/rules/CD-47/README.md +16 -32
- package/rules/CD-5/CHECKS.md +52 -0
- package/rules/CD-5/README.md +22 -52
- package/rules/CD-6/CHECKS.md +51 -0
- package/rules/CD-6/README.md +22 -51
- package/rules/CD-7/CHECKS.md +46 -0
- package/rules/CD-7/README.md +23 -46
- package/rules/CD-7a/CHECKS.md +38 -0
- package/rules/CD-7a/README.md +14 -32
- package/rules/CD-8/CHECKS.md +42 -0
- package/rules/CD-8/README.md +20 -42
- package/rules/CD-9/CHECKS.md +13 -0
- package/rules/CD-9/README.md +15 -8
- package/rules/README.md +5 -3
- package/rules/SPIRIT.md +50 -0
package/README.md
CHANGED
|
@@ -27,36 +27,60 @@ A team adds its own disciplines as a rule set in its own repository, with ESLint
|
|
|
27
27
|
The package ships one command, `hone`, with two subcommands, run through a `package.json` script as [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) shows:
|
|
28
28
|
|
|
29
29
|
```text
|
|
30
|
-
hone check --repo <dir> [--base-revision <
|
|
30
|
+
hone check --repo <dir> [--base-revision <revision>] [--report-output <full|failures-only|counts|verdict-only>] [--forfeiture <this-run|elsewhere>]
|
|
31
31
|
hone project --repo <dir>
|
|
32
|
+
hone --help
|
|
33
|
+
hone --version
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
`hone`
|
|
36
|
+
`--repo` is the folder that holds `disciplines.json`, usually the repository root. `hone --help` lists the commands, `hone check --help` and `hone project --help` list each one's options and exit codes, and `hone --version` prints the installed version. A command typed wrongly is a load failure `arguments-invalid` that says what was wrong, a `--repo` folder with no `disciplines.json` is the load failure `selection-absent`, and an error Hone did not expect is the load failure `unexpected-error`; each exits `2`. Everything Hone prints goes to standard output, so exit `1` always comes with `verdict: fail`. From a source checkout the same command is `node core/check/tool-command.ts check --repo <dir>`.
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
[docs/output-contract.md](docs/output-contract.md) lists every line `hone` prints, exactly as it prints it, with the exit codes and which parts are stable for hooks, CI and agents to rely on. A test renders every kind of line and checks it against that page, both ways.
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
| --- | --- | --- |
|
|
40
|
-
| `0` | the verdict is `pass` | every projection was written or already current |
|
|
41
|
-
| `1` | the verdict is `fail` | not used |
|
|
42
|
-
| `2` | an input could not be loaded, or a mechanism failed or returned invalid output | any failure |
|
|
43
|
-
|
|
44
|
-
A load failure prints one line, `load failure: <kind> <fields>`.
|
|
40
|
+
`hone check` loads the repository's selection, exceptions, rule sets and pieces; works out which files changed since `--base-revision`; runs each selected mechanism once over the repository's tracked `.ts`, `.tsx`, `.mts` and `.cts` files; applies the exceptions; and prints a plain-text report ending in `verdict: pass` or `verdict: fail`. It exits `0` when the verdict is `pass`, `1` when it is `fail`, and `2` on a load failure, which prints one line, `load failure: <kind> <fields>`. `hone project` exits `0` or `2`.
|
|
45
41
|
|
|
46
|
-
The report lists the excluded paths, the clauses not adopted, findings, exempted findings, uncovered clauses, stale, forfeited, unrecorded and doubly-held exceptions, invalid exception records, unmeasured checks, projection problems
|
|
42
|
+
The report lists the excluded paths, the clauses not adopted, the clauses adopted with their mechanism not run, findings, exempted findings, uncovered clauses, stale, forfeited, unrecorded and doubly-held exceptions, invalid exception records, unmeasured checks, projection problems, any part of the assessment left to another run and, last, where to read first for each clause with findings, each with its count. The verdict is `pass` only when every list except the excluded paths, clauses not adopted, clauses not run, exempted findings, assessment and where to read first is empty.
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
An `unrecorded` line is `<clause> <mechanism> <kind> <detail>`. Two kinds end with a note:
|
|
49
45
|
|
|
50
|
-
|
|
|
46
|
+
| Kind | Line |
|
|
51
47
|
| --- | --- |
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
48
|
+
| `inline-disable` naming no rule | `<clause> eslint inline-disable <file>:<line> <comment> names no rule and escapes every selected clause: naming the rule is the cheap fix` |
|
|
49
|
+
| `command-line-option` that weakens the run | `<clause> eslint command-line-option <package.json> <script> <option> weakens the script's whole run, so no record can cover it: remove it from the script` |
|
|
50
|
+
| `command-line-option` Hone cannot judge, because another command comes before `eslint` in its script | `<clause> eslint command-line-option <package.json> <script> <option>: <command> is not the first command of its script, so Hone cannot tell what the option does to the files under check; give <command> a script of its own, such as "<invocation>"` |
|
|
51
|
+
| `command-line-option` Hone cannot judge, because something before `eslint` in its own command is not a package runner or a `NAME=value` setting | `<clause> eslint command-line-option <package.json> <script> <option>: "<wrapper>" comes before <command> and is neither a package runner nor a NAME=value setting, so Hone cannot tell what the option does to the files under check; put only package runners and NAME=value settings before <command>` |
|
|
52
|
+
|
|
53
|
+
`<command>` is the `eslint` call as the script writes it, `<invocation>` is its whole command with its settings and options, from the same script, and `<wrapper>` is the first token before it that Hone does not read, such as `env` or a runner flag like `-y` or `-C`. `cross-env` followed only by `NAME=value` settings counts as a setting. Once only package runners and settings come first, Hone judges the option: `-c` naming the config ESLint already finds, and `--ignore-pattern` that ignores no checked file, are then not reported.
|
|
54
|
+
|
|
55
|
+
`readFirst` comes last, just before the verdict, so a reader who looks only at the end of a failing report lands on it. It has one line per clause with findings, not one per finding, in the order the findings first name the clauses. Each line points at the Spirit section of the clause's rule page, `rules/<ID>/README.md` in the clause's rule set, and, where the repository has written one, at the clause's own section in `disciplines.assessment.md` at the repository root first. That file is where a repository records its own causes, forward goal and steps for a clause; [ADOPTING step 5a](ADOPTING.md#5a-write-the-assessment) says how to write it. Paths are printed with forward slashes, relative to the `--repo` folder; a page on another drive is printed as its absolute path.
|
|
56
|
+
|
|
57
|
+
When `disciplines.assessment.md` is not written yet, or cannot be read, one note line comes first and says so, naming ADOPTING step 5a; each clause line then names its rule page only. The note counts as an entry, so a report with two failing clauses and no assessment file prints `readFirst (3)`. A clause line names the clause's section when the file has one, and says `disciplines.assessment.md does not assess this clause` when the file is there without it. [The output contract](docs/output-contract.md#report-lines) lists every `readFirst` line exactly.
|
|
58
|
+
|
|
59
|
+
A file that does not assess a clause is normal: the assessment covers the clauses the repository chose to describe, and the rule page's Spirit is the read for the rest.
|
|
60
|
+
|
|
61
|
+
A clause's section is a level-2 heading whose text is exactly the clause address as the report prints it (`## CD-15#loops`, `## team/TM-1#no-tmp-files`). Trailing spaces, a carriage return and a byte order mark at the start of the file are ignored. Nothing else is normalised: `## CD-15#loops ##`, `## CD-15#loops`, `### CD-15#loops` and `## hone/CD-15#loops` are not that clause's section, and a heading inside a fenced code block (opened by three or more backticks or tildes, closed by at least as many of the same character) is not counted.
|
|
62
|
+
|
|
63
|
+
Hone matches the heading only; it never reads the section's text. A missing file or section never fails the run. A run with no findings prints no `readFirst` section and reads neither file, so its report is unchanged; a run with findings reads `disciplines.assessment.md` once and checks that each failing clause's rule page exists.
|
|
64
|
+
|
|
65
|
+
`--report-output` sets how much of the report is printed for one run, overriding `reportOutput` in `disciplines.json`; with neither, the output is `full`. `full` prints every non-empty section, `failures-only` leaves out the informational sections and keeps `readFirst`, `counts` prints each section's heading line only, with `informational` or `guidance` after the sections that never fail the run, and `verdict-only` prints the verdict line alone; [the output contract](docs/output-contract.md#the-report) shows each.
|
|
56
66
|
|
|
57
67
|
The output changes only what is printed: the verdict and exit code always come from the whole report. An unknown `--report-output` value is a load failure `arguments-invalid`; an unknown `reportOutput` value makes `disciplines.json` `file-malformed`, even when `--report-output` is given. Load failures print the same in every output.
|
|
58
68
|
|
|
59
|
-
Without `--base-revision`, Hone cannot tell which files were touched, so a file carve-out cannot be forfeited; if any file carve-out exists the report lists `forfeiture-unmeasured` and the run fails. For the same reason it cannot tell whether an entry with an earlier-contract why-chain is unchanged; if one exists the report lists `legacy-chain-unmeasured` and the run fails.
|
|
69
|
+
Without `--base-revision`, Hone cannot tell which files were touched, so a file carve-out cannot be forfeited; if any file carve-out exists the report lists `forfeiture-unmeasured` and the run fails. For the same reason it cannot tell whether an entry with an earlier-contract why-chain is unchanged; if one exists the report lists `legacy-chain-unmeasured` and the run fails. Each line says what Hone needs:
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
forfeiture-unmeasured no-base-revision: no --base-revision was given, so file carve-outs cannot be checked for decay; pass --base-revision with the branch's base, such as origin/main, or leave decay to another run with "assessment": { "forfeiture": "elsewhere" } in disciplines.json or --forfeiture elsewhere
|
|
73
|
+
import-unmeasured no-base-revision: no --base-revision was given, so imported records cannot be checked against it; pass --base-revision with the branch's base, such as origin/main
|
|
74
|
+
legacy-chain-unmeasured no-base-revision: no --base-revision was given, so legacy-chain records cannot be checked against it; pass --base-revision with the branch's base, such as origin/main
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
A `--base-revision` that git cannot use gives the same kinds as `base-git-failed`, naming the revision in double quotes, escaped as in JSON, with git's own first line:
|
|
78
|
+
|
|
79
|
+
```text
|
|
80
|
+
forfeiture-unmeasured base-git-failed "origin/main": git could not list the files changed since that revision and said "<git's first line>"; Hone needs that revision and the history back to where this branch left it, or leave decay to another run with "assessment": { "forfeiture": "elsewhere" } in disciplines.json or --forfeiture elsewhere
|
|
81
|
+
import-unmeasured base-git-failed "origin/main": git could not read the exception records at that revision and said "<git's first line>"; Hone needs the exception records as they were at that revision
|
|
82
|
+
legacy-chain-unmeasured base-git-failed "origin/main": git could not read the exception records at that revision and said "<git's first line>"; Hone needs the exception records as they were at that revision
|
|
83
|
+
```
|
|
60
84
|
|
|
61
85
|
`--forfeiture elsewhere` makes a run leave carve-out decay to another run, such as a pre-push hook given a base revision, overriding `assessment.forfeiture` in `disciplines.json`; `--forfeiture this-run`, the default, assesses it in this run. A run with forfeiture elsewhere asks git for no change set, forfeits no file carve-out and never reports `forfeiture-unmeasured`, with or without `--base-revision`. It ends its report with an `assessment` section, printed whenever the run assesses less than the default, and marks its verdict line in every output:
|
|
62
86
|
|
|
@@ -68,13 +92,7 @@ verdict: pass (partial assessment)
|
|
|
68
92
|
|
|
69
93
|
The `assessment` section is informational and the marker does not change the exit code. Forfeiture elsewhere changes nothing else: `--base-revision` given with it is used only to check imported entries and legacy chains, and a run without a base revision still reports `import-unmeasured` and `legacy-chain-unmeasured` as above.
|
|
70
94
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```text
|
|
74
|
-
waived-clauses not-run: 1 clause not run, 1 record not judged stale: CD-6#naming-convention eslint
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
`hone project` writes the native configuration each embedded mechanism needs, and prints `<path> <effect>` per file (`written` or `unchanged`). The audit mechanism is standalone and writes nothing, so with only the walker selected the command prints nothing and exits `0`.
|
|
95
|
+
`hone project` writes the native configuration each embedded mechanism needs, and prints `<path> <effect>` per file: `written`, `unchanged`, `removed` for a package slice Hone wrote whose folder is no longer a config root, or `left-in-place` for such a file whose bytes are not what Hone would write there. The audit mechanism is standalone and writes nothing, so with only the walker selected the command prints nothing and exits `0`.
|
|
78
96
|
|
|
79
97
|
## Adopting the ESLint mechanism
|
|
80
98
|
|
|
@@ -89,8 +107,46 @@ export default [
|
|
|
89
107
|
];
|
|
90
108
|
```
|
|
91
109
|
|
|
92
|
-
This is the only supported way to adopt the rules. On every check, Hone reads the team's resolved configuration for each checked file and fails the run if the projection is missing
|
|
110
|
+
This is the only supported way to adopt the rules. On every check, Hone reads the team's resolved configuration for each checked file and fails the run if the projection is missing, not in effect, or differs from what `hone project` would write now, with the line that says what to do:
|
|
93
111
|
|
|
112
|
+
```text
|
|
113
|
+
mechanism-not-run eslint missing: disciplines.eslint.mjs is not written; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit every disciplines.eslint.mjs it writes
|
|
114
|
+
mechanism-not-run eslint not-included: the eslint configuration leaves the projection out of effect for a file under check; spread the default export of disciplines.eslint.mjs, or of a package's own disciplines.eslint.mjs in that package, last in the configuration that file loads, after every other block (an import placed last without the spread applies nothing), or, where a tool such as sku generates the configuration, last in the configuration the tool takes
|
|
115
|
+
eslint out-of-date: disciplines.eslint.mjs differs from what hone project writes now; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit every disciplines.eslint.mjs it writes
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The command on these lines runs the entry file of the Hone that ran the check with `node`, with the repository the check measured, both as absolute paths with forward slashes, so it runs as printed from any directory; the lines above show an install at `/work/shop`. Re-run `hone project` after changing the selection or the exceptions.
|
|
119
|
+
|
|
120
|
+
### Package slices
|
|
121
|
+
|
|
122
|
+
A package that runs ESLint from its own folder resolves the `files` of its config against that folder, so spreading the root projection there loses every carve-out written with a root-relative path. `hone project` therefore writes one projection per config root. The repository root gets `disciplines.eslint.mjs` as above. Under the nearest-to-file lookup, each package folder with a tracked `eslint.config.*` is a config root; under the repository-root lookup a package's own config is never loaded, so it gets no slice. Each folder `disciplines.json` lists under `eslintConfigRoots` is a config root under either lookup. Each package config root gets its own `disciplines.eslint.mjs` beside it: the same pieces, imported by a path relative to that folder, and only the records for files under it, with paths relative to it; clause-wide carve-outs go in every slice. Each package config spreads its own slice:
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
import disciplines from "./disciplines.eslint.mjs";
|
|
126
|
+
|
|
127
|
+
export default [{ files: ["**/*.{ts,tsx,mts,cts}"] }, ...disciplines];
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
A package with no `eslint.config.*` of its own is linted by the nearest config above it, so its records stay in that config's slice. A file is governed by the deepest config root that contains it. A folder holding its own `disciplines.json` gets no slice, and nor does anything under it: its ESLint configuration is not managed from this repository, and nested Hone configurations are not supported yet ([#72](https://github.com/HailsTails/hone/issues/72)). When that folder's own config leaves a carve-out recorded there out of effect, the `mechanism-not-run` line it explains adds the folder, which `--report-output failures-only` prints too. Governing the folder from this repository works today: remove its `disciplines.json`, keep its records here, and `hone project` writes its slice. With package slices also reported, the line points at them:
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
mechanism-not-run eslint not-included: the eslint configuration leaves the projection out of effect for a file under check; spread the default export of disciplines.eslint.mjs, or of a package's own disciplines.eslint.mjs in that package, last in the configuration that file loads, after every other block (an import placed last without the spread applies nothing), or, where a tool such as sku generates the configuration, last in the configuration the tool takes; the eslint lines under projectionProblems name the package slices involved; fixtures/a hold their own disciplines.json, and nested Hone configurations are not supported yet (https://github.com/HailsTails/hone/issues/72): to govern such a folder from this repository, remove its disciplines.json and keep its records here, then run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop, which writes its slice
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
A config root keeps its slice even where a config above it ignores its folder: a lint run from that folder loads its own config and never reads the ignores above it, so `hone project` writes the same slices from the same inputs every time. `not-applied` for such a package judges each recorded file by its nearest config, the one that lint loads. A repository with only a root config gets exactly the projection it had before.
|
|
137
|
+
|
|
138
|
+
The check reports each package slice under the mechanism, naming the slice: out of date, missing, or, when ESLint resolves each file from its nearest config and a package's carve-outs are not in effect, for example because its config spreads the root projection or nothing instead of its slice, not applied, beside `mechanism-not-run eslint not-included`. A folder listed under `eslintConfigRoots` with no `eslint.config.*` on disk is unconfigured: nothing there can load its slice, so Hone would otherwise say nothing about that package; generate its config before the check runs, as a tool such as sku does on any of its commands:
|
|
139
|
+
|
|
140
|
+
```text
|
|
141
|
+
eslint out-of-date packages/a/disciplines.eslint.mjs: that slice differs from what hone project writes now; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit every disciplines.eslint.mjs it writes
|
|
142
|
+
eslint missing packages/a/disciplines.eslint.mjs: that slice is not written; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit every disciplines.eslint.mjs it writes
|
|
143
|
+
eslint not-applied packages/a/disciplines.eslint.mjs: the eslint configuration for packages/a leaves records of that slice out of effect; spread the default export of packages/a/disciplines.eslint.mjs last in that package's configuration, in place of any other projection it spreads, or, where a tool such as sku generates the configuration, last in the configuration the tool takes
|
|
144
|
+
eslint unconfigured packages/a/disciplines.eslint.mjs: packages/a has no eslint configuration file on disk, so nothing loads that slice; run the tool that generates it (for sku, sku configure) before the check
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
A slice is not-applied only when a recorded file under check in that package is not excepted; a package with no file exceptions gets the same rules from either projection, so the check is silent there until the package has one.
|
|
148
|
+
|
|
149
|
+
`hone project` removes a tracked `disciplines.eslint.mjs` whose folder is no longer a config root only when its bytes are exactly what Hone would write for that folder now, so a file Hone did not write is never deleted; any other such file is reported `left-in-place`. Under the repository-root lookup no package folder is a config root, so `hone project` removes each package slice it wrote; a package config that still imports its slice then fails to load when someone lints from that package. List such a package under `eslintConfigRoots` to keep its slice, or stop importing it.
|
|
94
150
|
A file carve-out stays in the projection after it is forfeited, so the team's own ESLint run keeps ignoring that file; Hone's check is what fails it, as `forfeited`.
|
|
95
151
|
|
|
96
152
|
Hone's own ESLint run uses only the runner's configuration, with ignores, suppressions and inline configuration off, so nothing in the team's setup can change a finding. Every way the team's setup can weaken a selected rule (a native channel) is reported instead, and only an override that matches an exception record is accepted. The guide has the table.
|
|
@@ -113,15 +169,16 @@ At the repository root. It selects clauses and the mechanism that checks each on
|
|
|
113
169
|
```
|
|
114
170
|
|
|
115
171
|
- `ruleSets` names the repository's own rule sets, each a directory relative to the repository root. The name `hone` is reserved for the rule set shipped with the tool; `hone/CD-15#loops` and `CD-15#loops` are the same address. A rule-set name may not start with `hone-`, and no declared name may be another declared name plus `-<suffix>`.
|
|
116
|
-
- `clauses` maps a clause address to a mechanism id, or to `"not-adopted"`. An address is `[<ruleSet>/]<DisciplineId>#<clauseId>`; no prefix means the `hone` rule set. The mechanism must be one the clause lists.
|
|
172
|
+
- `clauses` maps a clause address to a mechanism id, to `"not-run"` or to `"not-adopted"`. An address is `[<ruleSet>/]<DisciplineId>#<clauseId>`; no prefix means the `hone` rule set. The mechanism must be one the clause lists.
|
|
117
173
|
- Listing a clause adopts its discipline. Mechanical clauses of an adopted discipline that are not listed are reported as uncovered, and fail the run.
|
|
118
|
-
- `"not-
|
|
174
|
+
- `"not-run"` states that the clause is adopted and binds the repository, but its mechanism is not run: the check is not a true measure of the rule's intent here, or cannot work here. The rule is enforced by review. `"not-adopted"` states that the clause does not apply to the repository. Either way the clause is never run and never projected, and its mechanism is not loaded unless another clause uses it. The report lists it under `notRun`, as `<clause> adopted, mechanism not run: enforced by review`, or under `notAdopted`; both are informational, and the run is still a whole assessment. An exception record on it is invalid as `clause-not-run` or `clause-not-adopted`, and `clauseSettings` for it make `disciplines.json` `file-malformed`: remove them. The clause must still exist and be mechanical, in any rule set; a judgement clause is never listed in either state and fails the run as `judgement-clause-listed`. No mechanism may be named `not-run` or `not-adopted`.
|
|
119
175
|
- A judgement clause cannot be selected; it is enforced by review.
|
|
120
176
|
- `eslintConfigLookup`, optional, is `"nearest-to-file"` or `"repository-root"` and says which `eslint.config.*` the team's own ESLint run applies to a file; see [Runtime](#runtime). Leave it out to let Hone detect it.
|
|
177
|
+
- `eslintConfigRoots`, optional, lists repository folders that get their own projection slice under either lookup although they track no `eslint.config.*`, such as a package whose config a tool generates and ignores; see [Package slices](#package-slices). Globs are refused. Each entry must be a folder git tracks files under outside every `exclude` path, spelled exactly as git spells it; any other entry stops the run before anything is checked or written, as `load failure: config-root-untracked <folder>:` with what to fix.
|
|
121
178
|
- `fileExceptionWhyChains`, optional, is `"required"` (the default) or `"optional"`. `"optional"` lets an `authorised-location` or `file-carve-out` entry give only its `reason`; see [discipline-exceptions.json](#discipline-exceptionsjson).
|
|
122
179
|
- `reportOutput`, optional, is `"full"` (the default), `"failures-only"`, `"counts"` or `"verdict-only"`: the repository's default for how much of the report the check prints. `--report-output` overrides it for one run; see [Commands](#commands).
|
|
123
|
-
- `clauseSettings`, optional, maps a selected clause address to an object of that clause's settings, for a clause whose
|
|
124
|
-
- `assessment`, optional, says which run assesses each concern. `forfeiture
|
|
180
|
+
- `clauseSettings`, optional, maps a selected clause address to an object of that clause's settings, for a clause whose CHECKS.md lists settings. Each key must be one the clause's piece declares, and its value must be the same JSON kind as the declared default and, where the piece lists choices, one of them; the value replaces the default. Anything else makes `disciplines.json` malformed, naming the clause, the key and what is accepted: settings for a clause the file does not select or names twice, for a clause that takes none, under an undeclared key, or of the wrong kind or choice.
|
|
181
|
+
- `assessment`, optional, says which run assesses each concern. Its one key, `forfeiture`, is `"this-run"` (the default) or `"elsewhere"`; `--forfeiture` overrides it for one run; see [Commands](#commands). `waivedClauses`, which earlier releases accepted, is removed: it makes `disciplines.json` `file-malformed`, naming the clause states that replace it; see [MIGRATING.md](MIGRATING.md#12-moving-off-waivedclauses). Any other key makes it `file-malformed`, naming the key as not available in this version.
|
|
125
182
|
- `exclude`, optional, lists repository folders or exact files that no mechanism checks. A folder entry covers everything under it. Globs are refused: an entry containing `*` makes `disciplines.json` malformed. The report lists the active entries under `excluded`. Exclude Hone's own install when it is vendored inside the repository.
|
|
126
183
|
|
|
127
184
|
## discipline-exceptions.json
|
|
@@ -141,7 +198,8 @@ At the repository root; absent means no exceptions. Each entry names a selected
|
|
|
141
198
|
|
|
142
199
|
- An `authorised-location` says the clause does not apply to that file.
|
|
143
200
|
- A `file-carve-out` is debt in one file. It is forfeited once the file is touched.
|
|
144
|
-
- A `clause-wide-carve-out` exempts the clause everywhere.
|
|
201
|
+
- A `clause-wide-carve-out` exempts the clause's findings everywhere. It does not hold an inline exception.
|
|
202
|
+
- An inline exception, an `eslint-disable` comment naming a selected rule or no rule, or a `@ts-expect-error`, `@ts-ignore` or `@ts-nocheck` directive under `CD-2#cast-expressions`, is held only by an `authorised-location` or `file-carve-out` on its clause and file. A comment naming no rule escapes every selected ESLint clause and needs one per clause. Without a record it is listed under `unrecorded` and fails the run. A lint-script option that weakens the whole run, such as `--rule`, `--suppress-all` or `-c` naming another config, cannot be recorded.
|
|
145
203
|
- Every entry needs a `whyChain` (an `authorised-location` or `file-carve-out` may leave it out when `fileExceptionWhyChains` is `"optional"`; see below) that follows the [why-chain contract](docs/why-chain-contract.md): exactly five `{ "why", "because", "evidence" }` steps chained cause to cause, then `rootCause`, `rootCheck`, `readback` and `owner`. The contract lists what Hone refuses and what review still judges:
|
|
146
204
|
|
|
147
205
|
```json
|
|
@@ -193,9 +251,9 @@ Both resolve with `moduleResolution` `"nodenext"` or `"bundler"`. `install-proof
|
|
|
193
251
|
|
|
194
252
|
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.
|
|
195
253
|
|
|
196
|
-
A peer that is missing, cannot load, or is outside its range stops the mechanism before any piece loads, with one line such as `load failure: runner-failed eslint toolchain-unavailable eslint found not installed, supported ^9.28.0 || ^10.0.0: add a supported version to the devDependencies of the repository root`. A `typescript` that is not installed at all is reported the same way, with the line saying that `typescript` is a required peer of `@hailstails/hone` and the install is incomplete, since a supported install always has it; one that is installed but out of range or unloadable gets the plain line. A peer that resolves from inside the installed package, such as an `eslint` left in `node_modules/@hailstails/hone/node_modules`, stops it as `toolchain-shadowed`, naming where it resolved and the folder to delete before reinstalling core. A source checkout of Hone is its own development install, so its development toolchain in its own `node_modules` is not a shadow.
|
|
254
|
+
A peer that is missing, cannot load, or is outside its range stops the mechanism before any piece loads, with one line such as `load failure: runner-failed eslint toolchain-unavailable eslint found not installed, supported ^9.28.0 || ^10.0.0: add a supported version to the devDependencies of the repository root`. The line names every peer of that mechanism that is unavailable, separated by `; `, and then asks for a supported version of each, so one install fixes them all. A `typescript` that is not installed at all is reported the same way, with the line saying that `typescript` is a required peer of `@hailstails/hone` and the install is incomplete, since a supported install always has it; one that is installed but out of range or unloadable gets the plain line. A peer that resolves from inside the installed package, such as an `eslint` left in `node_modules/@hailstails/hone/node_modules`, stops it as `toolchain-shadowed`, naming where it resolved and the folder to delete before reinstalling core. A source checkout of Hone is its own development install, so its development toolchain in its own `node_modules` is not a shadow.
|
|
197
255
|
|
|
198
|
-
A repository can hold one `eslint.config.*` at its root or one per package. Hone resolves the team's configuration the way the team's own ESLint run does. ESLint 10, and ESLint 9 started with `--flag v10_config_lookup_from_file` (or `unstable_config_lookup_from_file`), use the `eslint.config.*` nearest each checked file. Plain ESLint 9 uses only the one in the directory it runs from, so for a repository whose `eslint` resolves to 9.x at `node_modules/eslint` and whose lint scripts carry no such flag, Hone reads the root `eslint.config.*` for every file, and fails the run as `team-config-unloadable` if there is none. When Hone cannot read an installed `eslint` at the repository root it assumes the nearest-to-file lookup. Each config that applies to a file must spread the projection. Detection cannot see how a task runner starts ESLint, so `disciplines.json` can state the lookup: `"eslintConfigLookup": "nearest-to-file"` or `"repository-root"`, which overrides detection. Both lookups are tested against monorepo fixtures with a config per package.
|
|
256
|
+
A repository can hold one `eslint.config.*` at its root or one per package. Hone resolves the team's configuration the way the team's own ESLint run does. ESLint 10, and ESLint 9 started with `--flag v10_config_lookup_from_file` (or `unstable_config_lookup_from_file`), use the `eslint.config.*` nearest each checked file. Plain ESLint 9 uses only the one in the directory it runs from, so for a repository whose `eslint` resolves to 9.x at `node_modules/eslint` and whose lint scripts carry no such flag, Hone reads the root `eslint.config.*` for every file, and fails the run as `team-config-unloadable` if there is none. When Hone cannot read an installed `eslint` at the repository root it assumes the nearest-to-file lookup. Each config that applies to a file must spread its projection: the root config the root projection, each package config its own slice; see [Package slices](#package-slices). A config that fails to load stops the run as `team-config-unloadable`, naming the config, the checked file it applies to and ESLint's message, then the next step: fix that config. Only if its folder holds nothing Hone should check, add it to `exclude` in `disciplines.json` instead. A broken config in a folder that the repository's own ESLint never enters does not stop the run. Before failing, Hone asks the config that governs that folder, and each config above it up to the root, whether it really ignores both that folder and the file; a file that no `files` block matches is not taken for an ignored one. If one does, the file is treated like any other file the team's ESLint ignores and reported as an `ignore` native exception. Hone asks about a folder through a file inside it, so one gap remains: an ignore that matches every entry directly inside the folder but not the folder itself, such as `gen/*`, counts as ignoring `gen`, and Hone reports its files as ignored where the team's `eslint .` still loads the broken `gen/eslint.config.*` and fails. A file that no `eslint.config.*` applies to stops the run the same way, and the next step is to create one at the repository root that spreads the projection, as [ADOPTING.md](ADOPTING.md) step 4a shows. Detection cannot see how a task runner starts ESLint, so `disciplines.json` can state the lookup: `"eslintConfigLookup": "nearest-to-file"` or `"repository-root"`, which overrides detection. Both lookups are tested against monorepo fixtures with a config per package.
|
|
199
257
|
|
|
200
258
|
## Compatibility
|
|
201
259
|
|
|
@@ -203,11 +261,16 @@ Hone's version numbers follow semantic versioning under these rules:
|
|
|
203
261
|
|
|
204
262
|
- A new or tightened check ships off by default in a minor release and becomes a default only in a major release.
|
|
205
263
|
- A change to the ESLint config that `hone project` generates, which an adopter must regenerate, is a minor release, with a clear message telling the adopter to regenerate: its changelog entry says to run `hone project` and commit the result, and until then the check reports the projection `out-of-date`.
|
|
206
|
-
-
|
|
264
|
+
- 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.
|
|
265
|
+
- 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.
|
|
207
266
|
- 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.
|
|
208
267
|
- Before the first stable release, a change that would need a major release ships in a minor release instead.
|
|
209
268
|
- 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.
|
|
210
269
|
|
|
270
|
+
`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.
|
|
271
|
+
|
|
272
|
+
A clause that accepts `audit` keeps accepting it: `audit` is never removed from the mechanisms such a clause lists, so a selection that names `audit` for it keeps loading. A clause can only gain mechanisms.
|
|
273
|
+
|
|
211
274
|
Each release's changes are listed in [the changelog](https://github.com/HailsTails/hone/blob/main/CHANGELOG.md) in the repository.
|
|
212
275
|
|
|
213
276
|
## Known limits
|
|
@@ -245,7 +308,7 @@ This repository is self-contained: it holds its own configuration and its own lo
|
|
|
245
308
|
| `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` |
|
|
246
309
|
| `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 |
|
|
247
310
|
| `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) |
|
|
248
|
-
| `install-proof` | `node scripts/install-proof.ts`: packs the package once into a temporary tarball and installs it
|
|
311
|
+
| `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, and the proof prints where pnpm put the installed package and expects the report to name its pages there. 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 |
|
|
249
312
|
| `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) |
|
|
250
313
|
| `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) |
|
|
251
314
|
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sameClauseAddress
|
|
3
|
+
} from "./chunk-NCDYOPHG.js";
|
|
4
|
+
|
|
5
|
+
// mechanisms/audit/runner/type-directives.ts
|
|
6
|
+
var TYPE_DIRECTIVES = ["@ts-expect-error", "@ts-ignore", "@ts-nocheck"];
|
|
7
|
+
var LINE_SUPPRESSIONS = [
|
|
8
|
+
{ directive: "@ts-expect-error", pattern: /^\/\/\/?\s*@ts-expect-error/ },
|
|
9
|
+
{ directive: "@ts-ignore", pattern: /^\/\/\/?\s*@ts-ignore/ }
|
|
10
|
+
];
|
|
11
|
+
var BLOCK_SUPPRESSIONS = [
|
|
12
|
+
{ directive: "@ts-expect-error", pattern: /^\s*[/*]*\s*@ts-expect-error/ },
|
|
13
|
+
{ directive: "@ts-ignore", pattern: /^\s*[/*]*\s*@ts-ignore/ }
|
|
14
|
+
];
|
|
15
|
+
var FILE_SUPPRESSIONS = [
|
|
16
|
+
{ directive: "@ts-nocheck", pattern: /^\/\/\/?\s*@ts-nocheck(?=[\s:]|$)/i }
|
|
17
|
+
];
|
|
18
|
+
var readingAgainst = (request) => request.patterns.flatMap(({ directive, pattern }) => {
|
|
19
|
+
const marker = pattern.exec(request.text);
|
|
20
|
+
return marker === null ? [] : [{ directive, tail: request.text.slice(marker.index + marker[0].length) }];
|
|
21
|
+
})[0];
|
|
22
|
+
var commentPlacementOf = (request) => ({
|
|
23
|
+
form: request.range.kind === request.syntaxApi.SyntaxKind.MultiLineCommentTrivia ? "block" : "line",
|
|
24
|
+
region: request.fileHeaderPositions.has(request.range.pos) ? "file-header" : "body"
|
|
25
|
+
});
|
|
26
|
+
var readingByPlacement = (request) => {
|
|
27
|
+
const { comment, placement } = request;
|
|
28
|
+
if (placement.form === "block") {
|
|
29
|
+
return readingAgainst({ patterns: BLOCK_SUPPRESSIONS, text: comment.slice(comment.lastIndexOf("\n") + 1) });
|
|
30
|
+
}
|
|
31
|
+
const suppression = readingAgainst({ patterns: LINE_SUPPRESSIONS, text: comment });
|
|
32
|
+
if (suppression !== void 0 || placement.region === "body") return suppression;
|
|
33
|
+
return readingAgainst({ patterns: FILE_SUPPRESSIONS, text: comment });
|
|
34
|
+
};
|
|
35
|
+
var jsxTextSpansUnder = (request) => {
|
|
36
|
+
const own = request.syntaxApi.isJsxText(request.node) ? [{ pos: request.node.pos, end: request.node.end }] : [];
|
|
37
|
+
const children = [];
|
|
38
|
+
request.syntaxApi.forEachChild(request.node, (child) => {
|
|
39
|
+
children.push(child);
|
|
40
|
+
});
|
|
41
|
+
return [...own, ...children.flatMap((child) => jsxTextSpansUnder({ node: child, syntaxApi: request.syntaxApi }))];
|
|
42
|
+
};
|
|
43
|
+
var jsxTextSpansOf = (request) => request.sourceFile.languageVariant === request.syntaxApi.LanguageVariant.JSX ? jsxTextSpansUnder({ node: request.sourceFile, syntaxApi: request.syntaxApi }) : [];
|
|
44
|
+
var rangePlacementOf = (request) => request.spans.some((span) => span.pos <= request.range.pos && request.range.end <= span.end) ? "jsx-text" : "trivia";
|
|
45
|
+
var typeDirectiveReaderFor = (request) => {
|
|
46
|
+
const { sourceFile, syntaxApi } = request;
|
|
47
|
+
const fileHeaderPositions = new Set(
|
|
48
|
+
(syntaxApi.getLeadingCommentRanges(sourceFile.text, 0) ?? []).map((headerRange) => headerRange.pos)
|
|
49
|
+
);
|
|
50
|
+
const jsxTextSpans = jsxTextSpansOf({ sourceFile, syntaxApi });
|
|
51
|
+
return ({ range }) => rangePlacementOf({ range, spans: jsxTextSpans }) === "jsx-text" ? void 0 : readingByPlacement({
|
|
52
|
+
comment: sourceFile.text.slice(range.pos, range.end),
|
|
53
|
+
placement: commentPlacementOf({ range, fileHeaderPositions, syntaxApi })
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
var escapesOf = (request) => request.escapes.filter(
|
|
57
|
+
(directiveEscape) => request.clauses.some((clause) => sameClauseAddress({ left: clause, right: directiveEscape.clause }) === "same")
|
|
58
|
+
);
|
|
59
|
+
var directiveEscapesIn = (request) => {
|
|
60
|
+
if (request.escapes.length === 0) return [];
|
|
61
|
+
const readDirective = typeDirectiveReaderFor(request);
|
|
62
|
+
return [...request.comments].sort((left, right) => left.pos - right.pos).flatMap((range) => {
|
|
63
|
+
const reading = readDirective({ range });
|
|
64
|
+
if (reading === void 0) return [];
|
|
65
|
+
const line = request.anchorAt({ position: range.pos }).line;
|
|
66
|
+
const text = request.sourceFile.text.slice(range.pos, range.end).trim();
|
|
67
|
+
return request.escapes.filter((directiveEscape) => directiveEscape.directives.includes(reading.directive)).map((directiveEscape) => ({ kind: "inline-disable", clause: directiveEscape.clause, file: request.file, line, text, reach: "one-clause" }));
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
TYPE_DIRECTIVES,
|
|
73
|
+
typeDirectiveReaderFor,
|
|
74
|
+
escapesOf,
|
|
75
|
+
directiveEscapesIn
|
|
76
|
+
};
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
repoPathSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MVK5KFJI.js";
|
|
4
4
|
import {
|
|
5
5
|
clauseIdSchema,
|
|
6
6
|
disciplineIdSchema,
|
|
7
7
|
external_exports,
|
|
8
8
|
mechanismIdSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NCDYOPHG.js";
|
|
10
|
+
|
|
11
|
+
// core/values/parsed-json.ts
|
|
12
|
+
var parsedJson = (request) => {
|
|
13
|
+
try {
|
|
14
|
+
const parsed = JSON.parse(request.text);
|
|
15
|
+
return { outcome: "ok", value: parsed };
|
|
16
|
+
} catch (thrown) {
|
|
17
|
+
return {
|
|
18
|
+
outcome: "failed",
|
|
19
|
+
error: thrown instanceof Error ? thrown.message : String(thrown)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
};
|
|
10
23
|
|
|
11
24
|
// core/values/json-kind.ts
|
|
12
25
|
var JSON_KIND_NAMES = {
|
|
@@ -39,17 +52,6 @@ var sameJsonValue = (request) => {
|
|
|
39
52
|
|
|
40
53
|
// core/rule-set-reader/rule-set-reader.ts
|
|
41
54
|
var SUPPORTED_VERSION = 1;
|
|
42
|
-
var parsedJson = (request) => {
|
|
43
|
-
try {
|
|
44
|
-
const parsed = JSON.parse(request.text);
|
|
45
|
-
return { outcome: "ok", value: parsed };
|
|
46
|
-
} catch (thrown) {
|
|
47
|
-
return {
|
|
48
|
-
outcome: "failed",
|
|
49
|
-
error: thrown instanceof Error ? thrown.message : String(thrown)
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
55
|
var readVersionOneJson = (request) => {
|
|
54
56
|
const text = request.fileText.read({ path: request.path });
|
|
55
57
|
if (text.outcome === "failed") {
|
|
@@ -7,7 +7,9 @@ var gatheredOutcomes = (request) => {
|
|
|
7
7
|
value: request.outcomes.flatMap((outcome) => outcome.outcome === "ok" ? outcome.value : [])
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
+
var listedOutcome = (request) => request.outcome.outcome === "failed" ? request.outcome : { outcome: "ok", value: [request.outcome.value] };
|
|
10
11
|
|
|
11
12
|
export {
|
|
12
|
-
gatheredOutcomes
|
|
13
|
+
gatheredOutcomes,
|
|
14
|
+
listedOutcome
|
|
13
15
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
repoPathSchema
|
|
3
|
-
|
|
2
|
+
repoPathSchema,
|
|
3
|
+
snippetSchema
|
|
4
|
+
} from "./chunk-MVK5KFJI.js";
|
|
4
5
|
import {
|
|
5
6
|
clauseAddressObjectSchema,
|
|
6
7
|
external_exports
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-NCDYOPHG.js";
|
|
8
9
|
|
|
9
10
|
// core/values/anchor-schema.ts
|
|
10
11
|
var anchorSchema = external_exports.object({
|
|
@@ -14,6 +15,7 @@ var anchorSchema = external_exports.object({
|
|
|
14
15
|
|
|
15
16
|
// core/mechanism-port/runner-failure-schema.ts
|
|
16
17
|
var peerKindSchema = external_exports.enum(["required", "optional"]);
|
|
18
|
+
var unavailablePeerSchema = external_exports.object({ packageName: external_exports.string(), peer: peerKindSchema, supported: external_exports.string(), found: external_exports.string() }).readonly();
|
|
17
19
|
var runnerFailureSchema = external_exports.discriminatedUnion("kind", [
|
|
18
20
|
external_exports.object({ kind: external_exports.literal("piece-invalid"), pieceRoot: external_exports.string(), detail: external_exports.string() }).readonly(),
|
|
19
21
|
external_exports.object({ kind: external_exports.literal("tool-failed"), detail: external_exports.string() }).readonly(),
|
|
@@ -24,10 +26,7 @@ var runnerFailureSchema = external_exports.discriminatedUnion("kind", [
|
|
|
24
26
|
external_exports.object({ kind: external_exports.literal("file-unparseable"), file: repoPathSchema, detail: external_exports.string() }).readonly(),
|
|
25
27
|
external_exports.object({
|
|
26
28
|
kind: external_exports.literal("toolchain-unavailable"),
|
|
27
|
-
|
|
28
|
-
peer: peerKindSchema,
|
|
29
|
-
supported: external_exports.string(),
|
|
30
|
-
found: external_exports.string()
|
|
29
|
+
peers: external_exports.tuple([unavailablePeerSchema], unavailablePeerSchema).readonly()
|
|
31
30
|
}).readonly(),
|
|
32
31
|
external_exports.object({
|
|
33
32
|
kind: external_exports.literal("toolchain-shadowed"),
|
|
@@ -50,7 +49,7 @@ var hitSchema = external_exports.object({
|
|
|
50
49
|
clause: clauseAddressObjectSchema,
|
|
51
50
|
file: repoPathSchema,
|
|
52
51
|
anchor: anchorSchema,
|
|
53
|
-
snippet:
|
|
52
|
+
snippet: snippetSchema
|
|
54
53
|
}).readonly();
|
|
55
54
|
var caseVerdictSchema = external_exports.object({
|
|
56
55
|
caseName: external_exports.string(),
|
|
@@ -58,7 +57,7 @@ var caseVerdictSchema = external_exports.object({
|
|
|
58
57
|
}).readonly();
|
|
59
58
|
var projectionWriteSchema = external_exports.object({
|
|
60
59
|
path: repoPathSchema,
|
|
61
|
-
effect: external_exports.enum(["written", "unchanged"])
|
|
60
|
+
effect: external_exports.enum(["written", "unchanged", "removed", "left-in-place"])
|
|
62
61
|
}).readonly();
|
|
63
62
|
var runnerResultSchema = (request) => external_exports.union([
|
|
64
63
|
external_exports.object({ outcome: external_exports.literal("ok"), value: request.value }).readonly(),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
brandedTextSchema,
|
|
3
3
|
external_exports
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NCDYOPHG.js";
|
|
5
5
|
|
|
6
6
|
// core/platform-ports/file-system-port.ts
|
|
7
|
-
import { accessSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { accessSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
8
8
|
var NO_SUCH_FILE_CODE = "ENOENT";
|
|
9
9
|
var presenceAfterAccessFailure = (request) => request.thrown instanceof Error && "code" in request.thrown && request.thrown.code === NO_SUCH_FILE_CODE ? "absent" : "present";
|
|
10
10
|
var failureDetail = (request) => request.thrown instanceof Error ? request.thrown.message : String(request.thrown);
|
|
@@ -57,6 +57,25 @@ var defaultFileSystemSurface = {
|
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
var createDefaultFileTextPort = (_options) => createFileTextPort({ fileSystem: defaultFileSystemSurface });
|
|
60
|
+
var createFileRemovalPort = (options) => ({
|
|
61
|
+
remove: (request) => {
|
|
62
|
+
try {
|
|
63
|
+
options.fileSystem.removeFile({ path: request.path });
|
|
64
|
+
return { outcome: "ok", value: void 0 };
|
|
65
|
+
} catch (thrown) {
|
|
66
|
+
return {
|
|
67
|
+
outcome: "failed",
|
|
68
|
+
error: { kind: "unremovable", path: request.path, detail: failureDetail({ thrown }) }
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
var defaultFileRemovalSurface = {
|
|
74
|
+
removeFile: (request) => {
|
|
75
|
+
rmSync(request.path);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var createDefaultFileRemovalPort = (_options) => createFileRemovalPort({ fileSystem: defaultFileRemovalSurface });
|
|
60
79
|
|
|
61
80
|
// core/platform-ports/module-loader-port.ts
|
|
62
81
|
import { pathToFileURL } from "node:url";
|
|
@@ -293,12 +312,25 @@ var toolchainUnavailable = (request) => ({
|
|
|
293
312
|
outcome: "failed",
|
|
294
313
|
error: {
|
|
295
314
|
kind: "toolchain-unavailable",
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
315
|
+
peers: [
|
|
316
|
+
{
|
|
317
|
+
packageName: request.requirement.packageName,
|
|
318
|
+
peer: request.requirement.peer,
|
|
319
|
+
supported: supportedRange({ requirement: request.requirement }),
|
|
320
|
+
found: request.found
|
|
321
|
+
}
|
|
322
|
+
]
|
|
300
323
|
}
|
|
301
324
|
});
|
|
325
|
+
var unavailablePeersOf = (request) => request.failure.kind === "toolchain-unavailable" ? request.failure.peers : [];
|
|
326
|
+
var gatheredPeerFailure = (request) => {
|
|
327
|
+
const otherFailure = request.failures.find((failure) => failure.kind !== "toolchain-unavailable");
|
|
328
|
+
if (otherFailure !== void 0) {
|
|
329
|
+
return otherFailure;
|
|
330
|
+
}
|
|
331
|
+
const [first, ...rest] = request.failures.flatMap((failure) => unavailablePeersOf({ failure }));
|
|
332
|
+
return first === void 0 ? request.failures[0] : { kind: "toolchain-unavailable", peers: [first, ...rest] };
|
|
333
|
+
};
|
|
302
334
|
var thrownState = (request) => {
|
|
303
335
|
const parsed = moduleErrorSchema.safeParse(request.thrown);
|
|
304
336
|
if (parsed.success && parsed.data.code === MODULE_NOT_FOUND && parsed.data.message.includes(`'${request.packageName}'`)) {
|
|
@@ -318,7 +350,7 @@ var versionedPeer = (request) => Promise.resolve().then(request.load).then((load
|
|
|
318
350
|
found: thrownState({ thrown, packageName: request.requirement.packageName })
|
|
319
351
|
})
|
|
320
352
|
);
|
|
321
|
-
var
|
|
353
|
+
var shadowedPeer = (request) => ({
|
|
322
354
|
outcome: "failed",
|
|
323
355
|
error: {
|
|
324
356
|
kind: "toolchain-shadowed",
|
|
@@ -326,11 +358,24 @@ var placedPeer = (request) => shadowingOf({ resolved: request.resolved, location
|
|
|
326
358
|
location: request.resolved,
|
|
327
359
|
installRoot: request.location.installRoot
|
|
328
360
|
}
|
|
329
|
-
})
|
|
330
|
-
var
|
|
331
|
-
|
|
361
|
+
});
|
|
362
|
+
var placedPeer = (request) => shadowingOf({ resolved: request.resolved, location: request.location }) === "shadowed" ? Promise.resolve(shadowedPeer(request)) : versionedPeer(request);
|
|
363
|
+
var unlocatedPeer = (request) => toolchainUnavailable({
|
|
364
|
+
requirement: request.requirement,
|
|
365
|
+
found: `unloadable: ${request.unlocatable.url} (${request.unlocatable.detail})`
|
|
366
|
+
});
|
|
367
|
+
var locatedPeer = (request) => request.located.outcome === "ok" ? placedPeer({ ...request, resolved: request.located.value }) : Promise.resolve(unlocatedPeer({ requirement: request.requirement, unlocatable: request.located.error }));
|
|
368
|
+
var installedAt = (request) => {
|
|
369
|
+
if (request.located.outcome === "failed") {
|
|
370
|
+
return unlocatedPeer({ requirement: request.requirement, unlocatable: request.located.error });
|
|
371
|
+
}
|
|
372
|
+
return shadowingOf({ resolved: request.located.value, location: request.location }) === "shadowed" ? shadowedPeer({ ...request, resolved: request.located.value }) : { outcome: "ok", value: null };
|
|
373
|
+
};
|
|
374
|
+
var installedPeer = (request) => Promise.resolve().then(() => request.location.locate({ packageName: request.requirement.packageName })).then(
|
|
375
|
+
(located) => installedAt({ ...request, located }),
|
|
376
|
+
(thrown) => toolchainUnavailable({
|
|
332
377
|
requirement: request.requirement,
|
|
333
|
-
found:
|
|
378
|
+
found: thrownState({ thrown, packageName: request.requirement.packageName })
|
|
334
379
|
})
|
|
335
380
|
);
|
|
336
381
|
var loadedPeer = (request) => Promise.resolve().then(() => request.location.locate({ packageName: request.requirement.packageName })).then(
|
|
@@ -341,8 +386,18 @@ var loadedPeer = (request) => Promise.resolve().then(() => request.location.loca
|
|
|
341
386
|
})
|
|
342
387
|
);
|
|
343
388
|
|
|
389
|
+
// core/values/snippet.ts
|
|
390
|
+
var SNIPPET_LIMIT = 200;
|
|
391
|
+
var CUT_MARK = "\u2026";
|
|
392
|
+
var cutToLimit = (request) => `${request.characters.slice(0, SNIPPET_LIMIT).join("")}${CUT_MARK}`;
|
|
393
|
+
var snippetSchema = external_exports.string().transform((text) => {
|
|
394
|
+
const characters = Array.from(text);
|
|
395
|
+
return characters.length > SNIPPET_LIMIT ? cutToLimit({ characters }) : text;
|
|
396
|
+
});
|
|
397
|
+
|
|
344
398
|
export {
|
|
345
399
|
createDefaultFileTextPort,
|
|
400
|
+
createDefaultFileRemovalPort,
|
|
346
401
|
isRepoPathText,
|
|
347
402
|
repoPathTextSchema,
|
|
348
403
|
brandedRepoPathSchema,
|
|
@@ -352,10 +407,15 @@ export {
|
|
|
352
407
|
createDefaultPathPort,
|
|
353
408
|
NOT_INSTALLED,
|
|
354
409
|
versionSupport,
|
|
410
|
+
gatheredPeerFailure,
|
|
411
|
+
installedPeer,
|
|
355
412
|
loadedPeer,
|
|
356
413
|
installRootAboveEntry,
|
|
357
414
|
moduleExtensionOf,
|
|
358
415
|
installFormOf,
|
|
359
416
|
runnerModuleSegmentsOf,
|
|
360
|
-
moduleFileForm
|
|
417
|
+
moduleFileForm,
|
|
418
|
+
SNIPPET_LIMIT,
|
|
419
|
+
CUT_MARK,
|
|
420
|
+
snippetSchema
|
|
361
421
|
};
|