pr-checkmate 1.23.23 → 2.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.md +68 -15
- package/cspell.json +3 -8
- package/dist/cli.js +37 -62
- package/dist/config/constants.d.ts +21 -3
- package/dist/config/constants.js +33 -6
- package/dist/config/pr-checkmate-workflow.yml +33 -327
- package/dist/core/checks/dependencies/banned-imports.js +23 -24
- package/dist/core/checks/dependencies/circular-deps.js +1 -0
- package/dist/core/checks/dependencies/dependency-check.js +1 -0
- package/dist/core/checks/dependencies/grype-scan.js +1 -0
- package/dist/core/checks/dependencies/npm-audit.js +6 -1
- package/dist/core/checks/dependencies/vuln-scan.js +1 -0
- package/dist/core/checks/findings.d.ts +198 -19
- package/dist/core/checks/findings.js +474 -22
- package/dist/core/checks/git/custom-rules.js +21 -16
- package/dist/core/checks/git/diff-smell.d.ts +17 -0
- package/dist/core/checks/git/diff-smell.js +43 -24
- package/dist/core/checks/git/large-files.js +14 -2
- package/dist/core/checks/git/leftover-debug.js +23 -14
- package/dist/core/checks/git/lockfile-drift.js +2 -1
- package/dist/core/checks/git/merge-conflict.js +19 -8
- package/dist/core/checks/git/missing-tests.js +22 -6
- package/dist/core/checks/git/todo-fixme.js +10 -9
- package/dist/core/checks/languages/shellcheck.d.ts +8 -0
- package/dist/core/checks/languages/shellcheck.js +55 -0
- package/dist/core/checks/languages/typecheck.js +1 -0
- package/dist/core/checks/pr/pr-size-check.js +2 -1
- package/dist/core/checks/quality/config-validation.d.ts +14 -4
- package/dist/core/checks/quality/config-validation.js +119 -17
- package/dist/core/checks/quality/dead-code.js +1 -0
- package/dist/core/checks/quality/duplicate-check.js +1 -0
- package/dist/core/checks/quality/license-header.js +12 -2
- package/dist/core/checks/quality/spellcheck.d.ts +50 -0
- package/dist/core/checks/quality/spellcheck.js +141 -13
- package/dist/core/checks/quality/symlinks.d.ts +16 -0
- package/dist/core/checks/quality/symlinks.js +62 -0
- package/dist/core/checks/quality/yaml-lint.js +22 -9
- package/dist/core/checks/security/diff-security.js +111 -28
- package/dist/core/checks/security/dockerfile-security.js +23 -20
- package/dist/core/checks/security/migration-safety.js +19 -17
- package/dist/core/checks/security/sensitive-file-guard.js +37 -5
- package/dist/core/checks/security/workflow-security.d.ts +10 -0
- package/dist/core/checks/security/workflow-security.js +48 -26
- package/dist/core/commands.d.ts +27 -0
- package/dist/core/commands.js +91 -0
- package/dist/core/context.d.ts +12 -3
- package/dist/core/context.js +118 -16
- package/dist/core/install/cache.d.ts +39 -0
- package/dist/core/install/cache.js +99 -0
- package/dist/core/install/doctor.d.ts +35 -0
- package/dist/core/install/doctor.js +145 -0
- package/dist/core/install/ensure.d.ts +60 -0
- package/dist/core/install/ensure.js +169 -0
- package/dist/core/install/lock.d.ts +33 -0
- package/dist/core/install/lock.js +99 -0
- package/dist/core/install/profiles.d.ts +64 -0
- package/dist/core/install/profiles.js +170 -0
- package/dist/core/registry.js +4 -0
- package/dist/core/reporters.d.ts +13 -2
- package/dist/core/reporters.js +145 -104
- package/dist/core/run-checks.js +91 -14
- package/dist/core/targets.js +26 -4
- package/dist/core/types.d.ts +49 -1
- package/dist/init.d.ts +29 -14
- package/dist/init.js +204 -262
- package/dist/interfaces/index.d.ts +130 -0
- package/dist/scripts/generate-install-manifests.d.ts +39 -0
- package/dist/scripts/generate-install-manifests.js +121 -0
- package/dist/scripts/publish-github.js +18 -4
- package/dist/utils/detect-language.d.ts +37 -4
- package/dist/utils/detect-language.js +113 -19
- package/dist/utils/http.d.ts +59 -0
- package/dist/utils/http.js +119 -0
- package/dist/utils/logger.d.ts +52 -6
- package/dist/utils/logger.js +125 -33
- package/dist/utils/pool.d.ts +49 -0
- package/dist/utils/pool.js +124 -0
- package/dist/utils/update-notifier.d.ts +9 -0
- package/dist/utils/update-notifier.js +57 -3
- package/eslint.config.mjs +14 -2
- package/install-manifests/commitlint/package-lock.json +1028 -0
- package/install-manifests/commitlint/package.json +9 -0
- package/install-manifests/core/package-lock.json +1335 -0
- package/install-manifests/core/package.json +11 -0
- package/install-manifests/cpp/package-lock.json +29 -0
- package/install-manifests/cpp/package.json +8 -0
- package/install-manifests/duplicate/package-lock.json +113 -0
- package/install-manifests/duplicate/package.json +8 -0
- package/install-manifests/js/package-lock.json +5099 -0
- package/install-manifests/js/package.json +26 -0
- package/install-manifests/markdown/package-lock.json +1281 -0
- package/install-manifests/markdown/package.json +8 -0
- package/install-manifests/python/package-lock.json +21 -0
- package/install-manifests/python/package.json +8 -0
- package/install-manifests/spellcheck/package-lock.json +1047 -0
- package/install-manifests/spellcheck/package.json +8 -0
- package/package.json +13 -28
- package/pr-checkmate.schema.json +1070 -96
- package/src/config/cspell.json +3 -8
- package/src/config/pr-checkmate-workflow.yml +33 -327
- package/src/config/pr-checkmate.schema.json +1070 -96
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
> PR CheckMate is a security-first PR gate: secret scanning, dependency
|
|
15
15
|
> vulnerability checks, and a signed SBOM + independent VirusTotal scan on
|
|
16
|
-
> every release — plus
|
|
16
|
+
> every release — plus 53 code-quality checks across 12 languages bundled in
|
|
17
17
|
> for free, running in CI on every pull request. The bundled languages need no
|
|
18
18
|
> per-language toolchain setup.
|
|
19
19
|
|
|
@@ -82,6 +82,7 @@ tool installed; the check skips gracefully when the tool is absent.
|
|
|
82
82
|
| C# | `dotnet format` | .NET SDK on the runner |
|
|
83
83
|
| Ruby | RuboCop | `rubocop` on the runner |
|
|
84
84
|
| PHP | PHP-CS-Fixer | `php-cs-fixer` on the runner |
|
|
85
|
+
| Shell | ShellCheck | `shellcheck` on the runner |
|
|
85
86
|
|
|
86
87
|
Secret scanning (gitleaks) and the universal git-diff checks are bundled and run for
|
|
87
88
|
every language.
|
|
@@ -152,8 +153,9 @@ installed version.
|
|
|
152
153
|
|
|
153
154
|
## GitHub Actions
|
|
154
155
|
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
`init` generates this workflow; it is reproduced here so nothing about it is a
|
|
157
|
+
surprise. One job runs the whole registry — which checks run is decided in
|
|
158
|
+
`pr-checkmate.json`, not by copying YAML.
|
|
157
159
|
|
|
158
160
|
```yaml
|
|
159
161
|
name: PR CheckMate
|
|
@@ -162,31 +164,68 @@ on:
|
|
|
162
164
|
branches: [main]
|
|
163
165
|
|
|
164
166
|
permissions:
|
|
165
|
-
contents:
|
|
167
|
+
contents: read
|
|
166
168
|
pull-requests: write
|
|
167
169
|
|
|
168
170
|
jobs:
|
|
169
|
-
|
|
171
|
+
pr-checkmate:
|
|
170
172
|
runs-on: ubuntu-latest
|
|
171
173
|
steps:
|
|
172
|
-
- uses: actions/checkout@v4
|
|
174
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
173
175
|
with: { fetch-depth: 0 }
|
|
174
|
-
- uses: actions/setup-node@v4
|
|
175
|
-
with: { node-version: 24 }
|
|
176
|
+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
177
|
+
with: { node-version: 24, cache: 'npm' }
|
|
176
178
|
- run: npm ci
|
|
177
|
-
-
|
|
179
|
+
- name: Run PR CheckMate
|
|
180
|
+
env:
|
|
181
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
182
|
+
run: npx pr-checkmate all
|
|
178
183
|
```
|
|
179
184
|
|
|
185
|
+
Three lines are load-bearing:
|
|
186
|
+
|
|
187
|
+
- `fetch-depth: 0` — without the full history the PR base is not in the clone, no
|
|
188
|
+
diff range can be built, and every diff-based check skips itself. The run says so
|
|
189
|
+
(`Scan Scope: … set fetch-depth: 0`) rather than reporting a clean pass.
|
|
190
|
+
- `GITHUB_TOKEN` — Actions does not put it in the environment on its own. Without it
|
|
191
|
+
the checks still run, but the summary comment never reaches the PR.
|
|
192
|
+
- no `continue-on-error` — a gate that cannot fail the job is not a gate.
|
|
193
|
+
|
|
194
|
+
### Adopting it on an existing codebase
|
|
195
|
+
|
|
196
|
+
The instinct on an existing codebase is to soften the workflow. Do the opposite: keep
|
|
197
|
+
the gate real and relax individual checks in `pr-checkmate.json`, so whatever you have
|
|
198
|
+
already made clean stays enforced.
|
|
199
|
+
|
|
200
|
+
```jsonc
|
|
201
|
+
{
|
|
202
|
+
// everything advisory to begin with…
|
|
203
|
+
"severityDefaults": { "failOn": "warn" },
|
|
204
|
+
// …except the ones you are ready to enforce
|
|
205
|
+
"severity": {
|
|
206
|
+
"Security Scan": "error",
|
|
207
|
+
"Diff Security": "error",
|
|
208
|
+
"Duplicate Code": "off"
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Promote checks one at a time as the codebase catches up. `pr-checkmate init` also
|
|
214
|
+
offers an advisory workflow if you would rather start there, and it writes a banner
|
|
215
|
+
explaining how to leave that mode. Either way, `init` never overwrites a workflow file
|
|
216
|
+
that already exists.
|
|
217
|
+
|
|
180
218
|
For a runner-dependency language, add its toolchain setup step before the run: Go with
|
|
181
219
|
`actions/setup-go`, Rust with `dtolnay/rust-toolchain`, C# with `actions/setup-dotnet`,
|
|
182
220
|
Ruby with `ruby/setup-ruby` (plus `gem install rubocop`), PHP with
|
|
183
221
|
`shivammathur/setup-php` (tools: `php-cs-fixer`), Kotlin by fetching the `ktlint`
|
|
184
|
-
binary. Swift's `swiftlint` is pre-installed on `macos-latest
|
|
222
|
+
binary. Swift's `swiftlint` is pre-installed on `macos-latest`, and `shellcheck` is
|
|
223
|
+
pre-installed on `ubuntu-latest` — neither needs a setup step. Anything missing is
|
|
185
224
|
skipped, not failed.
|
|
186
225
|
|
|
187
226
|
## Checks
|
|
188
227
|
|
|
189
|
-
|
|
228
|
+
53 checks, grouped by category and run in parallel within each phase:
|
|
190
229
|
|
|
191
230
|
- Universal git-diff (18) — language-agnostic and bundled: merge-conflict markers,
|
|
192
231
|
secret scan, diff security (JS/TS/Python/Go/Kotlin), diff smells, GitHub Actions and
|
|
@@ -196,9 +235,10 @@ skipped, not failed.
|
|
|
196
235
|
- Dependencies (7) — unused/missing, circular, outdated, license compliance, npm audit,
|
|
197
236
|
a cross-language vuln scan (osv-scanner, opt-in), and a direct-dependency vuln scan
|
|
198
237
|
(grype, on by default).
|
|
199
|
-
- Quality (
|
|
238
|
+
- Quality (7) — duplicate code, dead code, multi-language spellcheck, markdown lint,
|
|
239
|
+
YAML lint, broken symlinks, config validation.
|
|
200
240
|
- PR hygiene (4) — size, title, body, and commit-message convention.
|
|
201
|
-
- Per-language (
|
|
241
|
+
- Per-language (17) — lint, format, and type-check for the languages listed above.
|
|
202
242
|
|
|
203
243
|
Each check has its own page in the
|
|
204
244
|
[per-check reference](https://github.com/Mybono/pr_checkmate_public/blob/main/documentation/checks/INDEX.md),
|
|
@@ -206,8 +246,21 @@ covering when it runs, the config keys it reads, and how to turn it off.
|
|
|
206
246
|
|
|
207
247
|
## Configuration
|
|
208
248
|
|
|
209
|
-
Everything lives in `pr-checkmate.json`. Run `npx pr-checkmate init` to
|
|
210
|
-
|
|
249
|
+
Everything lives in one file, `pr-checkmate.json`. Run `npx pr-checkmate init` to
|
|
250
|
+
scaffold it for your detected languages.
|
|
251
|
+
|
|
252
|
+
The generated file is short on purpose: it holds your decisions plus a few empty
|
|
253
|
+
blocks for the settings people tune most. Everything else stays implicit — the
|
|
254
|
+
config is merged over the built-in defaults at load time, so new defaults reach
|
|
255
|
+
you on upgrade without editing anything, and `init` is a first-run step rather
|
|
256
|
+
than something to repeat after every release.
|
|
257
|
+
|
|
258
|
+
**[The full configuration, annotated, with every option at its default →](https://github.com/Mybono/pr_checkmate_public/blob/main/pr-checkmate.json)**
|
|
259
|
+
Copy the block you need into your file. The `$schema` line in the generated
|
|
260
|
+
config also gives your editor autocomplete and a description for every key.
|
|
261
|
+
|
|
262
|
+
Three settings REPLACE their default rather than extending it, so copy the
|
|
263
|
+
default before editing: `ignoreDirs`, `duplicate.ignore`, `deadCode.ignoreFiles`.
|
|
211
264
|
|
|
212
265
|
- Severity map. The one universal control. Key any check by its display name (as it
|
|
213
266
|
appears in the report) and set `"error"` to fail the run, `"warn"` for advisory, or
|
package/cspell.json
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.2",
|
|
3
|
-
"language": "en,
|
|
4
|
-
"import": [
|
|
5
|
-
"@cspell/dict-ru_ru/cspell-ext.json",
|
|
6
|
-
"@cspell/dict-uk-ua/cspell-ext.json",
|
|
7
|
-
"@cspell/dict-he/cspell-ext.json",
|
|
8
|
-
"@cspell/dict-fr-fr/cspell-ext.json",
|
|
9
|
-
"@cspell/dict-es-es/cspell-ext.json"
|
|
10
|
-
],
|
|
3
|
+
"language": "en,en-GB",
|
|
11
4
|
"words": [
|
|
12
5
|
"absdiff",
|
|
13
6
|
"abspath",
|
|
@@ -467,6 +460,7 @@
|
|
|
467
460
|
"eficiente",
|
|
468
461
|
"eigen",
|
|
469
462
|
"EIGEN",
|
|
463
|
+
"EINTEGRITY",
|
|
470
464
|
"EKNFFL",
|
|
471
465
|
"elbert",
|
|
472
466
|
"elementwise",
|
|
@@ -1057,6 +1051,7 @@
|
|
|
1057
1051
|
"oaep",
|
|
1058
1052
|
"Obagi",
|
|
1059
1053
|
"objdetect",
|
|
1054
|
+
"Octo",
|
|
1060
1055
|
"octocat",
|
|
1061
1056
|
"ohlc",
|
|
1062
1057
|
"ohlcv",
|
package/dist/cli.js
CHANGED
|
@@ -2,64 +2,10 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const core_1 = require("./core");
|
|
5
|
+
const commands_1 = require("./core/commands");
|
|
6
|
+
const doctor_1 = require("./core/install/doctor");
|
|
5
7
|
const init_1 = require("./init");
|
|
6
8
|
const utils_1 = require("./utils");
|
|
7
|
-
/** Maps short CLI command names to their registry check names. */
|
|
8
|
-
const COMMAND_TO_CHECK = {
|
|
9
|
-
lint: 'ESLint',
|
|
10
|
-
deps: 'Dependencies',
|
|
11
|
-
dependencies: 'Dependencies',
|
|
12
|
-
'npm-audit': 'NPM Audit',
|
|
13
|
-
prettier: 'Prettier',
|
|
14
|
-
spellcheck: 'Spellcheck',
|
|
15
|
-
security: 'Security Scan',
|
|
16
|
-
circular: 'Circular Deps',
|
|
17
|
-
license: 'License Check',
|
|
18
|
-
'pr-size': 'PR Size',
|
|
19
|
-
'pr-title': 'PR Title',
|
|
20
|
-
outdated: 'Outdated Deps',
|
|
21
|
-
markdown: 'Markdown',
|
|
22
|
-
'yaml-lint': 'YAML Lint',
|
|
23
|
-
typecheck: 'TypeScript',
|
|
24
|
-
'diff-smell': 'Diff Smells',
|
|
25
|
-
'diff-security': 'Diff Security',
|
|
26
|
-
'workflow-security': 'Workflow Security',
|
|
27
|
-
'custom-rules': 'Custom Rules',
|
|
28
|
-
'banned-imports': 'Banned Imports',
|
|
29
|
-
'license-header': 'License Header',
|
|
30
|
-
'config-validation': 'Config Validation',
|
|
31
|
-
'dockerfile-security': 'Dockerfile Security',
|
|
32
|
-
'case-collision': 'Case Collision',
|
|
33
|
-
'vuln-scan': 'Vuln Scan',
|
|
34
|
-
'leftover-debug': 'Leftover Debug',
|
|
35
|
-
'lockfile-drift': 'Lockfile Drift',
|
|
36
|
-
'large-files': 'Large Files',
|
|
37
|
-
'todo-fixme': 'TODO/FIXME',
|
|
38
|
-
'missing-tests': 'Missing Tests',
|
|
39
|
-
coverage: 'Coverage',
|
|
40
|
-
'migration-safety': 'Migration Safety',
|
|
41
|
-
'sensitive-files': 'Sensitive Files',
|
|
42
|
-
'pr-body': 'PR Body',
|
|
43
|
-
duplicate: 'Duplicate Code',
|
|
44
|
-
commitlint: 'Commitlint',
|
|
45
|
-
'cpp-format': 'C++ Format',
|
|
46
|
-
'python-lint': 'Ruff Lint',
|
|
47
|
-
'python-format': 'Ruff Format',
|
|
48
|
-
'python-typecheck': 'Python Types',
|
|
49
|
-
'go-lint': 'Go Vet',
|
|
50
|
-
'go-format': 'Go Format',
|
|
51
|
-
'rust-lint': 'Clippy',
|
|
52
|
-
'rust-format': 'Rustfmt',
|
|
53
|
-
'csharp-format': 'C# Format',
|
|
54
|
-
'ruby-lint': 'RuboCop',
|
|
55
|
-
'php-format': 'PHP CS Fixer',
|
|
56
|
-
};
|
|
57
|
-
/** Commands that run the whole pipeline (or no pipeline at all) and take no siblings. */
|
|
58
|
-
const STANDALONE_COMMANDS = ['init', 'all', 'precommit'];
|
|
59
|
-
/** Flags accepted anywhere on the command line, with what each one means. */
|
|
60
|
-
const FLAGS = {
|
|
61
|
-
'--full': 'review every tracked file instead of the diff (the default outside CI)',
|
|
62
|
-
};
|
|
63
9
|
const argv = process.argv.slice(2);
|
|
64
10
|
/**
|
|
65
11
|
* Flags are separated from positional arguments so they compose with every command
|
|
@@ -75,10 +21,10 @@ const cmd = args[0];
|
|
|
75
21
|
* diff and print a green summary.
|
|
76
22
|
*/
|
|
77
23
|
function rejectUnknownFlags() {
|
|
78
|
-
const unknown = flags.filter(flag => !FLAGS[flag]);
|
|
24
|
+
const unknown = flags.filter(flag => !commands_1.FLAGS[flag]);
|
|
79
25
|
if (unknown.length === 0)
|
|
80
26
|
return;
|
|
81
|
-
const known = Object.entries(FLAGS)
|
|
27
|
+
const known = Object.entries(commands_1.FLAGS)
|
|
82
28
|
.map(([flag, help]) => `${flag} (${help})`)
|
|
83
29
|
.join(', ');
|
|
84
30
|
utils_1.logger.error(`[cli]: Unknown flag(s) "${unknown.join('", "')}". Available: ${known}`);
|
|
@@ -99,6 +45,17 @@ function rejectConflictingScope() {
|
|
|
99
45
|
utils_1.logger.error(`[cli]: "init" takes no flags, got: ${flags.join(', ')}.`);
|
|
100
46
|
process.exit(1);
|
|
101
47
|
}
|
|
48
|
+
// `--all` belongs to `install` alone. Accepting it elsewhere would look like a
|
|
49
|
+
// scope flag and quietly do nothing, which is the failure mode
|
|
50
|
+
// `rejectUnknownFlags` exists to prevent.
|
|
51
|
+
if (flags.includes('--all') && cmd !== 'install') {
|
|
52
|
+
utils_1.logger.error('[cli]: "--all" applies only to "install". Did you mean "--full"?');
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
if (flags.includes('--full') && commands_1.TOOLING_COMMANDS.includes(cmd ?? '')) {
|
|
56
|
+
utils_1.logger.error(`[cli]: "${cmd}" manages tooling and reviews nothing, so "--full" has no meaning.`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
102
59
|
}
|
|
103
60
|
const full = flags.includes('--full');
|
|
104
61
|
/**
|
|
@@ -111,7 +68,7 @@ const full = flags.includes('--full');
|
|
|
111
68
|
* added to the list but not to the branch.
|
|
112
69
|
*/
|
|
113
70
|
function rejectExtraArgs() {
|
|
114
|
-
if (!cmd || !STANDALONE_COMMANDS.includes(cmd) || args.length <= 1)
|
|
71
|
+
if (!cmd || !commands_1.STANDALONE_COMMANDS.includes(cmd) || args.length <= 1)
|
|
115
72
|
return;
|
|
116
73
|
utils_1.logger.error(`[cli]: "${cmd}" takes no other arguments, got: ${args.slice(1).join(', ')}. Run them as a separate command.`);
|
|
117
74
|
process.exit(1);
|
|
@@ -125,6 +82,24 @@ void (async () => {
|
|
|
125
82
|
await (0, init_1.init)();
|
|
126
83
|
process.exit(0);
|
|
127
84
|
}
|
|
85
|
+
// Tooling management. These run no checks — they prepare, inspect or clean
|
|
86
|
+
// up what the checks need, so they never touch the diff or the reporter.
|
|
87
|
+
if (cmd === 'install') {
|
|
88
|
+
const results = await (0, doctor_1.installProfiles)(process.cwd(), flags.includes('--all'));
|
|
89
|
+
const failed = results.filter(r => r.status === 'failed');
|
|
90
|
+
for (const result of failed) {
|
|
91
|
+
utils_1.logger.error(`[install]: ❌ ${result.profile}: ${result.reason}`);
|
|
92
|
+
}
|
|
93
|
+
process.exit(failed.length > 0 ? 1 : 0);
|
|
94
|
+
}
|
|
95
|
+
if (cmd === 'doctor') {
|
|
96
|
+
await (0, doctor_1.runDoctor)();
|
|
97
|
+
process.exit(0);
|
|
98
|
+
}
|
|
99
|
+
if (cmd === 'cache-prune') {
|
|
100
|
+
(0, doctor_1.pruneCache)();
|
|
101
|
+
process.exit(0);
|
|
102
|
+
}
|
|
128
103
|
// Full run: auto-detect the CI platform (GitHub/GitLab/Bitbucket), post the
|
|
129
104
|
// summary to its PR/MR, and allow formatters to write.
|
|
130
105
|
if (!cmd || cmd === 'all') {
|
|
@@ -148,12 +123,12 @@ void (async () => {
|
|
|
148
123
|
// Every remaining argument is a check name, so `pr-checkmate lint spellcheck`
|
|
149
124
|
// runs both in one pass. Unknown names abort the whole run — a typo must never
|
|
150
125
|
// shrink the requested check set silently.
|
|
151
|
-
const unknown = args.filter(arg => !COMMAND_TO_CHECK[arg]);
|
|
126
|
+
const unknown = args.filter(arg => !commands_1.COMMAND_TO_CHECK[arg]);
|
|
152
127
|
if (unknown.length > 0) {
|
|
153
|
-
utils_1.logger.error(`[cli]: Unknown command(s) "${unknown.join('", "')}". Available: ${STANDALONE_COMMANDS.join(', ')}, ${Object.keys(COMMAND_TO_CHECK).join(', ')}`);
|
|
128
|
+
utils_1.logger.error(`[cli]: Unknown command(s) "${unknown.join('", "')}". Available: ${commands_1.STANDALONE_COMMANDS.join(', ')}, ${Object.keys(commands_1.COMMAND_TO_CHECK).join(', ')}`);
|
|
154
129
|
process.exit(1);
|
|
155
130
|
}
|
|
156
|
-
const checkNames = [...new Set(args.map(arg => COMMAND_TO_CHECK[arg]))];
|
|
131
|
+
const checkNames = [...new Set(args.map(arg => commands_1.COMMAND_TO_CHECK[arg]))];
|
|
157
132
|
const report = await (0, core_1.runChecks)({ only: checkNames, reporter: 'stdout', write: true, full });
|
|
158
133
|
process.exit(report.ok ? 0 : 1);
|
|
159
134
|
}
|
|
@@ -70,12 +70,30 @@ export declare const DEFAULT_COMMANDS: {
|
|
|
70
70
|
/**
|
|
71
71
|
* Packages allow-listed for the license check by default.
|
|
72
72
|
*
|
|
73
|
-
* These are
|
|
74
|
-
*
|
|
75
|
-
*
|
|
73
|
+
* These are the optional cspell language dictionaries. Some ship under copyleft
|
|
74
|
+
* licenses (GPL/LGPL), and a client who installs one to spellcheck their own
|
|
75
|
+
* language should not have that turn into a licence finding: the dictionary is
|
|
76
|
+
* data for our check, not code they ship.
|
|
76
77
|
*/
|
|
77
78
|
export declare const DEFAULT_ALLOW_PACKAGES: string[];
|
|
79
|
+
/**
|
|
80
|
+
* Canonical entry point to the PR CheckMate docs. Single source of truth: it is
|
|
81
|
+
* written into every generated `pr-checkmate.json` (via {@link documentation})
|
|
82
|
+
* and printed in the "new version available" notice, so the two can never drift.
|
|
83
|
+
*/
|
|
84
|
+
export declare const DOCS_URL = "https://github.com/Mybono/pr_checkmate_public/tree/main/documentation";
|
|
85
|
+
/**
|
|
86
|
+
* The fully annotated configuration, with every option at its default value.
|
|
87
|
+
*
|
|
88
|
+
* A URL rather than a file inside the package on purpose: half the audience runs
|
|
89
|
+
* pr-checkmate through `npx` on a pipeline and has no `node_modules` at all, so
|
|
90
|
+
* a path into the installed package is a dead end for them. The release workflow
|
|
91
|
+
* publishes `src/config/pr-checkmate.template.json` to the public mirror under
|
|
92
|
+
* this name, which keeps one copy for everyone.
|
|
93
|
+
*/
|
|
94
|
+
export declare const FULL_CONFIG_URL = "https://github.com/Mybono/pr_checkmate_public/blob/main/pr-checkmate.json";
|
|
78
95
|
export declare const documentation: {
|
|
96
|
+
pr_checkmate: string;
|
|
79
97
|
eslint: string;
|
|
80
98
|
typescriptEslint: string;
|
|
81
99
|
prettier: string;
|
package/dist/config/constants.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.KNOWN_CONFIG_KEYS = exports.CONFIG_FILE = exports.documentation = exports.DEFAULT_ALLOW_PACKAGES = exports.DEFAULT_COMMANDS = exports.SOURCE_EXTENSIONS = exports.DUPLICATE_CODE_FORMATS = exports.CONFIG_FILE_PATTERNS = exports.DEAD_CODE_IGNORE_DEFAULTS = exports.DUPLICATE_IGNORE_DEFAULTS = exports.IGNORE_PATTERNS = exports.IGNORED_DIRS = void 0;
|
|
6
|
+
exports.KNOWN_CONFIG_KEYS = exports.CONFIG_FILE = exports.documentation = exports.FULL_CONFIG_URL = exports.DOCS_URL = exports.DEFAULT_ALLOW_PACKAGES = exports.DEFAULT_COMMANDS = exports.SOURCE_EXTENSIONS = exports.DUPLICATE_CODE_FORMATS = exports.CONFIG_FILE_PATTERNS = exports.DEAD_CODE_IGNORE_DEFAULTS = exports.DUPLICATE_IGNORE_DEFAULTS = exports.IGNORE_PATTERNS = exports.IGNORED_DIRS = void 0;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
/**
|
|
9
9
|
* Build output, dependency, tooling, and report directories that are never
|
|
@@ -180,8 +180,8 @@ exports.SOURCE_EXTENSIONS = {
|
|
|
180
180
|
all: ['.ts', '.tsx', '.js', '.jsx', '.json', '.md', '.mdx'],
|
|
181
181
|
};
|
|
182
182
|
exports.DEFAULT_COMMANDS = {
|
|
183
|
-
'npx pr-checkmate init': '
|
|
184
|
-
'npx pr-checkmate all': 'Run all checks
|
|
183
|
+
'npx pr-checkmate init': 'Create pr-checkmate.json and the CI workflow (first-run setup)',
|
|
184
|
+
'npx pr-checkmate all': 'Run all checks over the changes — the PR diff in CI, your branch changes locally',
|
|
185
185
|
'npx pr-checkmate all --full': 'Run all checks over every tracked file, CI included',
|
|
186
186
|
'npx pr-checkmate lint': 'Lint code using ESLint',
|
|
187
187
|
'npx pr-checkmate prettier': 'Format code using Prettier',
|
|
@@ -197,9 +197,10 @@ exports.DEFAULT_COMMANDS = {
|
|
|
197
197
|
/**
|
|
198
198
|
* Packages allow-listed for the license check by default.
|
|
199
199
|
*
|
|
200
|
-
* These are
|
|
201
|
-
*
|
|
202
|
-
*
|
|
200
|
+
* These are the optional cspell language dictionaries. Some ship under copyleft
|
|
201
|
+
* licenses (GPL/LGPL), and a client who installs one to spellcheck their own
|
|
202
|
+
* language should not have that turn into a licence finding: the dictionary is
|
|
203
|
+
* data for our check, not code they ship.
|
|
203
204
|
*/
|
|
204
205
|
exports.DEFAULT_ALLOW_PACKAGES = [
|
|
205
206
|
'@cspell/dict-es-es',
|
|
@@ -208,7 +209,24 @@ exports.DEFAULT_ALLOW_PACKAGES = [
|
|
|
208
209
|
'@cspell/dict-ru_ru',
|
|
209
210
|
'@cspell/dict-uk-ua',
|
|
210
211
|
];
|
|
212
|
+
/**
|
|
213
|
+
* Canonical entry point to the PR CheckMate docs. Single source of truth: it is
|
|
214
|
+
* written into every generated `pr-checkmate.json` (via {@link documentation})
|
|
215
|
+
* and printed in the "new version available" notice, so the two can never drift.
|
|
216
|
+
*/
|
|
217
|
+
exports.DOCS_URL = 'https://github.com/Mybono/pr_checkmate_public/tree/main/documentation';
|
|
218
|
+
/**
|
|
219
|
+
* The fully annotated configuration, with every option at its default value.
|
|
220
|
+
*
|
|
221
|
+
* A URL rather than a file inside the package on purpose: half the audience runs
|
|
222
|
+
* pr-checkmate through `npx` on a pipeline and has no `node_modules` at all, so
|
|
223
|
+
* a path into the installed package is a dead end for them. The release workflow
|
|
224
|
+
* publishes `src/config/pr-checkmate.template.json` to the public mirror under
|
|
225
|
+
* this name, which keeps one copy for everyone.
|
|
226
|
+
*/
|
|
227
|
+
exports.FULL_CONFIG_URL = 'https://github.com/Mybono/pr_checkmate_public/blob/main/pr-checkmate.json';
|
|
211
228
|
exports.documentation = {
|
|
229
|
+
pr_checkmate: exports.DOCS_URL,
|
|
212
230
|
eslint: 'https://eslint.org/docs/latest/rules/',
|
|
213
231
|
typescriptEslint: 'https://typescript-eslint.io/rules/',
|
|
214
232
|
prettier: 'https://prettier.io/docs/en/options.html',
|
|
@@ -227,8 +245,15 @@ exports.KNOWN_CONFIG_KEYS = new Set([
|
|
|
227
245
|
// core
|
|
228
246
|
'sourcePath',
|
|
229
247
|
'ignoreDirs',
|
|
248
|
+
'excludePaths',
|
|
230
249
|
'languages',
|
|
250
|
+
'detect',
|
|
251
|
+
'install',
|
|
231
252
|
'severity',
|
|
253
|
+
'severityDefaults',
|
|
254
|
+
'run',
|
|
255
|
+
'reporter',
|
|
256
|
+
'log',
|
|
232
257
|
'customRules',
|
|
233
258
|
'$schema',
|
|
234
259
|
'commands',
|
|
@@ -242,6 +267,8 @@ exports.KNOWN_CONFIG_KEYS = new Set([
|
|
|
242
267
|
'cspell',
|
|
243
268
|
'markdownlint',
|
|
244
269
|
'yamlLint',
|
|
270
|
+
'shellcheck',
|
|
271
|
+
'symlinks',
|
|
245
272
|
'typecheck',
|
|
246
273
|
// security
|
|
247
274
|
'security',
|