@avi2dg/checks 0.20.0 → 0.22.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/CHANGELOG.md +65 -39
- package/CONTRIBUTING.md +11 -8
- package/README.md +15 -24
- package/bunfig.toml +1 -1
- package/docs/configs/commit-messages.md +5 -1
- package/docs/configs/dependency-rules.md +5 -2
- package/docs/configs/effect-rules.md +32 -33
- package/docs/configs/native-settings.md +74 -0
- package/docs/configs/typescript-rules.md +4 -0
- package/docs/design.md +24 -25
- package/docs/gates/checks-backtest.md +4 -0
- package/docs/gates/checks-ci-wiring.md +30 -93
- package/docs/gates/checks-comment-gate.md +4 -0
- package/docs/gates/checks-commit-identity.md +23 -27
- package/docs/gates/checks-docs.md +23 -21
- package/docs/gates/checks-flake.md +4 -10
- package/docs/gates/checks-lint-coverage.md +5 -1
- package/docs/gates/checks-lint.md +22 -104
- package/docs/gates/checks-mutation-compare.md +4 -0
- package/docs/gates/checks-quarantine-clock.md +4 -0
- package/docs/gates/checks-repetition.md +26 -41
- package/docs/gates/checks-subsumed-tests.md +4 -0
- package/docs/gates/checks-suppressions-ratchet.md +4 -0
- package/docs/gates/checks-test-layout.md +16 -8
- package/docs/gates/checks-test.md +68 -36
- package/docs/gates/checks-vendor.md +20 -13
- package/package.json +8 -21
- package/scripts/ci-wiring.ts +28 -97
- package/scripts/commit-identity.ts +32 -4
- package/scripts/doc-rules.ts +26 -11
- package/scripts/doc-templates.ts +2 -1
- package/scripts/docs.ts +4 -7
- package/scripts/gates.ts +0 -29
- package/scripts/git.ts +24 -1
- package/scripts/lint.ts +15 -34
- package/scripts/range-gate.ts +1 -2
- package/scripts/repetition.ts +40 -40
- package/scripts/shell-command.ts +7 -1
- package/scripts/swc.ts +46 -0
- package/scripts/test-layout.ts +40 -56
- package/scripts/test-skips.ts +180 -0
- package/scripts/test.ts +33 -38
- package/scripts/vendor.ts +55 -11
- package/dist/feature-rules.js +0 -349
- package/docs/configs/quality-file.md +0 -101
- package/docs/gates/checks-feature-owners.md +0 -113
- package/docs/gates/checks-quality.md +0 -109
- package/docs/gates/checks-size-budget.md +0 -107
- package/quality.schema.json +0 -496
- package/scripts/feature-owners.ts +0 -139
- package/scripts/quality-file.ts +0 -347
- package/scripts/quality.ts +0 -342
- package/scripts/size-budget.ts +0 -285
- package/scripts/size-rules.ts +0 -126
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
# checks-quality
|
|
2
|
-
|
|
3
|
-
`checks-quality` is the bin that writes what `quality.json` declares into generated fragments and workflows and checks them, and a reader looks it up when generated text is stale.
|
|
4
|
-
|
|
5
|
-
## What it checks
|
|
6
|
-
|
|
7
|
-
oxlint and tsc read their own JSON and nothing else, so `checks-quality generate` writes what `sources.effect` declares into two fragments at the repository root, and the hand-written configs extend them.
|
|
8
|
-
Both fragments are committed.
|
|
9
|
-
|
|
10
|
-
`oxlintrc.quality.json` holds one override: the declared paths as `files`, the exempt ones as `excludeFiles`, and the kit's Effect rule block, `presets/effect.oxlint.json`.
|
|
11
|
-
`tsconfig.quality.json` holds the language-service override: the same paths as `include`, the exempt ones as `exclude`, and `presets/effect.language-service.json`.
|
|
12
|
-
A kit release that changes a preset reaches the repository through its next `generate`.
|
|
13
|
-
A rule only this repository needs stays in its own `.oxlintrc.json`, whose overrides come after the fragment's and so win.
|
|
14
|
-
|
|
15
|
-
`.oxlintrc.json` extends its fragment:
|
|
16
|
-
|
|
17
|
-
```json
|
|
18
|
-
{
|
|
19
|
-
"extends": ["./node_modules/@avi2dg/checks/oxlintrc.json", "./oxlintrc.quality.json"],
|
|
20
|
-
"plugins": ["typescript", "oxc", "eslint", "import"]
|
|
21
|
-
}
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
`tsconfig.json` extends its fragment:
|
|
25
|
-
|
|
26
|
-
```json
|
|
27
|
-
{
|
|
28
|
-
"extends": ["@avi2dg/checks/tsconfig.effect.json", "./tsconfig.quality.json"]
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
GitHub Actions reads its own YAML and nothing else, so `checks-quality generate` also writes the kit recipe workflows whole.
|
|
33
|
-
`.github/workflows/ci.yml` runs every `gates.ci` command but the title lint as its own step after a frozen install.
|
|
34
|
-
`.github/workflows/commitlint.yml` lints the pull request title with the installed kit config.
|
|
35
|
-
A step one repository alone needs lives in another workflow file, never in the recipe.
|
|
36
|
-
All generated workflows are committed.
|
|
37
|
-
|
|
38
|
-
`checks-quality --check` fails when any of these holds:
|
|
39
|
-
|
|
40
|
-
- A fragment is missing, or differs from what `generate` would write from `quality.json` and the installed kit's presets.
|
|
41
|
-
- A fragment is left over once `quality.json` stops declaring `sources.effect`.
|
|
42
|
-
- A generated workflow is missing, or differs from what `generate` would write from `quality.json` and the kit recipe.
|
|
43
|
-
- `.oxlintrc.json` or `tsconfig.json` does not list its fragment in `extends`, so the tool never reads it.
|
|
44
|
-
- `.oxlintrc.json` does not extend `./node_modules/@avi2dg/checks/oxlintrc.json`, so the kit's oxlint rules are not loaded.
|
|
45
|
-
- `tsconfig.json` does not extend `@avi2dg/checks/tsconfig.effect.json`, the one accepted spelling of the kit's Effect config.
|
|
46
|
-
- A `sources.effect.paths` or `sources.production` glob matches no tracked or untracked file, so it holds nothing.
|
|
47
|
-
|
|
48
|
-
Two details of the fragments are easy to get wrong, so the kit's tests pin both:
|
|
49
|
-
|
|
50
|
-
- A fragment sits at the repository root.
|
|
51
|
-
oxlint resolves an override's `files`, and the language service an override's `include`, against the directory of the config holding it.
|
|
52
|
-
From `.quality/` the language service reports no error at all on an `async function` planted under a declared path.
|
|
53
|
-
- The oxlint fragment always sets `plugins`, to the kit's.
|
|
54
|
-
A config in `extends` that sets none brings in oxlint's default plugins, whose category rules then fire across the whole tree.
|
|
55
|
-
The override names the kit's plugins beside the preset's `node`, `promise` and `unicorn`, because one that leaves any of the kit's out turns on the category rules of the plugins it adds under every declared path.
|
|
56
|
-
|
|
57
|
-
## What it reads
|
|
58
|
-
|
|
59
|
-
It reads the working tree: `quality.json`, the presets of the installed kit, `.oxlintrc.json`, `tsconfig.json`, the two fragments and the generated workflows.
|
|
60
|
-
It reads the root `package.json` name, since only the kit's own tree lints titles with its root `commitlint.config.js`.
|
|
61
|
-
The name also decides which kit configs `extends` must list, since the kit's own tree extends its root `oxlintrc.json` and `tsconfig.effect.json`.
|
|
62
|
-
It looks for `.bun-version` and `.node-version`, and the suite pins its bun and its node to whichever of the two files exists.
|
|
63
|
-
It lists the tracked and untracked files to see what each declared glob matches.
|
|
64
|
-
|
|
65
|
-
## Arguments
|
|
66
|
-
|
|
67
|
-
```sh
|
|
68
|
-
checks-quality generate
|
|
69
|
-
checks-quality --check
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
`generate` writes the fragments and the workflows, removes a left-over one, then runs the same check as `--check`.
|
|
73
|
-
`--check` writes nothing.
|
|
74
|
-
|
|
75
|
-
## Exit codes
|
|
76
|
-
|
|
77
|
-
| Code | When |
|
|
78
|
-
| --- | --- |
|
|
79
|
-
| 0 | the generated files hold what `quality.json` declares |
|
|
80
|
-
| 1 | a generated file is stale, missing or left over, a fragment is not extended, the kit's config is not extended, or a declared glob matches no file |
|
|
81
|
-
| 2 | `quality.json` does not decode, or the arguments are neither `generate` nor `--check` |
|
|
82
|
-
|
|
83
|
-
## Sample output
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
checks-quality: 2 problem(s) with what quality.json declares:
|
|
87
|
-
oxlintrc.quality.json is stale against quality.json and the kit's presets; run checks-quality generate
|
|
88
|
-
tsconfig.json does not extend ./tsconfig.quality.json, so the language service never reads it
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
A passing run says what the generated files hold:
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
checks-quality: oxlintrc.quality.json and tsconfig.quality.json and .github/workflows/ci.yml and .github/workflows/commitlint.yml hold what quality.json declares
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
A stale workflow is reported the same way as a stale fragment.
|
|
98
|
-
|
|
99
|
-
## Opting out
|
|
100
|
-
|
|
101
|
-
It runs only in a repository that tracks `quality.json`, and a selection in `quality.json` always keeps it, since the file it sits in is what makes it apply.
|
|
102
|
-
A repository that declares no `sources.effect` gets no fragment, and the check then refuses a left-over one.
|
|
103
|
-
Every repository gets the title lint workflow, and one with `gates.ci` gets the suite with it.
|
|
104
|
-
|
|
105
|
-
## Related topics
|
|
106
|
-
|
|
107
|
-
- [The quality file](../configs/quality-file.md)
|
|
108
|
-
- [The Effect rules](../configs/effect-rules.md)
|
|
109
|
-
- [checks-lint](checks-lint.md)
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# checks-size-budget
|
|
2
|
-
|
|
3
|
-
`checks-size-budget` is the gate that holds production and test files to the size budget `quality.json` declares, and a reader looks it up when a file or a function runs over it.
|
|
4
|
-
|
|
5
|
-
## What it checks
|
|
6
|
-
|
|
7
|
-
It holds production and test files to the size budget, and lists every other file over it without failing:
|
|
8
|
-
|
|
9
|
-
```json
|
|
10
|
-
"sources": { "production": ["src/**/*.ts"] },
|
|
11
|
-
"size": { "applies": "ratchet" }
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
A production file is one under `sources.production`, and a test file is a tracked `.ts` or `.tsx` file under `tests/`.
|
|
15
|
-
A test file keeps to the tests budget, and every other file keeps to the production budget.
|
|
16
|
-
It runs oxlint with a configuration of five rules, one for each limit, and the kit's own plugin bundle, which holds the complexity rule.
|
|
17
|
-
The kit sets each limit:
|
|
18
|
-
|
|
19
|
-
<!-- generated size-limits: bun run build writes it from SIZE_RULES and SIZE_DEFAULTS in scripts/size-rules.ts and scripts/doc-blocks.ts -->
|
|
20
|
-
|
|
21
|
-
| Key | Limits | oxlint rule | Production | Tests |
|
|
22
|
-
| --- | --- | --- | --- | --- |
|
|
23
|
-
| `fileLines` | The most lines a file may hold, blank and comment lines counted | `max-lines` | 400 | 600 |
|
|
24
|
-
| `functionLines` | The most lines a function may span, blank and comment lines counted | `max-lines-per-function` | 100 | none |
|
|
25
|
-
| `statements` | The most statements a function may hold | `max-statements` | 30 | 50 |
|
|
26
|
-
| `complexity` | The highest cognitive complexity a function may reach, a switch counted once | `effect-channel/cognitive-complexity` | 15 | 15 |
|
|
27
|
-
| `depth` | The deepest a block may nest inside a function | `max-depth` | 4 | 4 |
|
|
28
|
-
|
|
29
|
-
<!-- end generated size-limits -->
|
|
30
|
-
|
|
31
|
-
`size.production` and `size.tests` state only a limit that differs from the kit's:
|
|
32
|
-
|
|
33
|
-
```json
|
|
34
|
-
"size": {
|
|
35
|
-
"applies": "ratchet",
|
|
36
|
-
"production": { "complexity": 12 },
|
|
37
|
-
"tests": { "fileLines": 800 }
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
`applies` decides which files the gate holds and what fails them:
|
|
42
|
-
|
|
43
|
-
- `ratchet` holds each production and test file the range adds or changes, a rename that edits the file included.
|
|
44
|
-
For each file and each rule, it sums how far every site runs over its limit, and fails when that sum is higher at the head than at the base of the range.
|
|
45
|
-
A file the range adds starts from zero, so it has to keep within the budget.
|
|
46
|
-
A file already over the budget passes while its overrun does not grow, and an edit that shrinks the overrun passes.
|
|
47
|
-
An edited rename is compared with the file it was renamed from.
|
|
48
|
-
Nothing is committed as a baseline, because the base of the range holds it.
|
|
49
|
-
- `all` holds every production and test file, and fails on any overrun in them.
|
|
50
|
-
|
|
51
|
-
`applies` is `ratchet` when `size` leaves it out.
|
|
52
|
-
A file the range deletes or only renames is not held.
|
|
53
|
-
Every other tracked `.ts` or `.tsx` file over the budget, tooling and unchanged files alike, is listed as advisory and never fails the gate.
|
|
54
|
-
Under `ratchet` the advisory list also names each site in a held file whose overrun did not grow.
|
|
55
|
-
`.d.ts` files are not measured.
|
|
56
|
-
|
|
57
|
-
`quality.json` refuses `applies: "changed"`, which `ratchet` replaces.
|
|
58
|
-
It refuses a limit set directly under `size`, since each limit goes in `size.production` or `size.tests`.
|
|
59
|
-
|
|
60
|
-
## What it reads
|
|
61
|
-
|
|
62
|
-
It reads each file from the head commit rather than the working tree, so an uncommitted edit neither fails nor passes a range, and a pull request's merge checkout measures what the pull request holds.
|
|
63
|
-
Under `ratchet` it also reads each held file from the base of the range, under the path the file has at the head, so a file keeps the same budget at both ends.
|
|
64
|
-
It reads `sources.production` and `size` from `quality.json`.
|
|
65
|
-
oxlint must be on `PATH`, as it is under a package script.
|
|
66
|
-
|
|
67
|
-
## Arguments
|
|
68
|
-
|
|
69
|
-
```sh
|
|
70
|
-
checks-size-budget <base-ref> <head-ref>
|
|
71
|
-
checks-size-budget <ref>
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
With two arguments the range starts where the head branched from the base, at their merge-base.
|
|
75
|
-
With one it is that commit against its parent, or against the empty tree for a repository's first commit.
|
|
76
|
-
|
|
77
|
-
## Exit codes
|
|
78
|
-
|
|
79
|
-
| Code | When |
|
|
80
|
-
| --- | --- |
|
|
81
|
-
| 0 | every file it holds keeps within the budget, or under `ratchet` no file's overrun grows |
|
|
82
|
-
| 1 | a file it holds runs over the budget, or under `ratchet` a file's overrun grows |
|
|
83
|
-
| 2 | `quality.json` does not decode, a ref does not resolve, or oxlint cannot run |
|
|
84
|
-
|
|
85
|
-
## Sample output
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
size-budget: 2 overrun(s) grew past the base in the production and test files the range adds or changes:
|
|
89
|
-
src/billing/invoice.ts: max-lines over by 31 in total, up from 19
|
|
90
|
-
src/billing/invoice.ts: File has too many lines (431). Maximum allowed is 400.
|
|
91
|
-
src/billing/ledger.ts: cognitive-complexity over by 3 in total, up from 0
|
|
92
|
-
src/billing/ledger.ts:12: function `settle` has a cognitive complexity of 18. Maximum allowed is 15.
|
|
93
|
-
size-budget: advisory, 1 overrun(s) where the budget does not hold yet:
|
|
94
|
-
tests/e2e/billing.test.ts: File has too many lines (612). Maximum allowed is 600.
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## Opting out
|
|
98
|
-
|
|
99
|
-
A repository that declares no `size` passes.
|
|
100
|
-
`quality.json` refuses a `size` without `sources.production`, and `checks-quality` refuses a `sources.production` glob that matches no file.
|
|
101
|
-
A repository that tracks no `.ts` or `.tsx` file leaves it out of `gates.lint`, as [Gate selection](checks-lint.md#gate-selection) says.
|
|
102
|
-
Moving `applies` from `ratchet` to `all` tightens the budget to every production and test file, once the advisory list names none.
|
|
103
|
-
|
|
104
|
-
## Related topics
|
|
105
|
-
|
|
106
|
-
- [The quality file](../configs/quality-file.md)
|
|
107
|
-
- [checks-lint](checks-lint.md)
|