@yuu1111/quality-check 0.11.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ja.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # @yuu1111/quality-check
4
4
 
5
- Projectごとのscriptから個別に呼んでいたBiome、型検査、Knip、code-style-check、comment-check、document-style-check、TSDoc checkerを1つのCLIへまとめる baselineの差分判定もここで行う
5
+ 設定したengineを1つのCLIで実行し baselineの差分判定も持つ統合runner
6
6
 
7
7
  ## Install
8
8
 
@@ -10,14 +10,13 @@ Projectごとのscriptから個別に呼んでいたBiome、型検査、Knip、c
10
10
  bun add -D @yuu1111/quality-check
11
11
  ```
12
12
 
13
- このCLIは `comment-check`、`document-style-check`、`tsdoc-check` を、configの型がengineの公開するrule名を取り込むためpeer dependencyとして持つ
14
- package managerはこのCLIと一緒に導入し、engineのbinaryは利用Projectの `node_modules/.bin` から実行時に解決する
15
-
16
- `@yuu1111/code-style-check` を宣言するProjectではKnipが未使用依存として報告するため `knip.ts` の `ignoreDependencies` で理由付きに宣言する
13
+ 4つの検出engine `code-style-check`、`comment-check`、`document-style-check`、`tsdoc-check` はこのpackageへ同梱する
14
+ `bun build` がprivateなworkspace package `dist/cli.js` へbundleするため、このpackageを導入すればengine packageの追加導入も実行時の解決も要らない
15
+ Biome、`tsc`、Knipは子プロセスのままで、利用Projectの `node_modules/.bin` から解決する
17
16
 
18
17
  ## Usage
19
18
 
20
- `quality.config.ts` で起動するengineとengineごとの起動条件を指定し、scriptから起動する
19
+ `quality.json` で起動するengineを指定し、scriptから起動する
21
20
 
22
21
  ```json
23
22
  {
@@ -28,31 +27,35 @@ package managerはこのCLIと一緒に導入し、engineのbinaryは利用Proje
28
27
  ```
29
28
 
30
29
  ```ts
31
- import { defineConfig } from "@yuu1111/quality-check";
32
-
33
- export default defineConfig({
34
- engines: {
35
- biome: true,
36
- typecheck: true,
37
- knip: true,
38
- "code-style-check": true,
39
- "comment-check": true,
40
- "document-style-check": true,
41
- "tsdoc-check": true,
42
- },
43
- config: {
44
- "comment-check": {
45
- enable: ["japanese-period"],
46
- ignore: ["another-project"],
47
- },
48
- "document-style-check": {
49
- enable: ["japanese-period"],
50
- },
51
- "tsdoc-check": {
52
- error: ["missing-doc"],
53
- },
54
- },
55
- });
30
+ {
31
+ "$schema": "./node_modules/@yuu1111/quality-check/schema.json",
32
+ "biome": {
33
+ "enabled": true
34
+ },
35
+ "comment-check": {
36
+ "enabled": true,
37
+ "ignore": ["another-project"],
38
+ "rules": {
39
+ "preset": "recommended",
40
+ "content": {
41
+ "japanese-period": "on"
42
+ }
43
+ }
44
+ },
45
+ "document-style-check": {
46
+ "enabled": true,
47
+ "rules": {
48
+ "preset": "all"
49
+ }
50
+ },
51
+ "tsdoc-check": {
52
+ "enabled": true,
53
+ "rules": {
54
+ "preset": "all"
55
+ }
56
+ },
57
+ "failOnWarnings": true
58
+ }
56
59
  ```
57
60
 
58
61
  engineごとの出力と所要時間、集約summaryを並べて出し、どのengineが失敗したかと実行にかかった合計時間を1回の実行で示す
@@ -77,25 +80,26 @@ quality-check: 1 of 3 engines failed (1250ms)
77
80
 
78
81
  | Field | 説明 |
79
82
  |-------|-------------|
80
- | `engines` | 起動するengine、値は `true` または `false` |
81
- | `config` | engineごとの起動条件 |
83
+ | `<engine>` | engineごとのsectionで `enabled` が起動を決める |
84
+ | `<engine>.rules` | 同梱する4つの検出engineのrule選択 |
85
+ | `failOnWarnings` | warningを阻害する検出として扱う |
82
86
  | `baseline` | baseline fileのpath `false` なら差分判定を行わない |
83
87
 
84
88
  engineは `biome` → `typecheck` → `knip` → `code-style-check` → `comment-check` → `document-style-check` → `tsdoc-check` の順に実行する
85
89
 
86
- `engines` は起動の委任だけを表し、起動条件は `config` engineの下へ置く engineごとの条件は複数行のobjectとして書き、ruleやoptionを足しても他のengineの行が動かないようにする engineが受け取る条件は次のとおり
90
+ engineごとのsectionが `enabled` とそのengineが受け取る条件を持つ engineが受け取らない条件は設定errorにし、打ち間違いが黙って無視されないようにする `biome`、`typecheck`、`knip` は子プロセスで起動し、4つの検出engineはin-processで起動する
87
91
 
88
92
  | Engine | Command | 条件 |
89
- |--------|-----------------|--------------|
93
+ |--------|---------|--------------|
90
94
  | `biome` | `biome check` | `targets`、`args` 除外pathは `biome.json` が持つ |
91
95
  | `typecheck` | `tsc --noEmit` | `args`、`projects` 設定は `tsconfig.json` が持つ |
92
96
  | `knip` | `knip` | `args` 設定は `knip.ts` が持つ |
93
- | `code-style-check` | `code-style-check --json` | `ignore`、`targets`、`args` |
94
- | `comment-check` | `comment-check --json` | `ignore`、`targets`、`args`、`enable`(有効にするrule名) |
95
- | `document-style-check` | `document-style-check lint --json` | `ignore`、`targets`、`args`、`enable`(有効にするrule名) |
96
- | `tsdoc-check` | `tsdoc-check --json` | `ignore`、`targets`、`args`、`enable`(有効にするrule名)、`error`(違反として扱うrule名) |
97
+ | `code-style-check` | in-process | `ignore`、`targets`、`rules` |
98
+ | `comment-check` | in-process | `ignore`、`targets`、`rules` |
99
+ | `document-style-check` | in-process | `ignore`、`targets`、`rules` |
100
+ | `tsdoc-check` | in-process | `ignore`、`targets`、`rules` |
97
101
 
98
- `args` engineの既定引数の後ろへ足す
102
+ `args` は子プロセスengineだけが受け取り、engineの既定引数の後ろへ足す
99
103
  設定fileで表せない起動条件や、engineの引数が変わったときの逃げ道として使う
100
104
 
101
105
  engineが受け取らない条件は渡さず、その旨をそのengineのsectionへ出す
@@ -105,25 +109,78 @@ engineが受け取らない条件は渡さず、その旨をそのengineのsecti
105
109
  biome: ignore skipped (biome.json holds its settings)
106
110
  ```
107
111
 
108
- `enable` は `comment-check` と `document-style-check` と `tsdoc-check` の `--enable <rule>` になり、他のengineでは拒否される
109
- 値は導入済みengine `rule-ids` で公開するrule名で型付けするため、engineが知らない名前は起動時の失敗ではなく型errorになる
112
+ `rules` は同梱するengineのどのruleを実行してどう報告するかを選ぶ
113
+ `rules.preset` は一括で選び `recommended` はengineの既定 `all` は全て有効 `none` は全て無効にする
114
+ group名のkeyはengineが公開するruleのまとまりで、そのgroupの全ruleへ `off`、`on`、`error` を渡す
115
+ group名の下のobjectはruleを1つずつ選ぶ
116
+ 具体的な指定が勝つため preset、group、rule の順に書ける
117
+ `off` は既定で有効なruleにも渡せ、`on` はengineの既定severityのままにする
118
+ `error` を取れるのは `tsdoc-check` だけで、そのruleを違反へ上げ opt-inのruleは先に有効にする
119
+ engineが知らないgroup名やrule名は設定errorになり、配布する `schema.json` がeditorへ同じ語彙を教える
120
+ 選んだruleは同梱するengineへ直接渡すため、CLIは `--enable`、`--disable`、`--error` へは変換しない
110
121
 
111
- `comment-check` はbaseline差分を無効化する未作成のpathを渡して起動する
112
- 新規と解消済みの判定はengineごとではなく統合CLIが1つのbaseline fileで行うため、既存の `comment-baseline.json` がある場合は `--update-baseline` で移す
122
+ 検出engineはbaselineを持たないため、新規と解消済みの判定はengineごとではなく統合CLIが1つのbaseline fileで行う
113
123
 
114
124
  `typecheck` は `projects` に並べたtsconfigごとに `tsc --noEmit -p <path>` を起動する
115
125
  省略時はカレントの `tsconfig.json` を1回だけ読む
116
126
 
127
+ ## Baseline
128
+
129
+ 既存のtreeへ検査を導入するProjectは、その時点の検出を `quality-baseline.json` へ記録し、後から増えた検出だけを失敗にする
130
+ `--update-baseline` はそのfileを現在の検出で置き換える
131
+
132
+ ```bash
133
+ quality-check --update-baseline
134
+ ```
135
+
136
+ 実行のたびに新規の検出を報告し、現れなくなったbaselineのentryを `resolved` として数える
137
+ 新規の検出は直し、意図して受け入れるときだけ `--update-baseline` を実行する
138
+ entryの同一性はengineとruleとfileと検出messageで決まるため、messageが変わるとそのruleは再登録が必要になる
139
+ `quality.json` の `baseline` を `false` にすると差分判定を行わず、全ての検出を報告する
140
+
141
+ ## Commands
142
+
143
+ `quality-check document-style` は同梱する `document-style-check` の検証記録を実行する
144
+
145
+ ```bash
146
+ quality-check document-style lint .
147
+ quality-check document-style lint --write .
148
+ quality-check document-style lint --enable japanese-period .
149
+ quality-check document-style scan doc.md --rules SKILL.md --review review.json
150
+ quality-check document-style check doc.md --rules SKILL.md --review review.json
151
+ ```
152
+
153
+ | Command | 説明 |
154
+ |---------|-------------|
155
+ | `scan` | 対象文書の未確認の検証記録を書き出す |
156
+ | `check` | 埋めた検証記録を現在の本文と基準に対して確認する |
157
+ | `lint` | 機械的な違反を報告し、`--write`で整形する |
158
+
159
+ 記録は本文と基準のhashを固定するため、どちらかを編集すると無効になる `check`が保証するのは全項目に判断と根拠があることだけで、文体判断の正しさは別に確認する
160
+
117
161
  ## Options
118
162
 
119
163
  | Option | 説明 |
120
164
  |--------|-------------|
121
- | `--config <path>` | 読み込むconfig file(既定は `quality.config.ts`) |
165
+ | `--config <path>` | 読み込むconfig file(既定は `quality.json`) |
122
166
  | `--baseline <path>` | baseline fileを上書きする |
123
167
  | `--ignore <path>` | 除外pathを追加する、複数指定できる |
124
168
  | `--update-baseline` | 現在の検出でbaselineを置き換える |
125
169
  | `--json` | engineごとの結果をJSONで出力する |
170
+ | `document-style <command>` | 検証記録を実行する(`scan`、`check`、`lint`) |
126
171
 
127
172
  `--ignore` と位置引数の対象pathは、その条件を受け取るengineへだけ渡す
128
173
 
174
+ ### document-style
175
+
176
+ | Option | 説明 |
177
+ |--------|-------------|
178
+ | `--rules <path>` | `## 判断基準`を持つ基準fileで、`scan`と`check`では必須 |
179
+ | `--review <path>` | 読み書きする検証記録file |
180
+ | `--enable <rule>` | opt-in ruleを実行する、複数指定できる |
181
+ | `--disable <rule>` | 既定で有効なruleも含めて無効にする、複数指定できる |
182
+ | `--ignore <path>` | 検査から外すpath、複数指定できる |
183
+ | `--write` | 報告の代わりに整形を適用する |
184
+ | `--json` | 検出をJSONで出力する |
185
+
129
186
  色は標準出力が端末のときだけ付ける `NO_COLOR` で無効にし、`FORCE_COLOR` で強制できる `--json` の出力には付けない
package/README.md CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  # @yuu1111/quality-check
4
4
 
5
- Runs Biome, the type checker, Knip, code-style-check, comment-check, document-style-check, and the TSDoc checker from one CLI instead of one script per project.
6
- The baseline diff lives here too.
5
+ Integrated CLI that runs the configured engines and owns the baseline diff.
7
6
 
8
7
  ## Install
9
8
 
@@ -11,14 +10,13 @@ The baseline diff lives here too.
11
10
  bun add -D @yuu1111/quality-check
12
11
  ```
13
12
 
14
- `comment-check`, `document-style-check`, and `tsdoc-check` are peer dependencies of this CLI, because the config types embed the rule names those engines publish.
15
- A package manager installs them with this CLI, and each engine binary is resolved at run time from the project's `node_modules/.bin`.
16
-
17
- A project that declares `@yuu1111/code-style-check` sees Knip report it as an unused dependency, so it names it in `ignoreDependencies` with the reason.
13
+ The four finding engines `code-style-check`, `comment-check`, `document-style-check`, and `tsdoc-check` are built into this package.
14
+ `bun build` bundles those private workspace packages into `dist/cli.js`, so installing this package is enough and no engine package has to be installed or resolved at run time.
15
+ Biome, `tsc`, and Knip stay child processes and resolve from the project's `node_modules/.bin`.
18
16
 
19
17
  ## Usage
20
18
 
21
- Declare the engines to run and the conditions of each engine in `quality.config.ts`, then call the CLI from a script:
19
+ Declare the engines to run in `quality.json`, then call the CLI from a script:
22
20
 
23
21
  ```json
24
22
  {
@@ -29,31 +27,35 @@ Declare the engines to run and the conditions of each engine in `quality.config.
29
27
  ```
30
28
 
31
29
  ```ts
32
- import { defineConfig } from "@yuu1111/quality-check";
33
-
34
- export default defineConfig({
35
- engines: {
36
- biome: true,
37
- typecheck: true,
38
- knip: true,
39
- "code-style-check": true,
40
- "comment-check": true,
41
- "document-style-check": true,
42
- "tsdoc-check": true,
43
- },
44
- config: {
45
- "comment-check": {
46
- enable: ["japanese-period"],
47
- ignore: ["another-project"],
48
- },
49
- "document-style-check": {
50
- enable: ["japanese-period"],
51
- },
52
- "tsdoc-check": {
53
- error: ["missing-doc"],
54
- },
55
- },
56
- });
30
+ {
31
+ "$schema": "./node_modules/@yuu1111/quality-check/schema.json",
32
+ "biome": {
33
+ "enabled": true
34
+ },
35
+ "comment-check": {
36
+ "enabled": true,
37
+ "ignore": ["another-project"],
38
+ "rules": {
39
+ "preset": "recommended",
40
+ "content": {
41
+ "japanese-period": "on"
42
+ }
43
+ }
44
+ },
45
+ "document-style-check": {
46
+ "enabled": true,
47
+ "rules": {
48
+ "preset": "all"
49
+ }
50
+ },
51
+ "tsdoc-check": {
52
+ "enabled": true,
53
+ "rules": {
54
+ "preset": "all"
55
+ }
56
+ },
57
+ "failOnWarnings": true
58
+ }
57
59
  ```
58
60
 
59
61
  Each engine prints its own section with its own time, and the summary names the engines that failed and the total time the run took:
@@ -78,54 +80,109 @@ Exit code 0 means every engine passed, 1 that at least one failed, and 2 that th
78
80
 
79
81
  | Field | Description |
80
82
  |-------|-------------|
81
- | `engines` | Engines to run, as `true` or `false` |
82
- | `config` | Conditions of each engine |
83
+ | `<engine>` | One section per engine; `enabled` starts it |
84
+ | `<engine>.rules` | Rule selection of the four built-in finding engines |
85
+ | `failOnWarnings` | Treat every warning as a blocking finding |
83
86
  | `baseline` | Baseline file path; `false` disables the diff |
84
87
 
85
88
  Engines run in the order `biome`, `typecheck`, `knip`, `code-style-check`, `comment-check`, `document-style-check`, `tsdoc-check`.
86
89
 
87
- `engines` only delegates the start-up, and the conditions belong under the engine in `config`.
88
- Write an engine's conditions as a multi-line object, so a new rule or option changes one engine's block alone.
89
- Each engine runs:
90
+ Each engine owns a top-level section that holds `enabled` and the conditions that engine takes.
91
+ A condition an engine does not take is rejected, so a typo fails at start-up instead of being ignored.
92
+ `biome`, `typecheck`, and `knip` run as child processes, and the four finding engines run in-process.
90
93
 
91
94
  | Engine | Command | Conditions |
92
95
  |--------|---------|------------|
93
96
  | `biome` | `biome check` | `targets`, `args`; `biome.json` holds the excluded paths |
94
97
  | `typecheck` | `tsc --noEmit` | `args`, `projects`; `tsconfig.json` holds the settings |
95
98
  | `knip` | `knip` | `args`; `knip.ts` holds the settings |
96
- | `code-style-check` | `code-style-check --json` | `ignore`, `targets`, `args` |
97
- | `comment-check` | `comment-check --json` | `ignore`, `targets`, `args`, `enable` (rule names to turn on) |
98
- | `document-style-check` | `document-style-check lint --json` | `ignore`, `targets`, `args`, `enable` (rule names to turn on) |
99
- | `tsdoc-check` | `tsdoc-check --json` | `ignore`, `targets`, `args`, `enable` (rule names to turn on), `error` (rule names to fail on) |
99
+ | `code-style-check` | in-process | `ignore`, `targets`, `rules` |
100
+ | `comment-check` | in-process | `ignore`, `targets`, `rules` |
101
+ | `document-style-check` | in-process | `ignore`, `targets`, `rules` |
102
+ | `tsdoc-check` | in-process | `ignore`, `targets`, `rules` |
100
103
 
101
- `args` is appended after the engine defaults, for conditions the config cannot express and for the case where an engine changes its arguments.
104
+ `args` applies only to the child-process engines and is appended after the engine defaults, for conditions the config cannot express and for the case where an engine changes its arguments.
102
105
 
103
- A condition that an engine does not take is not passed on, and the section says so:
106
+ A command line override an engine does not take is not passed on, and the section says so:
104
107
 
105
108
  ```text
106
109
  == biome ==
107
110
  biome: ignore skipped (biome.json holds its settings)
108
111
  ```
109
112
 
110
- `enable` becomes `--enable <rule>` on `comment-check`, `document-style-check`, and `tsdoc-check`, and the other engines reject the field.
111
- Each value is typed with the rule names the installed engine publishes from its `rule-ids` entry, so a name that engine does not know is a type error rather than a start-up failure.
113
+ `rules` selects which rules of the built-in engines run and how they are reported.
114
+ `rules.preset` selects in bulk: `recommended` is the engine default, `all` turns every rule on, and `none` turns every rule off.
115
+ A group key names one of the rule groups the engine publishes and takes `off`, `on`, or `error` for every rule in that group.
116
+ An object under a group key names single rules.
117
+ The most specific setting wins, so a preset, a group, and a rule may be written in that order.
118
+ `off` also works for a rule that is on by default, and `on` keeps the engine default severity.
119
+ Only `tsdoc-check` takes `error`, which raises the rule and turns an opt-in rule on first.
120
+ A group or rule name that the engine does not know is a configuration error, and the published `schema.json` teaches an editor the same names.
121
+ The selection is handed to the built-in engines directly, so the CLI no longer turns it into `--enable`, `--disable`, or `--error` arguments.
112
122
 
113
- `comment-check` runs with an unwritten baseline path so that it reports every finding.
114
- The new-and-resolved diff is done by this CLI from a single baseline file, so an existing `comment-baseline.json` is moved over with `--update-baseline`.
123
+ No check engine keeps a baseline of its own, so the new-and-resolved diff is done by this CLI from a single baseline file.
115
124
 
116
125
  `typecheck` starts `tsc --noEmit -p <path>` once per path in `projects`, and falls back to the current `tsconfig.json`.
117
126
 
127
+ ## Baseline
128
+
129
+ A project that adopts the checks on an existing tree records the findings it has today in `quality-baseline.json`, so only the findings it adds later fail.
130
+ `--update-baseline` replaces that file with the current findings:
131
+
132
+ ```bash
133
+ quality-check --update-baseline
134
+ ```
135
+
136
+ Every run reports the new findings and counts the baseline entries that no longer appear as `resolved`.
137
+ Fix the new findings, and run `--update-baseline` only when the team accepts one on purpose.
138
+ An entry is identified by its engine, rule, file, and message, so a change to a message re-baselines that rule.
139
+ Set `baseline` to `false` in `quality.json` to diff nothing and report every finding.
140
+
141
+ ## Commands
142
+
143
+ `quality-check document-style` runs the review ledger of the built-in `document-style-check` engine:
144
+
145
+ ```bash
146
+ quality-check document-style lint .
147
+ quality-check document-style lint --write .
148
+ quality-check document-style lint --enable japanese-period .
149
+ quality-check document-style scan doc.md --rules SKILL.md --review review.json
150
+ quality-check document-style check doc.md --rules SKILL.md --review review.json
151
+ ```
152
+
153
+ | Command | Description |
154
+ |---------|-------------|
155
+ | `scan` | Write an unconfirmed review record for the given documents |
156
+ | `check` | Verify a filled review record against the current documents and rules |
157
+ | `lint` | Report mechanical violations, or fix them with `--write` |
158
+
159
+ The review file pins the document bytes and the rules bytes by hash, so editing either one invalidates the record.
160
+ `check` only confirms that every candidate carries a decision and a reason; it does not judge the writing.
161
+
118
162
  ## Options
119
163
 
120
164
  | Option | Description |
121
165
  |--------|-------------|
122
- | `--config <path>` | Config file to load (default `quality.config.ts`) |
166
+ | `--config <path>` | Config file to load (default `quality.json`) |
123
167
  | `--baseline <path>` | Override the baseline file |
124
168
  | `--ignore <path>` | Add an excluded path, repeatable |
125
169
  | `--update-baseline` | Replace the baseline with the current findings |
126
170
  | `--json` | Print the per-engine results as JSON |
171
+ | `document-style <command>` | Run the review ledger (`scan`, `check`, or `lint`) |
127
172
 
128
173
  `--ignore` and the positional targets reach only the engines that take them.
129
174
 
175
+ ### document-style
176
+
177
+ | Option | Description |
178
+ |--------|-------------|
179
+ | `--rules <path>` | Rules file that holds the criteria, required by `scan` and `check` |
180
+ | `--review <path>` | Review file to write or read |
181
+ | `--enable <rule>` | Run an opt-in rule, repeatable |
182
+ | `--disable <rule>` | Turn a rule off, repeatable |
183
+ | `--ignore <path>` | Path to leave out, repeatable |
184
+ | `--write` | Apply `lint` fixes instead of reporting them |
185
+ | `--json` | Print findings as JSON |
186
+
130
187
  Color is added only when stdout is a terminal.
131
188
  `NO_COLOR` turns it off and `FORCE_COLOR` turns it on; the `--json` output stays plain.