@avi2dg/checks 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +232 -86
- package/package.json +15 -16
- package/presets/effect.language-service.json +8 -0
- package/presets/effect.oxlint.json +11 -0
- package/quality.schema.json +197 -0
- package/scripts/ci-wiring.ts +16 -43
- package/scripts/commit-identity.ts +4 -33
- package/scripts/gates.ts +15 -15
- package/scripts/lint.ts +7 -17
- package/scripts/quality-file.ts +188 -0
- package/scripts/quality.ts +172 -0
package/README.md
CHANGED
|
@@ -6,8 +6,9 @@ below over a range it resolves itself, the `checks-test` entry point
|
|
|
6
6
|
that runs the suite and refuses an undeclared skip, the `checks-flake`
|
|
7
7
|
run that records the seeds a failing test fails with, the oxlint base
|
|
8
8
|
config, the tsconfig fragment with the Effect language-service block,
|
|
9
|
-
the
|
|
10
|
-
|
|
9
|
+
the `quality.json` schema with the generator that turns its Effect paths
|
|
10
|
+
into oxlint and tsconfig fragments, the shared commitlint config, the
|
|
11
|
+
shared dependency-cruiser base, the test-layout check with its bunfig preset, the commit-identity check, the
|
|
11
12
|
comment gate with its backtest, the oxlint suppressions ratchet, the
|
|
12
13
|
Stryker mutation-testing preset with its no-regression comparator, the
|
|
13
14
|
CI-wiring check, and the Effect error-channel plugin compiled to
|
|
@@ -46,6 +47,17 @@ node_modules/
|
|
|
46
47
|
}
|
|
47
48
|
```
|
|
48
49
|
|
|
50
|
+
`quality.json` at the repository root declares what the repository
|
|
51
|
+
opts into, starting with the commands its CI runs; see "Quality file"
|
|
52
|
+
below:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"$schema": "./node_modules/@avi2dg/checks/quality.schema.json",
|
|
57
|
+
"gates": { "ci": ["bun run lint", "bun run typecheck", "bun run test"] }
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
49
61
|
`bunfig.toml` is a copy of the shipped preset:
|
|
50
62
|
|
|
51
63
|
```sh
|
|
@@ -92,12 +104,148 @@ export default {
|
|
|
92
104
|
The registry version is pinned by the consumer's lockfile; bump
|
|
93
105
|
`@avi2dg/checks` to adopt a new release.
|
|
94
106
|
|
|
107
|
+
## Quality file
|
|
108
|
+
|
|
109
|
+
`quality.json` at the repository root says what the repository has
|
|
110
|
+
opted into. The kit's bins find it at the git root and read it there:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"$schema": "./node_modules/@avi2dg/checks/quality.schema.json",
|
|
115
|
+
"defaultBranch": "main",
|
|
116
|
+
"gates": {
|
|
117
|
+
"ci": ["bun run lint", "bun run typecheck", "bun run test"],
|
|
118
|
+
"scheduled": ["bunx checks-flake --runs 10 --report flake-report.json"]
|
|
119
|
+
},
|
|
120
|
+
"commitIdentity": { "authors": [{ "name": "avi2d", "email": "avi2dg@gmail.com" }] },
|
|
121
|
+
"sources": {
|
|
122
|
+
"production": ["src/**/*.ts"],
|
|
123
|
+
"effect": { "paths": ["src/**/*.ts"], "exempt": ["src/host/*.ts"] }
|
|
124
|
+
},
|
|
125
|
+
"agentRules": { "on": [], "off": [] }
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
| Key | Read by | Holds |
|
|
130
|
+
| --- | --- | --- |
|
|
131
|
+
| `defaultBranch` | `checks-lint`, `checks-ci-wiring` | the branch pull requests merge into, `main` when absent |
|
|
132
|
+
| `gates.ci` | `checks-ci-wiring` | the commands CI runs on every pull request; see "CI wiring" |
|
|
133
|
+
| `gates.scheduled` | `checks-ci-wiring` | the commands a schedule runs |
|
|
134
|
+
| `gates.lint` | `checks-lint`, `checks-ci-wiring` | the gates `checks-lint` runs when not all apply; see "Gate selection" |
|
|
135
|
+
| `commitIdentity.authors` | `checks-commit-identity` | the identities allowed to author and commit; see "Commit identity" |
|
|
136
|
+
| `sources.effect` | `checks-quality` | the paths held to the Effect rules, and the files under them that are not; see "Effect rules" |
|
|
137
|
+
| `sources.production` | no kit gate yet | the source the repository ships |
|
|
138
|
+
| `agentRules.on`, `agentRules.off` | agent Rule selection, not the kit | catalogued Rules switched on or off for this repository |
|
|
139
|
+
|
|
140
|
+
Every key is optional. The bins decode the file with one Effect
|
|
141
|
+
`Schema`, and the package ships `quality.schema.json` emitted from that
|
|
142
|
+
schema, so the `$schema` line gives an editor the verdict the bins
|
|
143
|
+
reach, save one: a Rule switched both on and off, which the bins refuse
|
|
144
|
+
and no JSON Schema can express across two lists. A key the schema does
|
|
145
|
+
not name is refused, not ignored, so a misspelt `sources` cannot switch
|
|
146
|
+
the Effect rules off unnoticed. A glob in `sources`
|
|
147
|
+
starts at the repository root, names a directory first, uses `*`
|
|
148
|
+
only within a segment and `**` only as a whole one, and ends in a file
|
|
149
|
+
name with an extension, which are the globs oxlint, the language
|
|
150
|
+
service and git all read alike. oxlint matches `*.ts` at any depth
|
|
151
|
+
where the other two match it at the root alone, so the schema refuses
|
|
152
|
+
it; `**/*.ts` means every depth to all three. The language service
|
|
153
|
+
matches nothing for `src/**` and oxlint nothing for `src/lib`, so the
|
|
154
|
+
schema refuses both; `src/**/*.ts` and `src/lib/*.ts` say it to all
|
|
155
|
+
three.
|
|
156
|
+
|
|
157
|
+
Until a later minor release, a repository with no `quality.json` still
|
|
158
|
+
has `ciWiring` and `commitIdentity` read from `package.json`, with a
|
|
159
|
+
notice on each read. One with both exits 2 until `package.json` drops
|
|
160
|
+
them. The keys map one for one:
|
|
161
|
+
|
|
162
|
+
| `package.json` | `quality.json` |
|
|
163
|
+
| --- | --- |
|
|
164
|
+
| `ciWiring.gates` | `gates.ci` |
|
|
165
|
+
| `ciWiring.scheduled` | `gates.scheduled` |
|
|
166
|
+
| `ciWiring.lintGates` | `gates.lint` |
|
|
167
|
+
| `ciWiring.defaultBranch` | `defaultBranch` |
|
|
168
|
+
| `commitIdentity` | `commitIdentity` |
|
|
169
|
+
|
|
170
|
+
### Generated fragments
|
|
171
|
+
|
|
172
|
+
oxlint and tsc read their own JSON and nothing else, so
|
|
173
|
+
`checks-quality generate` writes what `sources.effect` declares into two
|
|
174
|
+
fragments at the repository root, and the hand-written configs extend
|
|
175
|
+
them. Both fragments are committed:
|
|
176
|
+
|
|
177
|
+
```sh
|
|
178
|
+
checks-quality generate
|
|
179
|
+
checks-quality --check
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
`.oxlintrc.json`:
|
|
183
|
+
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"extends": ["./node_modules/@avi2dg/checks/oxlintrc.json", "./oxlintrc.quality.json"],
|
|
187
|
+
"plugins": ["typescript", "oxc", "eslint", "import"]
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
`tsconfig.json`:
|
|
192
|
+
|
|
193
|
+
```json
|
|
194
|
+
{
|
|
195
|
+
"extends": ["@avi2dg/checks/tsconfig.effect.json", "./tsconfig.quality.json"]
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
`oxlintrc.quality.json` holds one override: the declared paths as
|
|
200
|
+
`files`, the exempt ones as `excludeFiles`, and the kit's Effect rule
|
|
201
|
+
block, `presets/effect.oxlint.json`. `tsconfig.quality.json` holds the
|
|
202
|
+
language-service override: the same paths as `include`, the exempt ones
|
|
203
|
+
as `exclude`, and `presets/effect.language-service.json`. A kit release
|
|
204
|
+
that changes a preset reaches the repository through its next
|
|
205
|
+
`generate`. A rule only this repository needs stays in its own
|
|
206
|
+
`.oxlintrc.json`, whose overrides come after the fragment's and so win.
|
|
207
|
+
|
|
208
|
+
`checks-lint` runs `checks-quality --check`, which exits 1 when:
|
|
209
|
+
|
|
210
|
+
- a fragment is missing, or differs from what `generate` would write
|
|
211
|
+
from `quality.json` and the installed kit's presets;
|
|
212
|
+
- a fragment is left over once `quality.json` stops declaring
|
|
213
|
+
`sources.effect`;
|
|
214
|
+
- `.oxlintrc.json` or `tsconfig.json` does not list its fragment in
|
|
215
|
+
`extends`, so the tool never reads it;
|
|
216
|
+
- a `sources.effect.paths` glob matches no tracked or untracked file,
|
|
217
|
+
so it holds nothing to the rules.
|
|
218
|
+
|
|
219
|
+
It exits 2 when `quality.json` does not decode. `generate` writes the
|
|
220
|
+
fragments, removes a left-over one, then runs the same check.
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
checks-quality: 2 problem(s) with what quality.json declares:
|
|
224
|
+
oxlintrc.quality.json is stale against quality.json and the kit's presets; run checks-quality generate
|
|
225
|
+
tsconfig.json does not extend ./tsconfig.quality.json, so the language service never reads it
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Two details of the fragments are easy to get wrong, so the kit's tests
|
|
229
|
+
pin both:
|
|
230
|
+
|
|
231
|
+
- A fragment sits at the repository root. oxlint resolves an
|
|
232
|
+
override's `files`, and the language service an override's `include`,
|
|
233
|
+
against the directory of the config holding it. From `.quality/` the
|
|
234
|
+
language service reports no error at all on an `async function`
|
|
235
|
+
planted under a declared path.
|
|
236
|
+
- The oxlint fragment always sets `plugins`, to the kit's. A config in
|
|
237
|
+
`extends` that sets none brings in oxlint's default plugins, whose
|
|
238
|
+
category rules then fire across the whole tree. The override names
|
|
239
|
+
the kit's plugins beside the preset's `node`, `promise` and `unicorn`,
|
|
240
|
+
because one that leaves any of the kit's out turns on the category
|
|
241
|
+
rules of the plugins it adds under every declared path.
|
|
242
|
+
|
|
95
243
|
## Lint entry point
|
|
96
244
|
|
|
97
245
|
`checks-lint` runs each of the kit's lint gates in turn and names every
|
|
98
246
|
one that fails, rather than stopping at the first. A repository whose
|
|
99
247
|
tracked files give a gate nothing to check can leave it out through
|
|
100
|
-
`
|
|
248
|
+
`gates.lint`; see "Gate selection" under "CI wiring".
|
|
101
249
|
|
|
102
250
|
| Gate | Reads |
|
|
103
251
|
| --- | --- |
|
|
@@ -107,6 +255,7 @@ tracked files give a gate nothing to check can leave it out through
|
|
|
107
255
|
| `checks-comment-gate` | the range |
|
|
108
256
|
| `checks-suppressions-ratchet` | the range |
|
|
109
257
|
| `checks-ci-wiring` | the working tree |
|
|
258
|
+
| `checks-quality` | the working tree |
|
|
110
259
|
|
|
111
260
|
```sh
|
|
112
261
|
checks-lint
|
|
@@ -117,8 +266,8 @@ It resolves the range once and hands the same one to every range gate.
|
|
|
117
266
|
Locally, and on any event other than a pull request, the range ends at
|
|
118
267
|
`HEAD` and starts where `HEAD` branched from the origin default branch:
|
|
119
268
|
`origin/HEAD`, or when `origin/HEAD` is not set, as in an
|
|
120
|
-
`actions/checkout` clone, `origin/<
|
|
121
|
-
repository's `
|
|
269
|
+
`actions/checkout` clone, `origin/<defaultBranch>` from the
|
|
270
|
+
repository's `quality.json` (see "Quality file"), and `origin/main` when
|
|
122
271
|
that is not declared. In a GitHub Actions pull request, where
|
|
123
272
|
`GITHUB_EVENT_NAME` is `pull_request`, it ends
|
|
124
273
|
at the event's head sha and starts where that branched from
|
|
@@ -159,12 +308,12 @@ gate's own report, then its verdict:
|
|
|
159
308
|
```
|
|
160
309
|
checks-lint: range 2504acf098d120e73a8ece3c96f22b934f35c6a8..10ba7d8935b73ed72624120a1542e51bd21ca7c7 from HEAD against origin/main
|
|
161
310
|
...
|
|
162
|
-
checks-lint: 3 of
|
|
311
|
+
checks-lint: 3 of 7 gate(s) failed: checks-commit-identity, checks-comment-gate, checks-suppressions-ratchet
|
|
163
312
|
```
|
|
164
313
|
|
|
165
314
|
It exits 1 when any gate found a violation, and 2 when the range or the
|
|
166
315
|
selection does not resolve, or no failing gate could decide. ci-wiring
|
|
167
|
-
always runs, so a repository on `checks-lint` declares `
|
|
316
|
+
always runs, so a repository on `checks-lint` declares `gates.ci`
|
|
168
317
|
(see "CI wiring"), and it holds the test layout unless its selection
|
|
169
318
|
leaves out `checks-test-layout`.
|
|
170
319
|
|
|
@@ -205,69 +354,43 @@ Each refusal says what to write instead: a `Schema.TaggedError` failed
|
|
|
205
354
|
through `Effect.fail`, a throwing call wrapped in `Effect.try` or
|
|
206
355
|
`Effect.tryPromise`, and recovery by tag with `Effect.catchTag`.
|
|
207
356
|
|
|
208
|
-
A repository turns them on for the paths it writes in Effect
|
|
209
|
-
`
|
|
357
|
+
A repository turns them on for the paths it writes in Effect by
|
|
358
|
+
declaring those paths in `quality.json` and extending the generated
|
|
359
|
+
fragments; see "Generated fragments" under "Quality file":
|
|
210
360
|
|
|
211
361
|
```json
|
|
212
|
-
{
|
|
213
|
-
"
|
|
214
|
-
"plugins": ["typescript", "oxc", "eslint", "import"],
|
|
215
|
-
"overrides": [
|
|
216
|
-
{
|
|
217
|
-
"files": ["src/**"],
|
|
218
|
-
"rules": {
|
|
219
|
-
"effect-channel/no-throw": "error",
|
|
220
|
-
"effect-channel/no-try-catch": "error"
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
]
|
|
362
|
+
"sources": {
|
|
363
|
+
"effect": { "paths": ["src/**/*.ts"], "exempt": ["src/host/*.ts"] }
|
|
224
364
|
}
|
|
225
365
|
```
|
|
226
366
|
|
|
367
|
+
The fragment's override carries the kit's Effect rule block,
|
|
368
|
+
`presets/effect.oxlint.json`: the two rules above, plus `node/no-sync`,
|
|
369
|
+
`oxc/no-async-await`, `promise/avoid-new` and `unicorn/no-process-exit`.
|
|
370
|
+
Files under `exempt` answer to none of them.
|
|
371
|
+
|
|
227
372
|
oxlint resolves `files` against the directory of the config that holds
|
|
228
373
|
the override, so a config passed with `-c` from outside the repository
|
|
229
374
|
matches nothing and reports nothing.
|
|
230
375
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
a
|
|
236
|
-
|
|
237
|
-
baseline, `oxlint --suppress-all`,
|
|
238
|
-
|
|
239
|
-
|
|
376
|
+
`unicorn/no-process-exit` passes over any file that opens with a
|
|
377
|
+
shebang, so a repository whose bins open with one bans `process.exit`
|
|
378
|
+
itself with `no-restricted-properties` in its own `.oxlintrc.json`, as
|
|
379
|
+
this one does. The preset leaves that rule out because
|
|
380
|
+
a repository's own `no-restricted-properties` list for the same files
|
|
381
|
+
would replace it, or be replaced by it. Sites standing when the
|
|
382
|
+
declaration lands go in oxlint's own baseline, `oxlint --suppress-all`,
|
|
383
|
+
so their count can only fall. This repository's own `.oxlintrc.json`
|
|
384
|
+
also lifts `effect-channel/no-throw` from `scripts/comment-matchers.ts`,
|
|
385
|
+
the one file under its Effect path that a host loads without
|
|
386
|
+
`node_modules`.
|
|
240
387
|
|
|
241
388
|
The language service holds the same paths to Effect-native IO through
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
{
|
|
248
|
-
"extends": "@avi2dg/checks/tsconfig.effect.json",
|
|
249
|
-
"compilerOptions": {
|
|
250
|
-
"plugins": [
|
|
251
|
-
{
|
|
252
|
-
"name": "@effect/language-service",
|
|
253
|
-
"overrides": [
|
|
254
|
-
{
|
|
255
|
-
"include": ["src/**/*.ts"],
|
|
256
|
-
"options": {
|
|
257
|
-
"diagnosticSeverity": {
|
|
258
|
-
"nodeBuiltinImport": "error",
|
|
259
|
-
"asyncFunction": "error",
|
|
260
|
-
"newPromise": "error",
|
|
261
|
-
"extendsNativeError": "error"
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
]
|
|
266
|
-
}
|
|
267
|
-
]
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
```
|
|
389
|
+
the tsconfig fragment's override, whose severities are
|
|
390
|
+
`presets/effect.language-service.json`: `nodeBuiltinImport`,
|
|
391
|
+
`asyncFunction`, `newPromise` and `extendsNativeError`, all errors.
|
|
392
|
+
effect-tsgo keeps the severities `tsconfig.effect.json` sets when a later
|
|
393
|
+
config in `extends` restates the plugin with only its overrides.
|
|
271
394
|
|
|
272
395
|
## Test layout
|
|
273
396
|
|
|
@@ -412,7 +535,7 @@ jobs:
|
|
|
412
535
|
path: flake-report.json
|
|
413
536
|
```
|
|
414
537
|
|
|
415
|
-
and declares the step in `
|
|
538
|
+
and declares the step in `gates.scheduled`, so `checks-ci-wiring`
|
|
416
539
|
fails once the schedule stops running it; see "CI wiring".
|
|
417
540
|
|
|
418
541
|
## Dependency rules
|
|
@@ -520,7 +643,7 @@ body are left alone. `GitHub <noreply@github.com>` is allowed as
|
|
|
520
643
|
committer only, since that is who writes a squash merge.
|
|
521
644
|
|
|
522
645
|
The allowlist defaults to `avi2d <avi2dg@gmail.com>`. A repo with other
|
|
523
|
-
owners restates it in `
|
|
646
|
+
owners restates it in `quality.json`:
|
|
524
647
|
|
|
525
648
|
```json
|
|
526
649
|
"commitIdentity": {
|
|
@@ -601,13 +724,17 @@ longer runs on pull requests to the default branch. No local check sees
|
|
|
601
724
|
that: a workflow whose lint step became a no-op leaves `bun run lint`
|
|
602
725
|
green.
|
|
603
726
|
|
|
604
|
-
The repository declares its gates once, in `
|
|
605
|
-
|
|
727
|
+
The repository declares its gates once, in `quality.json`:
|
|
728
|
+
|
|
729
|
+
```json
|
|
730
|
+
"gates": {
|
|
731
|
+
"ci": ["bun run lint", "bun run typecheck", "bun run test"]
|
|
732
|
+
}
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
and `package.json` runs the check through `checks-lint`:
|
|
606
736
|
|
|
607
737
|
```json
|
|
608
|
-
"ciWiring": {
|
|
609
|
-
"gates": ["bun run lint", "bun run typecheck", "bun run test"]
|
|
610
|
-
},
|
|
611
738
|
"scripts": {
|
|
612
739
|
"lint": "oxlint --type-aware && checks-lint"
|
|
613
740
|
}
|
|
@@ -649,11 +776,11 @@ one of the gates `checks-lint` runs by its bare bin name, when the step
|
|
|
649
776
|
calls `checks-lint` the same way: `bunx checks-lint` counts for
|
|
650
777
|
`bunx checks-comment-gate "origin/$BASE_REF" "$HEAD_SHA"`. A step running `bun run lint` counts only for the `bun run lint` gate,
|
|
651
778
|
since the check never reads what a package script runs. So once `lint`
|
|
652
|
-
runs `checks-lint`, the per-gate entries can leave `
|
|
779
|
+
runs `checks-lint`, the per-gate entries can leave `gates.ci`
|
|
653
780
|
along with the workflows that ran them.
|
|
654
781
|
|
|
655
782
|
The default branch is `main`; a repo with another one sets
|
|
656
|
-
`"defaultBranch"`
|
|
783
|
+
`"defaultBranch"` in `quality.json`, which `checks-lint` also reads when
|
|
657
784
|
`origin/HEAD` is not set.
|
|
658
785
|
|
|
659
786
|
It exits 1 naming each gap, with every step that runs the gate and why
|
|
@@ -665,17 +792,17 @@ ci-wiring: 1 of 8 gate(s) do not run on pull requests to main:
|
|
|
665
792
|
.github/workflows/release.yml job publish step 7: .github/workflows/release.yml does not trigger on pull_request
|
|
666
793
|
```
|
|
667
794
|
|
|
668
|
-
It exits 2 when `
|
|
669
|
-
|
|
795
|
+
It exits 2 when `quality.json` declares no `gates.ci` or does not
|
|
796
|
+
decode, a gate or scheduled command is not one plain command, or a
|
|
670
797
|
workflow does not parse. Whether a workflow is well formed is
|
|
671
798
|
actionlint's question, not this one's.
|
|
672
799
|
|
|
673
800
|
A command a schedule must run, such as the flake run, goes in
|
|
674
|
-
`
|
|
801
|
+
`gates.scheduled`:
|
|
675
802
|
|
|
676
803
|
```json
|
|
677
|
-
"
|
|
678
|
-
"
|
|
804
|
+
"gates": {
|
|
805
|
+
"ci": ["bun run lint", "bun run typecheck", "bun run test"],
|
|
679
806
|
"scheduled": ["bunx checks-flake --runs 10 --report flake-report.json"]
|
|
680
807
|
}
|
|
681
808
|
```
|
|
@@ -696,23 +823,26 @@ ci-wiring: 1 of 1 scheduled command(s) do not run on a schedule:
|
|
|
696
823
|
A repository with no TypeScript source gives `checks-lint-coverage` and
|
|
697
824
|
`checks-test-layout` nothing to check, and test-layout still refuses its
|
|
698
825
|
missing `bun test` script and `bunfig.toml`. It declares the gates
|
|
699
|
-
`checks-lint` runs as `
|
|
826
|
+
`checks-lint` runs as `gates.lint`:
|
|
700
827
|
|
|
701
828
|
```json
|
|
702
|
-
"
|
|
703
|
-
"
|
|
704
|
-
"
|
|
829
|
+
"gates": {
|
|
830
|
+
"ci": ["bun run lint"],
|
|
831
|
+
"lint": [
|
|
705
832
|
"checks-commit-identity",
|
|
706
833
|
"checks-comment-gate",
|
|
707
834
|
"checks-suppressions-ratchet",
|
|
708
|
-
"checks-ci-wiring"
|
|
835
|
+
"checks-ci-wiring",
|
|
836
|
+
"checks-quality"
|
|
709
837
|
]
|
|
710
838
|
}
|
|
711
839
|
```
|
|
712
840
|
|
|
713
841
|
`checks-lint` runs exactly those, in the "Lint entry point" table's
|
|
714
|
-
order, and all
|
|
715
|
-
`
|
|
842
|
+
order, and all seven when `gates.lint` is absent. A selection in
|
|
843
|
+
`quality.json` always keeps `checks-quality`, since the file it sits in
|
|
844
|
+
is what makes that gate apply. A step running
|
|
845
|
+
`checks-lint` then counts only for a declared gate that `gates.lint`
|
|
716
846
|
keeps.
|
|
717
847
|
|
|
718
848
|
A selection may leave out only a gate that does not apply:
|
|
@@ -725,14 +855,15 @@ A selection may leave out only a gate that does not apply:
|
|
|
725
855
|
| `checks-comment-gate` | always |
|
|
726
856
|
| `checks-suppressions-ratchet` | always |
|
|
727
857
|
| `checks-ci-wiring` | always |
|
|
858
|
+
| `checks-quality` | tracks a `quality.json` |
|
|
728
859
|
|
|
729
|
-
Both bins exit 2 on a `
|
|
860
|
+
Both bins exit 2 on a `gates.lint` that names an unknown gate or leaves
|
|
730
861
|
out one that always applies. ci-wiring exits 1 when the
|
|
731
862
|
selection leaves out a gate the repository's tracked files make
|
|
732
863
|
applicable, and names the gate and the files:
|
|
733
864
|
|
|
734
865
|
```
|
|
735
|
-
ci-wiring:
|
|
866
|
+
ci-wiring: quality.json gates.lint leaves out 2 gate(s) this repository's contents make applicable:
|
|
736
867
|
checks-lint-coverage: the repository tracks TypeScript source (src/widget.ts)
|
|
737
868
|
checks-test-layout: the repository tracks TypeScript source (src/widget.ts)
|
|
738
869
|
```
|
|
@@ -819,9 +950,12 @@ The shared Stryker preset's `json` reporter writes
|
|
|
819
950
|
|
|
820
951
|
## Why it is shaped this way
|
|
821
952
|
|
|
822
|
-
-
|
|
823
|
-
|
|
824
|
-
|
|
953
|
+
- Every config in an oxlint `extends` chain brings its own `plugins`,
|
|
954
|
+
and one that sets none brings oxlint's default plugins, whose
|
|
955
|
+
category rules the base's `categories` then turn on across the tree.
|
|
956
|
+
`rules`, `categories` and `jsPlugins` inherit as expected. That is why
|
|
957
|
+
the consumer snippet restates `plugins` and nothing else, and why the
|
|
958
|
+
generated fragment always sets them.
|
|
825
959
|
- `node_modules/` is excluded through the consumer's `.gitignore`, not
|
|
826
960
|
`ignorePatterns`: oxlint still walks the installed package when only
|
|
827
961
|
`ignorePatterns` names it.
|
|
@@ -837,7 +971,19 @@ The shared Stryker preset's `json` reporter writes
|
|
|
837
971
|
- `dist/` is committed. No `prepack` or `prepublishOnly` builds it, so a
|
|
838
972
|
publish ships whatever bundle the publishing worktree holds. Rebuild it
|
|
839
973
|
after pulling with `bun run build`; CI fails when the committed bundle
|
|
840
|
-
is stale.
|
|
974
|
+
is stale. `bun run build` also emits `quality.schema.json`, which is
|
|
975
|
+
committed the same way, and a test fails when it differs from what
|
|
976
|
+
the schema emits.
|
|
977
|
+
- `quality.json` is JSON, not TOML or a TypeScript module: a bun bin, a
|
|
978
|
+
hook running without `node_modules`, a `.cjs` or `.mjs` config and
|
|
979
|
+
`jq` all parse it with nothing installed, and nobody runs a
|
|
980
|
+
repository's own code to learn its policy. It holds declarations
|
|
981
|
+
only. The kit's bins read it directly; oxlint and tsc read nothing but
|
|
982
|
+
their own JSON, so they extend generated fragments, which
|
|
983
|
+
`checks-quality --check` holds to the declarations.
|
|
984
|
+
- `quality.json` refuses a key its schema does not name, so a kit that
|
|
985
|
+
cannot enforce a newer key refuses it rather than let the repository
|
|
986
|
+
believe it enforced.
|
|
841
987
|
- The base parses with swc because typescript 7 (tsgo) has no compiler
|
|
842
988
|
API for dependency-cruiser to use. Without `@swc/core` installed the
|
|
843
989
|
cruise silently skips every `.ts` file, so this repo's test asserts its
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avi2dg/checks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Deterministic checks shared across the captain's TypeScript repos",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,6 +32,11 @@
|
|
|
32
32
|
"scripts/comment-gate.ts",
|
|
33
33
|
"scripts/suppressions-ratchet.ts",
|
|
34
34
|
"scripts/backtest.ts",
|
|
35
|
+
"scripts/quality-file.ts",
|
|
36
|
+
"scripts/quality.ts",
|
|
37
|
+
"presets/effect.oxlint.json",
|
|
38
|
+
"presets/effect.language-service.json",
|
|
39
|
+
"quality.schema.json",
|
|
35
40
|
"oxlintrc.json",
|
|
36
41
|
"stryker.preset.js",
|
|
37
42
|
"tsconfig.effect.json",
|
|
@@ -54,6 +59,11 @@
|
|
|
54
59
|
"./scripts/comment-gate.ts": "./scripts/comment-gate.ts",
|
|
55
60
|
"./scripts/suppressions-ratchet.ts": "./scripts/suppressions-ratchet.ts",
|
|
56
61
|
"./scripts/backtest.ts": "./scripts/backtest.ts",
|
|
62
|
+
"./scripts/quality-file.ts": "./scripts/quality-file.ts",
|
|
63
|
+
"./scripts/quality.ts": "./scripts/quality.ts",
|
|
64
|
+
"./presets/effect.oxlint.json": "./presets/effect.oxlint.json",
|
|
65
|
+
"./presets/effect.language-service.json": "./presets/effect.language-service.json",
|
|
66
|
+
"./quality.schema.json": "./quality.schema.json",
|
|
57
67
|
"./oxlintrc.json": "./oxlintrc.json",
|
|
58
68
|
"./stryker.preset.js": "./stryker.preset.js",
|
|
59
69
|
"./tsconfig.effect.json": "./tsconfig.effect.json",
|
|
@@ -70,27 +80,15 @@
|
|
|
70
80
|
"checks-ci-wiring": "scripts/ci-wiring.ts",
|
|
71
81
|
"checks-comment-gate": "scripts/comment-gate.ts",
|
|
72
82
|
"checks-suppressions-ratchet": "scripts/suppressions-ratchet.ts",
|
|
73
|
-
"checks-backtest": "scripts/backtest.ts"
|
|
83
|
+
"checks-backtest": "scripts/backtest.ts",
|
|
84
|
+
"checks-quality": "scripts/quality.ts"
|
|
74
85
|
},
|
|
75
86
|
"scripts": {
|
|
76
|
-
"build": "bun build effect-channel/index.ts --outdir dist --target node --format esm",
|
|
87
|
+
"build": "bun build effect-channel/index.ts --outdir dist --target node --format esm && bun scripts/quality-schema.ts",
|
|
77
88
|
"lint": "oxlint --type-aware && bun scripts/lint.ts && depcruise --config .dependency-cruiser.cjs .",
|
|
78
89
|
"typecheck": "tsc --noEmit && effect-tsgo diagnostics --project tsconfig.json --format text --strict",
|
|
79
90
|
"test": "bun scripts/test.ts"
|
|
80
91
|
},
|
|
81
|
-
"ciWiring": {
|
|
82
|
-
"gates": [
|
|
83
|
-
"bun run build",
|
|
84
|
-
"git diff --exit-code dist/",
|
|
85
|
-
"bun run lint",
|
|
86
|
-
"bun run typecheck",
|
|
87
|
-
"bun run test",
|
|
88
|
-
"./node_modules/.bin/commitlint"
|
|
89
|
-
],
|
|
90
|
-
"scheduled": [
|
|
91
|
-
"bun scripts/flake.ts --runs 10 --report flake-report.json"
|
|
92
|
-
]
|
|
93
|
-
},
|
|
94
92
|
"peerDependencies": {
|
|
95
93
|
"@swc/core": "1.16.2",
|
|
96
94
|
"dependency-cruiser": "18.4.0",
|
|
@@ -104,6 +102,7 @@
|
|
|
104
102
|
"@oxlint/plugins": "1.83.0",
|
|
105
103
|
"@swc/core": "1.16.2",
|
|
106
104
|
"@types/bun": "^1.3.0",
|
|
105
|
+
"ajv": "8.20.0",
|
|
107
106
|
"dependency-cruiser": "18.4.0",
|
|
108
107
|
"effect": "4.0.0-rc.115",
|
|
109
108
|
"oxlint": "1.83.0",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"plugins": ["node", "promise", "unicorn"],
|
|
3
|
+
"rules": {
|
|
4
|
+
"node/no-sync": "error",
|
|
5
|
+
"oxc/no-async-await": "error",
|
|
6
|
+
"promise/avoid-new": "error",
|
|
7
|
+
"unicorn/no-process-exit": "error",
|
|
8
|
+
"effect-channel/no-throw": "error",
|
|
9
|
+
"effect-channel/no-try-catch": "error"
|
|
10
|
+
}
|
|
11
|
+
}
|