@yuu1111/quality-check 0.7.1 → 0.9.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 +35 -36
- package/README.md +36 -59
- package/dist/cli.js +34 -18
- package/package.json +2 -2
- package/src/config.ts +3 -0
- package/src/engines.ts +6 -0
package/README.ja.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# @yuu1111/quality-check
|
|
4
4
|
|
|
5
|
-
Projectごとのscriptから個別に呼んでいたBiome、型検査、Knip、comment-check、document-style-check、TSDoc checkerを1つのCLIへまとめる baselineの差分判定もここで行う
|
|
5
|
+
Projectごとのscriptから個別に呼んでいたBiome、型検査、Knip、code-style-check、comment-check、document-style-check、TSDoc checkerを1つのCLIへまとめる baselineの差分判定もここで行う
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -10,6 +10,8 @@ Projectごとのscriptから個別に呼んでいたBiome、型検査、Knip、c
|
|
|
10
10
|
bun add -D @yuu1111/quality-check
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
engineのbinaryは利用Projectの `node_modules/.bin` から実行時に解決する engineを自分のscriptから呼ばないProjectではKnipが `@yuu1111/comment-check` などを未使用依存として報告するため `knip.ts` の `ignoreDependencies` で理由付きに宣言する
|
|
14
|
+
|
|
13
15
|
## Usage
|
|
14
16
|
|
|
15
17
|
`quality.config.ts` で起動するengineとengineごとの起動条件を指定し、scriptから起動する
|
|
@@ -30,6 +32,7 @@ export default defineConfig({
|
|
|
30
32
|
biome: true,
|
|
31
33
|
typecheck: true,
|
|
32
34
|
knip: true,
|
|
35
|
+
"code-style-check": true,
|
|
33
36
|
"comment-check": true,
|
|
34
37
|
"document-style-check": true,
|
|
35
38
|
"tsdoc-check": true,
|
|
@@ -49,79 +52,75 @@ export default defineConfig({
|
|
|
49
52
|
});
|
|
50
53
|
```
|
|
51
54
|
|
|
52
|
-
engine
|
|
55
|
+
engineごとの出力と所要時間、集約summaryを並べて出し、どのengineが失敗したかと実行にかかった合計時間を1回の実行で示す
|
|
53
56
|
|
|
54
57
|
```text
|
|
55
58
|
== biome ==
|
|
56
59
|
Checked 128 files in 260ms. No fixes applied.
|
|
57
|
-
biome: passed (exit 0)
|
|
60
|
+
biome: passed (exit 0, 296ms)
|
|
58
61
|
|
|
59
62
|
== comment-check ==
|
|
60
63
|
src/queue.ts:18:2 placeholder-comment placeholder comment should be resolved or tracked
|
|
61
|
-
comment-check: failed (1 new, 0 resolved, 0 warnings)
|
|
64
|
+
comment-check: failed (1 new, 0 resolved, 0 warnings, 118ms)
|
|
62
65
|
|
|
63
|
-
quality-check: 1 of 3 engines failed
|
|
66
|
+
quality-check: 1 of 3 engines failed (1250ms)
|
|
64
67
|
failed: comment-check
|
|
65
68
|
passed: biome, tsdoc-check
|
|
66
69
|
```
|
|
67
70
|
|
|
71
|
+
終了codeは0が全engine成功、1が失敗したengineあり、2が設定またはengine起動の失敗
|
|
72
|
+
|
|
68
73
|
## Config
|
|
69
74
|
|
|
70
|
-
| Field |
|
|
75
|
+
| Field | 説明 |
|
|
71
76
|
|-------|-------------|
|
|
72
|
-
| `engines` | 起動するengine
|
|
77
|
+
| `engines` | 起動するengine、値は `true` または `false` |
|
|
73
78
|
| `config` | engineごとの起動条件 |
|
|
74
79
|
| `baseline` | baseline fileのpath `false` なら差分判定を行わない |
|
|
75
80
|
|
|
76
|
-
engineは `biome` → `typecheck` → `knip` → `comment-check` → `document-style-check` → `tsdoc-check` の順に実行する
|
|
81
|
+
engineは `biome` → `typecheck` → `knip` → `code-style-check` → `comment-check` → `document-style-check` → `tsdoc-check` の順に実行する
|
|
77
82
|
|
|
78
83
|
`engines` は起動の委任だけを表し、起動条件は `config` のengineの下へ置く engineごとの条件は複数行のobjectとして書き、ruleやoptionを足しても他のengineの行が動かないようにする engineが受け取る条件は次のとおり
|
|
79
84
|
|
|
80
|
-
|
|
|
85
|
+
| Engine | Command | 条件 |
|
|
81
86
|
|--------|-----------------|--------------|
|
|
82
87
|
| `biome` | `biome check` | `targets`、`args` 除外pathは `biome.json` が持つ |
|
|
83
88
|
| `typecheck` | `tsc --noEmit` | `args`、`projects` 設定は `tsconfig.json` が持つ |
|
|
84
89
|
| `knip` | `knip` | `args` 設定は `knip.ts` が持つ |
|
|
90
|
+
| `code-style-check` | `code-style-check --json` | `ignore`、`targets`、`args` |
|
|
85
91
|
| `comment-check` | `comment-check --json` | `ignore`、`targets`、`args`、`enable`(有効にするrule名) |
|
|
86
92
|
| `document-style-check` | `document-style-check lint --json` | `ignore`、`targets`、`args`、`enable`(有効にするrule名) |
|
|
87
93
|
| `tsdoc-check` | `tsdoc-check --json` | `ignore`、`targets`、`args`、`error`(違反として扱うrule名) |
|
|
88
94
|
|
|
89
|
-
`args` はengineの既定引数の後ろへ足す
|
|
90
|
-
|
|
91
|
-
## Options
|
|
92
|
-
|
|
93
|
-
| Option | Description |
|
|
94
|
-
|--------|-------------|
|
|
95
|
-
| `--config <path>` | 読み込むconfig file(既定は `quality.config.ts`) |
|
|
96
|
-
| `--baseline <path>` | baseline fileを上書きする |
|
|
97
|
-
| `--ignore <path>` | 除外pathを追加する 複数指定できる |
|
|
98
|
-
| `--update-baseline` | 現在の検出でbaselineを置き換える |
|
|
99
|
-
| `--json` | engineごとの結果をJSONで出力する |
|
|
100
|
-
|
|
101
|
-
`--ignore` と位置引数の対象pathは、その条件を受け取るengineへだけ渡す
|
|
102
|
-
|
|
103
|
-
## Notes
|
|
95
|
+
`args` はengineの既定引数の後ろへ足す
|
|
96
|
+
設定fileで表せない起動条件や、engineの引数が変わったときの逃げ道として使う
|
|
104
97
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
色は標準出力が端末のときだけ付ける `NO_COLOR` で無効にし、`FORCE_COLOR` で強制できる `--json` の出力には付けない
|
|
108
|
-
|
|
109
|
-
色を扱えるengineへは自身の出力の色も許可する Biomeは `--colors=force`、tscは `--pretty` を受け取る
|
|
110
|
-
|
|
111
|
-
engineが受け取らない条件を書いた場合は渡さず、その旨をそのengineのsectionへ出す
|
|
98
|
+
engineが受け取らない条件は渡さず、その旨をそのengineのsectionへ出す
|
|
112
99
|
|
|
113
100
|
```text
|
|
114
101
|
== biome ==
|
|
115
102
|
biome: ignore skipped (biome.json holds its settings)
|
|
116
103
|
```
|
|
117
104
|
|
|
118
|
-
|
|
105
|
+
`enable` は `comment-check` と `document-style-check` の `--enable <rule>` になり、他のengineでは拒否される
|
|
106
|
+
このCLIはengineを同梱しないため、opt-in ruleを有効にするProjectは対応するengine packageも同じ変更で更新する
|
|
119
107
|
|
|
120
|
-
|
|
108
|
+
`comment-check` はbaseline差分を無効化する未作成のpathを渡して起動する
|
|
109
|
+
新規と解消済みの判定はengineごとではなく統合CLIが1つのbaseline fileで行うため、既存の `comment-baseline.json` がある場合は `--update-baseline` で移す
|
|
121
110
|
|
|
122
|
-
`
|
|
111
|
+
`typecheck` は `projects` に並べたtsconfigごとに `tsc --noEmit -p <path>` を起動する
|
|
112
|
+
省略時はカレントの `tsconfig.json` を1回だけ読む
|
|
123
113
|
|
|
124
|
-
|
|
114
|
+
## Options
|
|
125
115
|
|
|
126
|
-
|
|
116
|
+
| Option | 説明 |
|
|
117
|
+
|--------|-------------|
|
|
118
|
+
| `--config <path>` | 読み込むconfig file(既定は `quality.config.ts`) |
|
|
119
|
+
| `--baseline <path>` | baseline fileを上書きする |
|
|
120
|
+
| `--ignore <path>` | 除外pathを追加する、複数指定できる |
|
|
121
|
+
| `--update-baseline` | 現在の検出でbaselineを置き換える |
|
|
122
|
+
| `--json` | engineごとの結果をJSONで出力する |
|
|
127
123
|
|
|
124
|
+
`--ignore` と位置引数の対象pathは、その条件を受け取るengineへだけ渡す
|
|
125
|
+
|
|
126
|
+
色は標準出力が端末のときだけ付ける `NO_COLOR` で無効にし、`FORCE_COLOR` で強制できる `--json` の出力には付けない
|
package/README.md
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# @yuu1111/quality-check
|
|
4
4
|
|
|
5
|
-
Runs Biome, the type checker, Knip, comment-check, document-style-check, and the
|
|
6
|
-
|
|
7
|
-
lives here too.
|
|
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.
|
|
8
7
|
|
|
9
8
|
## Install
|
|
10
9
|
|
|
@@ -12,10 +11,12 @@ lives here too.
|
|
|
12
11
|
bun add -D @yuu1111/quality-check
|
|
13
12
|
```
|
|
14
13
|
|
|
14
|
+
An engine binary is resolved at run time from the project's `node_modules/.bin`.
|
|
15
|
+
A project that never calls an engine from its own scripts therefore sees Knip report `@yuu1111/comment-check` and its siblings as unused dependencies, so it declares them in `ignoreDependencies` with the reason.
|
|
16
|
+
|
|
15
17
|
## Usage
|
|
16
18
|
|
|
17
|
-
Declare the engines to run and the conditions of each engine in
|
|
18
|
-
`quality.config.ts`, then call the CLI from a script:
|
|
19
|
+
Declare the engines to run and the conditions of each engine in `quality.config.ts`, then call the CLI from a script:
|
|
19
20
|
|
|
20
21
|
```json
|
|
21
22
|
{
|
|
@@ -33,6 +34,7 @@ export default defineConfig({
|
|
|
33
34
|
biome: true,
|
|
34
35
|
typecheck: true,
|
|
35
36
|
knip: true,
|
|
37
|
+
"code-style-check": true,
|
|
36
38
|
"comment-check": true,
|
|
37
39
|
"document-style-check": true,
|
|
38
40
|
"tsdoc-check": true,
|
|
@@ -52,23 +54,24 @@ export default defineConfig({
|
|
|
52
54
|
});
|
|
53
55
|
```
|
|
54
56
|
|
|
55
|
-
Each engine prints its own section, and the summary names the engines that
|
|
56
|
-
failed:
|
|
57
|
+
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:
|
|
57
58
|
|
|
58
59
|
```text
|
|
59
60
|
== biome ==
|
|
60
61
|
Checked 128 files in 260ms. No fixes applied.
|
|
61
|
-
biome: passed (exit 0)
|
|
62
|
+
biome: passed (exit 0, 296ms)
|
|
62
63
|
|
|
63
64
|
== comment-check ==
|
|
64
65
|
src/queue.ts:18:2 placeholder-comment placeholder comment should be resolved or tracked
|
|
65
|
-
comment-check: failed (1 new, 0 resolved, 0 warnings)
|
|
66
|
+
comment-check: failed (1 new, 0 resolved, 0 warnings, 118ms)
|
|
66
67
|
|
|
67
|
-
quality-check: 1 of 3 engines failed
|
|
68
|
+
quality-check: 1 of 3 engines failed (1250ms)
|
|
68
69
|
failed: comment-check
|
|
69
70
|
passed: biome, tsdoc-check
|
|
70
71
|
```
|
|
71
72
|
|
|
73
|
+
Exit code 0 means every engine passed, 1 that at least one failed, and 2 that the configuration or an engine could not start.
|
|
74
|
+
|
|
72
75
|
## Config
|
|
73
76
|
|
|
74
77
|
| Field | Description |
|
|
@@ -77,24 +80,38 @@ quality-check: 1 of 3 engines failed
|
|
|
77
80
|
| `config` | Conditions of each engine |
|
|
78
81
|
| `baseline` | Baseline file path; `false` disables the diff |
|
|
79
82
|
|
|
80
|
-
Engines run in the order `biome`, `typecheck`, `knip`, `comment-check`,
|
|
81
|
-
`document-style-check`, `tsdoc-check`.
|
|
83
|
+
Engines run in the order `biome`, `typecheck`, `knip`, `code-style-check`, `comment-check`, `document-style-check`, `tsdoc-check`.
|
|
82
84
|
|
|
83
|
-
`engines` only delegates the start-up, and the conditions belong under the
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
`engines` only delegates the start-up, and the conditions belong under the engine in `config`.
|
|
86
|
+
Write an engine's conditions as a multi-line object, so a new rule or option changes one engine's block alone.
|
|
87
|
+
Each engine runs:
|
|
86
88
|
|
|
87
89
|
| Engine | Command | Conditions |
|
|
88
90
|
|--------|---------|------------|
|
|
89
91
|
| `biome` | `biome check` | `targets`, `args`; `biome.json` holds the excluded paths |
|
|
90
92
|
| `typecheck` | `tsc --noEmit` | `args`, `projects`; `tsconfig.json` holds the settings |
|
|
91
93
|
| `knip` | `knip` | `args`; `knip.ts` holds the settings |
|
|
94
|
+
| `code-style-check` | `code-style-check --json` | `ignore`, `targets`, `args` |
|
|
92
95
|
| `comment-check` | `comment-check --json` | `ignore`, `targets`, `args`, `enable` (rule names to turn on) |
|
|
93
96
|
| `document-style-check` | `document-style-check lint --json` | `ignore`, `targets`, `args`, `enable` (rule names to turn on) |
|
|
94
97
|
| `tsdoc-check` | `tsdoc-check --json` | `ignore`, `targets`, `args`, `error` (rule names to fail on) |
|
|
95
98
|
|
|
96
|
-
`args` is appended after the engine defaults, for conditions the config cannot
|
|
97
|
-
|
|
99
|
+
`args` is appended after the engine defaults, for conditions the config cannot express and for the case where an engine changes its arguments.
|
|
100
|
+
|
|
101
|
+
A condition that an engine does not take is not passed on, and the section says so:
|
|
102
|
+
|
|
103
|
+
```text
|
|
104
|
+
== biome ==
|
|
105
|
+
biome: ignore skipped (biome.json holds its settings)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`enable` becomes `--enable <rule>` on `comment-check` and `document-style-check`, and the other engines reject the field.
|
|
109
|
+
This CLI ships no engine of its own, so a project that turns an opt-in rule on updates the matching engine package in the same change.
|
|
110
|
+
|
|
111
|
+
`comment-check` runs with an unwritten baseline path so that it reports every finding.
|
|
112
|
+
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`.
|
|
113
|
+
|
|
114
|
+
`typecheck` starts `tsc --noEmit -p <path>` once per path in `projects`, and falls back to the current `tsconfig.json`.
|
|
98
115
|
|
|
99
116
|
## Options
|
|
100
117
|
|
|
@@ -108,45 +125,5 @@ express and for the case where an engine changes its arguments.
|
|
|
108
125
|
|
|
109
126
|
`--ignore` and the positional targets reach only the engines that take them.
|
|
110
127
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
Exit code 0 means every engine passed, 1 that at least one failed, and 2 that the
|
|
114
|
-
configuration or an engine could not start.
|
|
115
|
-
|
|
116
|
-
Color is added only when stdout is a terminal. `NO_COLOR` turns it off and
|
|
117
|
-
`FORCE_COLOR` turns it on; the `--json` output stays plain.
|
|
118
|
-
|
|
119
|
-
The engines that can color their own output receive the same permission: Biome
|
|
120
|
-
gets `--colors=force` and tsc gets `--pretty`.
|
|
121
|
-
|
|
122
|
-
A condition that an engine does not take is not passed on, and the section says
|
|
123
|
-
so:
|
|
124
|
-
|
|
125
|
-
```text
|
|
126
|
-
== biome ==
|
|
127
|
-
biome: ignore skipped (biome.json holds its settings)
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
Biome, the type checker, and Knip keep their settings in `biome.json`,
|
|
131
|
-
`tsconfig.json`, and `knip.ts`. This CLI starts the engines from one file and
|
|
132
|
-
aggregates the results.
|
|
133
|
-
|
|
134
|
-
An engine binary is resolved at run time from the `node_modules/.bin` of the
|
|
135
|
-
project. A project that never calls an engine from its own scripts therefore
|
|
136
|
-
sees Knip report `@yuu1111/comment-check` and its siblings as unused
|
|
137
|
-
dependencies, so it declares them in `ignoreDependencies` with the reason.
|
|
138
|
-
|
|
139
|
-
`comment-check` runs with an unwritten baseline path so that it reports every
|
|
140
|
-
finding. The new-and-resolved diff is done by this CLI from a single baseline
|
|
141
|
-
file, so an existing `comment-baseline.json` is moved over with
|
|
142
|
-
`--update-baseline`.
|
|
143
|
-
|
|
144
|
-
`enable` names the opt-in rules of `comment-check` and `document-style-check`
|
|
145
|
-
and becomes `--enable <rule>` on each of their commands. The other engines
|
|
146
|
-
reject the field, and the default rule set stays as it is. This CLI ships no
|
|
147
|
-
engine of its own, so a project that turns an opt-in rule on updates the
|
|
148
|
-
matching engine package in the same change.
|
|
149
|
-
|
|
150
|
-
`typecheck` starts `tsc --noEmit -p <path>` once per path in `projects`. Without
|
|
151
|
-
it the current `tsconfig.json` is read once, and `args` are added to every
|
|
152
|
-
start.
|
|
128
|
+
Color is added only when stdout is a terminal.
|
|
129
|
+
`NO_COLOR` turns it off and `FORCE_COLOR` turns it on; the `--json` output stays plain.
|
package/dist/cli.js
CHANGED
|
@@ -198,6 +198,7 @@ var ENGINE_NAMES = [
|
|
|
198
198
|
"biome",
|
|
199
199
|
"typecheck",
|
|
200
200
|
"knip",
|
|
201
|
+
"code-style-check",
|
|
201
202
|
"comment-check",
|
|
202
203
|
"document-style-check",
|
|
203
204
|
"tsdoc-check"
|
|
@@ -219,6 +220,7 @@ var ENGINE_OPTION_KEYS = {
|
|
|
219
220
|
biome: ["args", "ignore", "targets"],
|
|
220
221
|
typecheck: ["args", "ignore", "projects", "targets"],
|
|
221
222
|
knip: ["args", "ignore", "targets"],
|
|
223
|
+
"code-style-check": ["args", "ignore", "targets"],
|
|
222
224
|
"comment-check": ["args", "enable", "ignore", "targets"],
|
|
223
225
|
"document-style-check": ["args", "enable", "ignore", "targets"],
|
|
224
226
|
"tsdoc-check": ["args", "error", "ignore", "targets"]
|
|
@@ -375,6 +377,7 @@ import { existsSync as existsSync3 } from "fs";
|
|
|
375
377
|
import { dirname, join } from "path";
|
|
376
378
|
var ENGINE_BINS = {
|
|
377
379
|
biome: "biome",
|
|
380
|
+
"code-style-check": "code-style-check",
|
|
378
381
|
"comment-check": "comment-check",
|
|
379
382
|
"document-style-check": "document-style-check",
|
|
380
383
|
knip: "knip",
|
|
@@ -393,6 +396,7 @@ var ENGINE_LIMITS = {
|
|
|
393
396
|
ignore: "knip.ts holds its settings",
|
|
394
397
|
targets: "knip analyzes the whole project"
|
|
395
398
|
},
|
|
399
|
+
"code-style-check": {},
|
|
396
400
|
"comment-check": {},
|
|
397
401
|
"document-style-check": {},
|
|
398
402
|
"tsdoc-check": {}
|
|
@@ -412,7 +416,7 @@ function skippedEngineOptions(name, options) {
|
|
|
412
416
|
return skipped;
|
|
413
417
|
}
|
|
414
418
|
function isFindingEngine(name) {
|
|
415
|
-
return name === "comment-check" || name === "document-style-check" || name === "tsdoc-check";
|
|
419
|
+
return name === "code-style-check" || name === "comment-check" || name === "document-style-check" || name === "tsdoc-check";
|
|
416
420
|
}
|
|
417
421
|
function resolveExecutable(name, cwd) {
|
|
418
422
|
const shims = process.platform === "win32" ? WINDOWS_SHIMS : POSIX_SHIMS;
|
|
@@ -507,6 +511,9 @@ function buildEngineCommand(name, executable, context) {
|
|
|
507
511
|
...extra
|
|
508
512
|
];
|
|
509
513
|
}
|
|
514
|
+
if (name === "code-style-check") {
|
|
515
|
+
return [executable, "--json", ...targets, ...ignoreArguments, ...extra];
|
|
516
|
+
}
|
|
510
517
|
return [
|
|
511
518
|
executable,
|
|
512
519
|
"--json",
|
|
@@ -548,12 +555,17 @@ function describeCounts(result) {
|
|
|
548
555
|
}
|
|
549
556
|
return `${result.reported.length} new, ${result.resolved} resolved, ${result.warnings.length} warnings`;
|
|
550
557
|
}
|
|
558
|
+
function formatMillis(elapsedMs) {
|
|
559
|
+
return `${Math.round(elapsedMs)}ms`;
|
|
560
|
+
}
|
|
551
561
|
function describeStatus(result, paint) {
|
|
552
562
|
if (result.status === "error") {
|
|
553
|
-
|
|
563
|
+
const status = paint("error", "error");
|
|
564
|
+
return result.durationMs === null ? status : `${status} (${formatMillis(result.durationMs)})`;
|
|
554
565
|
}
|
|
555
566
|
const tone = result.status === "passed" ? "pass" : "error";
|
|
556
|
-
|
|
567
|
+
const elapsed = result.durationMs === null ? "" : `, ${formatMillis(result.durationMs)}`;
|
|
568
|
+
return `${paint(result.status, tone)} (${describeCounts(result)}${elapsed})`;
|
|
557
569
|
}
|
|
558
570
|
function formatEngineSection(result, paint = plainPainter) {
|
|
559
571
|
const lines = [paint(`== ${result.name} ==`, "header")];
|
|
@@ -576,14 +588,15 @@ function formatEngineSection(result, paint = plainPainter) {
|
|
|
576
588
|
return lines.join(`
|
|
577
589
|
`);
|
|
578
590
|
}
|
|
579
|
-
function formatSummary(results, paint = plainPainter) {
|
|
591
|
+
function formatSummary(results, elapsedMs, paint = plainPainter) {
|
|
580
592
|
const failed = results.filter((result) => result.status !== "passed").map((result) => result.name);
|
|
581
593
|
const passed = results.filter((result) => result.status === "passed").map((result) => result.name);
|
|
594
|
+
const elapsed = ` (${formatMillis(elapsedMs)})`;
|
|
582
595
|
if (failed.length === 0) {
|
|
583
|
-
return paint(`quality-check: ${results.length} engines passed`, "pass");
|
|
596
|
+
return paint(`quality-check: ${results.length} engines passed${elapsed}`, "pass");
|
|
584
597
|
}
|
|
585
598
|
const lines = [
|
|
586
|
-
paint(`quality-check: ${failed.length} of ${results.length} engines failed`, "error"),
|
|
599
|
+
paint(`quality-check: ${failed.length} of ${results.length} engines failed${elapsed}`, "error"),
|
|
587
600
|
` ${paint("failed:", "error")} ${failed.join(", ")}`
|
|
588
601
|
];
|
|
589
602
|
if (passed.length > 0) {
|
|
@@ -592,10 +605,12 @@ function formatSummary(results, paint = plainPainter) {
|
|
|
592
605
|
return lines.join(`
|
|
593
606
|
`);
|
|
594
607
|
}
|
|
595
|
-
function toJsonReport(results) {
|
|
608
|
+
function toJsonReport(results, elapsedMs) {
|
|
596
609
|
return {
|
|
610
|
+
elapsedMs: Math.round(elapsedMs),
|
|
597
611
|
engines: results.map((result) => ({
|
|
598
612
|
detected: result.detected.length,
|
|
613
|
+
durationMs: result.durationMs === null ? null : Math.round(result.durationMs),
|
|
599
614
|
exitCode: result.exitCode,
|
|
600
615
|
message: result.message ?? null,
|
|
601
616
|
name: result.name,
|
|
@@ -747,25 +762,24 @@ async function runProcessEngine(name, options, executable, context, runner) {
|
|
|
747
762
|
status: exitCode === 0 ? "passed" : "failed"
|
|
748
763
|
};
|
|
749
764
|
}
|
|
750
|
-
async function
|
|
765
|
+
async function runEngine(name, options, context, runner) {
|
|
751
766
|
const executable = (options.resolve ?? resolveExecutable)(name, options.cwd);
|
|
767
|
+
const skipped = skippedEngineOptions(name, options.config.config?.[name]);
|
|
752
768
|
if (executable === null) {
|
|
753
769
|
return {
|
|
754
770
|
...baseResult(name, null, ""),
|
|
771
|
+
durationMs: null,
|
|
755
772
|
message: `${ENGINE_BINS[name]} is not installed`,
|
|
773
|
+
skipped,
|
|
756
774
|
status: "error"
|
|
757
775
|
};
|
|
758
776
|
}
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}
|
|
762
|
-
return await runProcessEngine(name, options, executable, context, runner);
|
|
763
|
-
}
|
|
764
|
-
async function runEngine(name, options, context, runner) {
|
|
765
|
-
const result = await executeEngine(name, options, context, runner);
|
|
777
|
+
const startedAt = performance.now();
|
|
778
|
+
const result = isFindingEngine(name) ? await runFindingEngine(name, options, executable, context, runner) : await runProcessEngine(name, options, executable, context, runner);
|
|
766
779
|
return {
|
|
767
780
|
...result,
|
|
768
|
-
|
|
781
|
+
durationMs: performance.now() - startedAt,
|
|
782
|
+
skipped
|
|
769
783
|
};
|
|
770
784
|
}
|
|
771
785
|
async function runEngines(options) {
|
|
@@ -830,6 +844,7 @@ async function main(argv) {
|
|
|
830
844
|
}
|
|
831
845
|
const config = await loadConfig(configPath);
|
|
832
846
|
const baselinePath = resolveBaselinePath(options, config, cwd);
|
|
847
|
+
const startedAt = performance.now();
|
|
833
848
|
const results = await runEngines({
|
|
834
849
|
baseline: options.update || baselinePath === null ? null : readBaseline(baselinePath, "quality"),
|
|
835
850
|
color,
|
|
@@ -838,6 +853,7 @@ async function main(argv) {
|
|
|
838
853
|
overrides: { ignore: options.ignores, targets: options.targets },
|
|
839
854
|
rawBaseline: join2(tmpdir(), `quality-check-raw-${process.pid}.json`)
|
|
840
855
|
});
|
|
856
|
+
const elapsedMs = performance.now() - startedAt;
|
|
841
857
|
if (options.update) {
|
|
842
858
|
if (baselinePath === null) {
|
|
843
859
|
console.error("baseline is disabled by the configuration");
|
|
@@ -849,12 +865,12 @@ async function main(argv) {
|
|
|
849
865
|
return 0;
|
|
850
866
|
}
|
|
851
867
|
if (options.json) {
|
|
852
|
-
console.log(JSON.stringify(toJsonReport(results), null, "\t"));
|
|
868
|
+
console.log(JSON.stringify(toJsonReport(results, elapsedMs), null, "\t"));
|
|
853
869
|
} else {
|
|
854
870
|
for (const result of results) {
|
|
855
871
|
console.log(formatEngineSection(result, paint));
|
|
856
872
|
}
|
|
857
|
-
console.log(formatSummary(results, paint));
|
|
873
|
+
console.log(formatSummary(results, elapsedMs, paint));
|
|
858
874
|
}
|
|
859
875
|
return results.some((result) => result.status !== "passed") ? 1 : 0;
|
|
860
876
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuu1111/quality-check",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Integrated quality check runner",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/yuu1111/configs.git",
|
|
8
|
-
"directory": "packages/quality-check"
|
|
8
|
+
"directory": "packages/engine/quality-check"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
11
|
"bin": {
|
package/src/config.ts
CHANGED
|
@@ -9,6 +9,7 @@ export const ENGINE_NAMES = [
|
|
|
9
9
|
"biome",
|
|
10
10
|
"typecheck",
|
|
11
11
|
"knip",
|
|
12
|
+
"code-style-check",
|
|
12
13
|
"comment-check",
|
|
13
14
|
"document-style-check",
|
|
14
15
|
"tsdoc-check",
|
|
@@ -70,6 +71,7 @@ export interface EngineConfigMap {
|
|
|
70
71
|
biome: EngineOptions;
|
|
71
72
|
typecheck: TypecheckOptions;
|
|
72
73
|
knip: EngineOptions;
|
|
74
|
+
"code-style-check": EngineOptions;
|
|
73
75
|
"comment-check": CommentCheckOptions;
|
|
74
76
|
"document-style-check": DocumentStyleCheckOptions;
|
|
75
77
|
"tsdoc-check": TsdocCheckOptions;
|
|
@@ -123,6 +125,7 @@ const ENGINE_OPTION_KEYS: Record<EngineName, readonly string[]> = {
|
|
|
123
125
|
biome: ["args", "ignore", "targets"],
|
|
124
126
|
typecheck: ["args", "ignore", "projects", "targets"],
|
|
125
127
|
knip: ["args", "ignore", "targets"],
|
|
128
|
+
"code-style-check": ["args", "ignore", "targets"],
|
|
126
129
|
"comment-check": ["args", "enable", "ignore", "targets"],
|
|
127
130
|
"document-style-check": ["args", "enable", "ignore", "targets"],
|
|
128
131
|
"tsdoc-check": ["args", "error", "ignore", "targets"],
|
package/src/engines.ts
CHANGED
|
@@ -29,6 +29,7 @@ export type EngineRunner = (
|
|
|
29
29
|
*/
|
|
30
30
|
export const ENGINE_BINS: Record<EngineName, string> = {
|
|
31
31
|
biome: "biome",
|
|
32
|
+
"code-style-check": "code-style-check",
|
|
32
33
|
"comment-check": "comment-check",
|
|
33
34
|
"document-style-check": "document-style-check",
|
|
34
35
|
knip: "knip",
|
|
@@ -76,6 +77,7 @@ export const ENGINE_LIMITS: Record<
|
|
|
76
77
|
ignore: "knip.ts holds its settings",
|
|
77
78
|
targets: "knip analyzes the whole project",
|
|
78
79
|
},
|
|
80
|
+
"code-style-check": {},
|
|
79
81
|
"comment-check": {},
|
|
80
82
|
"document-style-check": {},
|
|
81
83
|
"tsdoc-check": {},
|
|
@@ -107,6 +109,7 @@ export function skippedEngineOptions(
|
|
|
107
109
|
*/
|
|
108
110
|
export function isFindingEngine(name: EngineName): boolean {
|
|
109
111
|
return (
|
|
112
|
+
name === "code-style-check" ||
|
|
110
113
|
name === "comment-check" ||
|
|
111
114
|
name === "document-style-check" ||
|
|
112
115
|
name === "tsdoc-check"
|
|
@@ -249,6 +252,9 @@ export function buildEngineCommand(
|
|
|
249
252
|
...extra,
|
|
250
253
|
];
|
|
251
254
|
}
|
|
255
|
+
if (name === "code-style-check") {
|
|
256
|
+
return [executable, "--json", ...targets, ...ignoreArguments, ...extra];
|
|
257
|
+
}
|
|
252
258
|
return [
|
|
253
259
|
executable,
|
|
254
260
|
"--json",
|