pr-checkmate 1.22.7 → 1.23.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.
Files changed (140) hide show
  1. package/README.md +101 -333
  2. package/cspell.json +9 -1
  3. package/dist/cli.js +32 -2
  4. package/dist/config/constants.d.ts +25 -1
  5. package/dist/config/constants.js +157 -38
  6. package/dist/config/index.d.ts +15 -2
  7. package/dist/config/index.js +28 -7
  8. package/dist/config/loader.js +5 -1
  9. package/dist/core/checks/dependencies/banned-imports.d.ts +2 -0
  10. package/dist/core/checks/dependencies/banned-imports.js +71 -0
  11. package/dist/core/checks/{circular-deps.d.ts → dependencies/circular-deps.d.ts} +1 -1
  12. package/dist/core/checks/{circular-deps.js → dependencies/circular-deps.js} +9 -10
  13. package/dist/core/checks/{dependency-check.d.ts → dependencies/dependency-check.d.ts} +1 -1
  14. package/dist/core/checks/{dependency-check.js → dependencies/dependency-check.js} +3 -3
  15. package/dist/core/checks/{license-check.d.ts → dependencies/license-check.d.ts} +1 -1
  16. package/dist/core/checks/{license-check.js → dependencies/license-check.js} +3 -3
  17. package/dist/core/checks/{npm-audit.d.ts → dependencies/npm-audit.d.ts} +1 -1
  18. package/dist/core/checks/{npm-audit.js → dependencies/npm-audit.js} +3 -3
  19. package/dist/core/checks/{outdated-deps.d.ts → dependencies/outdated-deps.d.ts} +1 -1
  20. package/dist/core/checks/{outdated-deps.js → dependencies/outdated-deps.js} +3 -3
  21. package/dist/core/checks/dependencies/vuln-scan.d.ts +9 -0
  22. package/dist/core/checks/dependencies/vuln-scan.js +41 -0
  23. package/dist/core/checks/findings.d.ts +37 -1
  24. package/dist/core/checks/findings.js +80 -3
  25. package/dist/core/checks/git/custom-rules.d.ts +2 -0
  26. package/dist/core/checks/git/custom-rules.js +102 -0
  27. package/dist/core/checks/{diff-smell.d.ts → git/diff-smell.d.ts} +1 -1
  28. package/dist/core/checks/{diff-smell.js → git/diff-smell.js} +3 -3
  29. package/dist/core/checks/git/large-files.d.ts +2 -0
  30. package/dist/core/checks/git/large-files.js +83 -0
  31. package/dist/core/checks/git/leftover-debug.d.ts +2 -0
  32. package/dist/core/checks/git/leftover-debug.js +77 -0
  33. package/dist/core/checks/git/lockfile-drift.d.ts +2 -0
  34. package/dist/core/checks/git/lockfile-drift.js +114 -0
  35. package/dist/core/checks/git/merge-conflict.d.ts +2 -0
  36. package/dist/core/checks/git/merge-conflict.js +109 -0
  37. package/dist/core/checks/git/missing-tests.d.ts +2 -0
  38. package/dist/core/checks/git/missing-tests.js +92 -0
  39. package/dist/core/checks/git/todo-fixme.d.ts +7 -0
  40. package/dist/core/checks/git/todo-fixme.js +74 -0
  41. package/dist/core/checks/{cpp-format.d.ts → languages/cpp-format.d.ts} +1 -1
  42. package/dist/core/checks/{cpp-format.js → languages/cpp-format.js} +3 -3
  43. package/dist/core/checks/languages/csharp-format.d.ts +13 -0
  44. package/dist/core/checks/languages/csharp-format.js +52 -0
  45. package/dist/core/checks/languages/go-format.d.ts +8 -0
  46. package/dist/core/checks/languages/go-format.js +48 -0
  47. package/dist/core/checks/languages/go-lint.d.ts +8 -0
  48. package/dist/core/checks/languages/go-lint.js +48 -0
  49. package/dist/core/checks/{kotlin-lint.d.ts → languages/kotlin-lint.d.ts} +1 -1
  50. package/dist/core/checks/{kotlin-lint.js → languages/kotlin-lint.js} +13 -17
  51. package/dist/core/checks/{lint.d.ts → languages/lint.d.ts} +1 -1
  52. package/dist/core/checks/{lint.js → languages/lint.js} +25 -14
  53. package/dist/core/checks/languages/php-format.d.ts +9 -0
  54. package/dist/core/checks/languages/php-format.js +49 -0
  55. package/dist/core/checks/{prettier.d.ts → languages/prettier.d.ts} +1 -1
  56. package/dist/core/checks/{prettier.js → languages/prettier.js} +10 -10
  57. package/dist/core/checks/{python-format.d.ts → languages/python-format.d.ts} +1 -1
  58. package/dist/core/checks/{python-format.js → languages/python-format.js} +3 -3
  59. package/dist/core/checks/{python-lint.d.ts → languages/python-lint.d.ts} +1 -1
  60. package/dist/core/checks/{python-lint.js → languages/python-lint.js} +3 -3
  61. package/dist/core/checks/languages/python-typecheck.d.ts +9 -0
  62. package/dist/core/checks/languages/python-typecheck.js +66 -0
  63. package/dist/core/checks/languages/ruby-lint.d.ts +8 -0
  64. package/dist/core/checks/languages/ruby-lint.js +50 -0
  65. package/dist/core/checks/languages/rust-format.d.ts +9 -0
  66. package/dist/core/checks/languages/rust-format.js +45 -0
  67. package/dist/core/checks/languages/rust-lint.d.ts +8 -0
  68. package/dist/core/checks/languages/rust-lint.js +50 -0
  69. package/dist/core/checks/{swift-lint.d.ts → languages/swift-lint.d.ts} +1 -1
  70. package/dist/core/checks/{swift-lint.js → languages/swift-lint.js} +13 -17
  71. package/dist/core/checks/{typecheck.d.ts → languages/typecheck.d.ts} +1 -1
  72. package/dist/core/checks/{typecheck.js → languages/typecheck.js} +3 -3
  73. package/dist/core/checks/{commitlint.d.ts → pr/commitlint.d.ts} +1 -1
  74. package/dist/core/checks/{commitlint.js → pr/commitlint.js} +4 -4
  75. package/dist/core/checks/{pr-body.d.ts → pr/pr-body.d.ts} +1 -1
  76. package/dist/core/checks/{pr-body.js → pr/pr-body.js} +2 -2
  77. package/dist/core/checks/{pr-size-check.d.ts → pr/pr-size-check.d.ts} +1 -1
  78. package/dist/core/checks/{pr-size-check.js → pr/pr-size-check.js} +13 -11
  79. package/dist/core/checks/{pr-title-lint.d.ts → pr/pr-title-lint.d.ts} +1 -1
  80. package/dist/core/checks/{pr-title-lint.js → pr/pr-title-lint.js} +2 -2
  81. package/dist/core/checks/quality/case-collision.d.ts +8 -0
  82. package/dist/core/checks/quality/case-collision.js +40 -0
  83. package/dist/core/checks/quality/config-validation.d.ts +8 -0
  84. package/dist/core/checks/quality/config-validation.js +63 -0
  85. package/dist/core/checks/quality/coverage.d.ts +2 -0
  86. package/dist/core/checks/quality/coverage.js +63 -0
  87. package/dist/core/checks/{dead-code.d.ts → quality/dead-code.d.ts} +1 -1
  88. package/dist/core/checks/{dead-code.js → quality/dead-code.js} +4 -4
  89. package/dist/core/checks/{duplicate-check.d.ts → quality/duplicate-check.d.ts} +1 -1
  90. package/dist/core/checks/{duplicate-check.js → quality/duplicate-check.js} +11 -15
  91. package/dist/core/checks/quality/license-header.d.ts +7 -0
  92. package/dist/core/checks/quality/license-header.js +74 -0
  93. package/dist/core/checks/{markdown-lint.d.ts → quality/markdown-lint.d.ts} +1 -1
  94. package/dist/core/checks/{markdown-lint.js → quality/markdown-lint.js} +8 -21
  95. package/dist/core/checks/{spellcheck.d.ts → quality/spellcheck.d.ts} +1 -1
  96. package/dist/core/checks/{spellcheck.js → quality/spellcheck.js} +11 -19
  97. package/dist/core/checks/{diff-security.d.ts → security/diff-security.d.ts} +1 -1
  98. package/dist/core/checks/security/diff-security.js +262 -0
  99. package/dist/core/checks/security/dockerfile-security.d.ts +2 -0
  100. package/dist/core/checks/security/dockerfile-security.js +92 -0
  101. package/dist/core/checks/security/migration-safety.d.ts +2 -0
  102. package/dist/core/checks/security/migration-safety.js +110 -0
  103. package/dist/core/checks/{security.d.ts → security/security.d.ts} +1 -1
  104. package/dist/core/checks/{security.js → security/security.js} +4 -4
  105. package/dist/core/checks/{sensitive-file-guard.d.ts → security/sensitive-file-guard.d.ts} +1 -1
  106. package/dist/core/checks/{sensitive-file-guard.js → security/sensitive-file-guard.js} +4 -4
  107. package/dist/core/checks/security/workflow-security.d.ts +2 -0
  108. package/dist/core/checks/security/workflow-security.js +75 -0
  109. package/dist/core/context.js +54 -10
  110. package/dist/core/registry.js +73 -28
  111. package/dist/core/reporters.d.ts +4 -3
  112. package/dist/core/reporters.js +104 -4
  113. package/dist/core/run-checks.js +21 -3
  114. package/dist/core/targets.d.ts +17 -1
  115. package/dist/core/targets.js +74 -4
  116. package/dist/core/types.d.ts +13 -1
  117. package/dist/index.d.ts +1 -1
  118. package/dist/index.js +3 -1
  119. package/dist/init.js +86 -8
  120. package/dist/interfaces/index.d.ts +101 -1
  121. package/dist/scripts/copy-configs.js +6 -1
  122. package/dist/utils/detect-language.d.ts +1 -1
  123. package/dist/utils/detect-language.js +32 -3
  124. package/dist/utils/glob.d.ts +10 -0
  125. package/dist/utils/glob.js +25 -0
  126. package/dist/utils/index.d.ts +1 -1
  127. package/dist/utils/index.js +1 -1
  128. package/eslint-default-rules.json +62 -0
  129. package/eslint.config.mjs +6 -66
  130. package/package.json +3 -1
  131. package/pr-checkmate.schema.json +166 -0
  132. package/src/config/cspell.json +9 -1
  133. package/src/config/eslint-default-rules.json +62 -0
  134. package/src/config/pr-checkmate.schema.json +166 -0
  135. package/dist/core/checks/diff-security.js +0 -145
  136. package/dist/utils/delta.d.ts +0 -5
  137. package/dist/utils/delta.js +0 -53
  138. package/src/config/eslint.config.mjs +0 -180
  139. /package/dist/core/checks/{ruff-shared.d.ts → languages/ruff-shared.d.ts} +0 -0
  140. /package/dist/core/checks/{ruff-shared.js → languages/ruff-shared.js} +0 -0
@@ -0,0 +1,9 @@
1
+ import { Check } from '../../types';
2
+ /**
3
+ * Type-checks changed Python files — the Python analogue of the TypeScript
4
+ * `tsc --noEmit` check. Runner-dependency (needs mypy or pyright on the runner),
5
+ * gracefully skipping when neither is present. Informational by design (like
6
+ * Ruff lint) so teams can adopt gradually; force a checker with
7
+ * `python.typeChecker`, else mypy is tried first, then pyright.
8
+ */
9
+ export declare const pythonTypecheckCheck: Check;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pythonTypecheckCheck = void 0;
4
+ const utils_1 = require("../../../utils");
5
+ const execa_1 = require("../../../utils/execa");
6
+ const targets_1 = require("../../targets");
7
+ const types_1 = require("../../types");
8
+ const ruff_shared_1 = require("./ruff-shared");
9
+ /** Run a type checker over the target files, or return null if the binary is absent. */
10
+ async function runChecker(ctx, bin, targets) {
11
+ const result = await (0, execa_1.execa)(bin, targets, { cwd: ctx.cwd, reject: false });
12
+ if (result.code === 'ENOENT')
13
+ return null;
14
+ return { exitCode: result.exitCode, stdout: result.stdout, stderr: result.stderr };
15
+ }
16
+ /**
17
+ * Type-checks changed Python files — the Python analogue of the TypeScript
18
+ * `tsc --noEmit` check. Runner-dependency (needs mypy or pyright on the runner),
19
+ * gracefully skipping when neither is present. Informational by design (like
20
+ * Ruff lint) so teams can adopt gradually; force a checker with
21
+ * `python.typeChecker`, else mypy is tried first, then pyright.
22
+ */
23
+ exports.pythonTypecheckCheck = {
24
+ name: 'Python Types',
25
+ phase: 'informational',
26
+ applies(ctx) {
27
+ return (ctx.config.python?.enabled !== false &&
28
+ ctx.config.python?.typecheck !== false &&
29
+ ctx.languages.includes('python'));
30
+ },
31
+ async run(ctx) {
32
+ const targets = await (0, targets_1.resolveTargetFiles)(ctx, ruff_shared_1.PY_GLOBS);
33
+ if (targets === null)
34
+ return (0, types_1.skip)('git unavailable');
35
+ if (targets.length === 0)
36
+ return (0, types_1.pass)('no Python files changed');
37
+ const forced = ctx.config.python?.typeChecker;
38
+ const order = forced ? [forced] : ['mypy', 'pyright'];
39
+ let result = null;
40
+ let used = '';
41
+ for (const bin of order) {
42
+ result = await runChecker(ctx, bin, targets);
43
+ if (result) {
44
+ used = bin;
45
+ break;
46
+ }
47
+ }
48
+ if (!result)
49
+ return (0, types_1.skip)(`${forced ?? 'mypy/pyright'} not installed`);
50
+ if (result.exitCode === 0) {
51
+ utils_1.logger.info(`[Python Types]: ✅ No type errors (${used})`);
52
+ return (0, types_1.pass)();
53
+ }
54
+ const lines = [result.stdout, result.stderr]
55
+ .filter(Boolean)
56
+ .join('\n')
57
+ .split('\n')
58
+ .filter(l => /\berror\b|\bwarning\b/i.test(l));
59
+ utils_1.logger.warn(`[Python Types]: ⚠️ type issues (${used}):`);
60
+ lines.slice(0, 10).forEach(l => utils_1.logger.warn(` ${l}`));
61
+ if (lines.length > 10)
62
+ utils_1.logger.warn(` ... and ${lines.length - 10} more`);
63
+ const summary = lines.find(l => /found\s+\d+\s+error/i.test(l)) ?? `${lines.length} type issue(s)`;
64
+ return (0, types_1.warn)(summary.trim());
65
+ },
66
+ };
@@ -0,0 +1,8 @@
1
+ import { Check } from '../../types';
2
+ /**
3
+ * Lints changed Ruby files with RuboCop (which covers both style and layout, so
4
+ * it doubles as the formatting signal). Runner-dependency: needs `rubocop` on
5
+ * the runner, gracefully skipping when absent. Uses the repo's own `.rubocop.yml`
6
+ * when present.
7
+ */
8
+ export declare const rubyLintCheck: Check;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rubyLintCheck = void 0;
4
+ const utils_1 = require("../../../utils");
5
+ const execa_1 = require("../../../utils/execa");
6
+ const targets_1 = require("../../targets");
7
+ const types_1 = require("../../types");
8
+ const RUBY_GLOBS = ['*.rb', '*.rake'];
9
+ /**
10
+ * Lints changed Ruby files with RuboCop (which covers both style and layout, so
11
+ * it doubles as the formatting signal). Runner-dependency: needs `rubocop` on
12
+ * the runner, gracefully skipping when absent. Uses the repo's own `.rubocop.yml`
13
+ * when present.
14
+ */
15
+ exports.rubyLintCheck = {
16
+ name: 'RuboCop',
17
+ phase: 'informational',
18
+ applies(ctx) {
19
+ return ctx.config.ruby?.enabled !== false && ctx.languages.includes('ruby');
20
+ },
21
+ async run(ctx) {
22
+ const targets = await (0, targets_1.resolveTargetFiles)(ctx, RUBY_GLOBS);
23
+ if (targets === null)
24
+ return (0, types_1.skip)('git unavailable');
25
+ if (targets.length === 0)
26
+ return (0, types_1.pass)('no Ruby files changed');
27
+ const result = await (0, execa_1.execa)('rubocop', ['--format', 'simple', ...targets], {
28
+ cwd: ctx.cwd,
29
+ reject: false,
30
+ });
31
+ if (result.code === 'ENOENT')
32
+ return (0, types_1.skip)('rubocop not installed');
33
+ if (result.exitCode === 0) {
34
+ utils_1.logger.info('[RuboCop]: ✅ No offenses found');
35
+ return (0, types_1.pass)();
36
+ }
37
+ const lines = [result.stdout, result.stderr]
38
+ .filter(Boolean)
39
+ .join('\n')
40
+ .split('\n')
41
+ .filter(l => l.trim());
42
+ utils_1.logger.warn('[RuboCop]: ⚠️ offenses detected:');
43
+ lines.slice(0, 10).forEach(l => utils_1.logger.warn(` ${l}`));
44
+ if (lines.length > 10)
45
+ utils_1.logger.warn(` ... and ${lines.length - 10} more line(s)`);
46
+ // RuboCop's summary line looks like "N offenses detected".
47
+ const summary = lines.find(l => /offense/i.test(l)) ?? `${lines.length} line(s) of output`;
48
+ return (0, types_1.warn)(summary.trim());
49
+ },
50
+ };
@@ -0,0 +1,9 @@
1
+ import { Check } from '../../types';
2
+ /**
3
+ * Formats changed Rust code with `cargo fmt` (which respects the crate's edition
4
+ * from Cargo.toml, unlike a bare `rustfmt`). Runner-dependency, gracefully
5
+ * skipping when `cargo` is absent. Read-only in check mode (`cargo fmt --check`);
6
+ * rewrites in place with `cargo fmt` when `write`, so CI can auto-commit —
7
+ * mirrors the Prettier/C++/Go format checks.
8
+ */
9
+ export declare const rustFormatCheck: Check;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rustFormatCheck = void 0;
4
+ const utils_1 = require("../../../utils");
5
+ const execa_1 = require("../../../utils/execa");
6
+ const targets_1 = require("../../targets");
7
+ const types_1 = require("../../types");
8
+ const RUST_GLOBS = ['*.rs'];
9
+ /**
10
+ * Formats changed Rust code with `cargo fmt` (which respects the crate's edition
11
+ * from Cargo.toml, unlike a bare `rustfmt`). Runner-dependency, gracefully
12
+ * skipping when `cargo` is absent. Read-only in check mode (`cargo fmt --check`);
13
+ * rewrites in place with `cargo fmt` when `write`, so CI can auto-commit —
14
+ * mirrors the Prettier/C++/Go format checks.
15
+ */
16
+ exports.rustFormatCheck = {
17
+ name: 'Rustfmt',
18
+ phase: 'format',
19
+ applies(ctx) {
20
+ return ctx.config.rust?.enabled !== false && ctx.languages.includes('rust');
21
+ },
22
+ async run(ctx) {
23
+ const targets = await (0, targets_1.resolveTargetFiles)(ctx, RUST_GLOBS);
24
+ if (targets === null)
25
+ return (0, types_1.skip)('git unavailable');
26
+ if (targets.length === 0)
27
+ return (0, types_1.pass)('no Rust files changed');
28
+ const check = await (0, execa_1.execa)('cargo', ['fmt', '--check'], { cwd: ctx.cwd, reject: false });
29
+ if (check.code === 'ENOENT')
30
+ return (0, types_1.skip)('cargo not installed');
31
+ if (check.exitCode === 0)
32
+ return (0, types_1.pass)();
33
+ if (!ctx.write) {
34
+ utils_1.logger.warn('[Rustfmt]: ⚠️ Rust code is not formatted (cargo fmt --check failed)');
35
+ return (0, types_1.warn)('Rust code needs formatting (run with write to fix)');
36
+ }
37
+ const fix = await (0, execa_1.execa)('cargo', ['fmt'], { cwd: ctx.cwd, reject: false });
38
+ if (fix.exitCode !== 0) {
39
+ utils_1.logger.warn(`[Rustfmt]: ⚠️ cargo fmt failed\n${fix.stderr}`);
40
+ return (0, types_1.warn)('cargo fmt failed to rewrite files');
41
+ }
42
+ utils_1.logger.info('[Rustfmt]: ✅ Reformatted Rust code');
43
+ return (0, types_1.pass)('reformatted Rust code');
44
+ },
45
+ };
@@ -0,0 +1,8 @@
1
+ import { Check } from '../../types';
2
+ /**
3
+ * Lints changed Rust code with Clippy (`cargo clippy -- -D warnings`).
4
+ * Runner-dependency: needs the Rust toolchain + clippy on the runner, and
5
+ * gracefully skips when absent. Clippy compiles the whole crate, so it runs over
6
+ * the crate rather than a file list; the delta check only gates whether it runs.
7
+ */
8
+ export declare const rustLintCheck: Check;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rustLintCheck = void 0;
4
+ const utils_1 = require("../../../utils");
5
+ const execa_1 = require("../../../utils/execa");
6
+ const targets_1 = require("../../targets");
7
+ const types_1 = require("../../types");
8
+ const RUST_GLOBS = ['*.rs'];
9
+ /**
10
+ * Lints changed Rust code with Clippy (`cargo clippy -- -D warnings`).
11
+ * Runner-dependency: needs the Rust toolchain + clippy on the runner, and
12
+ * gracefully skips when absent. Clippy compiles the whole crate, so it runs over
13
+ * the crate rather than a file list; the delta check only gates whether it runs.
14
+ */
15
+ exports.rustLintCheck = {
16
+ name: 'Clippy',
17
+ phase: 'informational',
18
+ applies(ctx) {
19
+ return ctx.config.rust?.enabled !== false && ctx.languages.includes('rust');
20
+ },
21
+ async run(ctx) {
22
+ const targets = await (0, targets_1.resolveTargetFiles)(ctx, RUST_GLOBS);
23
+ if (targets === null)
24
+ return (0, types_1.skip)('git unavailable');
25
+ if (targets.length === 0)
26
+ return (0, types_1.pass)('no Rust files changed');
27
+ const result = await (0, execa_1.execa)('cargo', ['clippy', '--quiet', '--', '-D', 'warnings'], {
28
+ cwd: ctx.cwd,
29
+ reject: false,
30
+ });
31
+ // execa v9 with reject:false resolves (not throws) with `code: 'ENOENT'` when
32
+ // the binary is absent — detect the missing toolchain on the result.
33
+ if (result.code === 'ENOENT')
34
+ return (0, types_1.skip)('cargo/clippy not installed');
35
+ if (result.exitCode === 0) {
36
+ utils_1.logger.info('[Clippy]: ✅ No issues found');
37
+ return (0, types_1.pass)();
38
+ }
39
+ // Clippy writes diagnostics to stderr.
40
+ const lines = result.stderr
41
+ .split('\n')
42
+ .filter(l => /\b(warning|error)\b/.test(l))
43
+ .filter(Boolean);
44
+ utils_1.logger.warn(`[Clippy]: ⚠️ ${lines.length} diagnostic line(s):`);
45
+ lines.slice(0, 10).forEach(l => utils_1.logger.warn(` ${l}`));
46
+ if (lines.length > 10)
47
+ utils_1.logger.warn(` ... and ${lines.length - 10} more`);
48
+ return (0, types_1.warn)(`${lines.length || 'unknown'} clippy diagnostic(s)`);
49
+ },
50
+ };
@@ -1,2 +1,2 @@
1
- import { Check } from '../types';
1
+ import { Check } from '../../types';
2
2
  export declare const swiftLintCheck: Check;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.swiftLintCheck = void 0;
4
- const utils_1 = require("../../utils");
5
- const execa_1 = require("../../utils/execa");
6
- const targets_1 = require("../targets");
7
- const types_1 = require("../types");
4
+ const utils_1 = require("../../../utils");
5
+ const execa_1 = require("../../../utils/execa");
6
+ const targets_1 = require("../../targets");
7
+ const types_1 = require("../../types");
8
8
  const SWIFT_GLOBS = ['*.swift'];
9
9
  exports.swiftLintCheck = {
10
10
  name: 'SwiftLint',
@@ -18,19 +18,15 @@ exports.swiftLintCheck = {
18
18
  return (0, types_1.skip)('git unavailable');
19
19
  if (targets.length === 0)
20
20
  return (0, types_1.pass)('no Swift files changed');
21
- let result;
22
- try {
23
- result = await (0, execa_1.execa)('swiftlint', ['lint', '--quiet', '--path', ctx.cwd], {
24
- cwd: ctx.cwd,
25
- reject: false,
26
- });
27
- }
28
- catch (err) {
29
- if (err.code === 'ENOENT') {
30
- return (0, types_1.skip)('swiftlint not installed');
31
- }
32
- throw err;
33
- }
21
+ const result = await (0, execa_1.execa)('swiftlint', ['lint', '--quiet', '--path', ctx.cwd], {
22
+ cwd: ctx.cwd,
23
+ reject: false,
24
+ });
25
+ // execa v9 with reject:false does NOT throw on a missing binary — it resolves
26
+ // with `code: 'ENOENT'`. Detect the absent toolchain on the result, not via a
27
+ // try/catch (which never fires here and would let a missing linter pass silently).
28
+ if (result.code === 'ENOENT')
29
+ return (0, types_1.skip)('swiftlint not installed');
34
30
  const output = [result.stdout, result.stderr].filter(Boolean).join('\n').trim();
35
31
  if (result.exitCode === 0 || !output) {
36
32
  utils_1.logger.info('[SwiftLint]: ✅ No issues found');
@@ -1,2 +1,2 @@
1
- import { Check } from '../types';
1
+ import { Check } from '../../types';
2
2
  export declare const typecheckCheck: Check;
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.typecheckCheck = void 0;
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
- const utils_1 = require("../../utils");
10
- const execa_1 = require("../../utils/execa");
11
- const types_1 = require("../types");
9
+ const utils_1 = require("../../../utils");
10
+ const execa_1 = require("../../../utils/execa");
11
+ const types_1 = require("../../types");
12
12
  /**
13
13
  * Prefer the consumer project's own TypeScript so its tsconfig is compiled by the
14
14
  * version it was written for; fall back to the compiler bundled with pr-checkmate.
@@ -1,2 +1,2 @@
1
- import { Check } from '../types';
1
+ import { Check } from '../../types';
2
2
  export declare const commitlintCheck: Check;
@@ -7,10 +7,10 @@ exports.commitlintCheck = void 0;
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const node_os_1 = __importDefault(require("node:os"));
9
9
  const node_path_1 = __importDefault(require("node:path"));
10
- const config_1 = require("../../config");
11
- const utils_1 = require("../../utils");
12
- const execa_1 = require("../../utils/execa");
13
- const types_1 = require("../types");
10
+ const config_1 = require("../../../config");
11
+ const utils_1 = require("../../../utils");
12
+ const execa_1 = require("../../../utils/execa");
13
+ const types_1 = require("../../types");
14
14
  const LOCAL_CONFIG_FILES = [
15
15
  'commitlint.config.cjs',
16
16
  'commitlint.config.js',
@@ -1,2 +1,2 @@
1
- import { Check } from '../types';
1
+ import { Check } from '../../types';
2
2
  export declare const prBodyCheck: Check;
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.prBodyCheck = void 0;
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
- const utils_1 = require("../../utils");
9
- const types_1 = require("../types");
8
+ const utils_1 = require("../../../utils");
9
+ const types_1 = require("../../types");
10
10
  // Matches "Closes #123", "Fixes #45", "Resolves #7" or JIRA-style "PROJ-456".
11
11
  const TICKET_PATTERN = /(?:closes?|fixes?|resolves?)\s+#\d+|[A-Z][A-Z0-9]+-\d+/i;
12
12
  exports.prBodyCheck = {
@@ -1,2 +1,2 @@
1
- import { Check } from '../types';
1
+ import { Check } from '../../types';
2
2
  export declare const prSizeCheck: Check;
@@ -1,20 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.prSizeCheck = void 0;
4
- const utils_1 = require("../../utils");
5
- const execa_1 = require("../../utils/execa");
6
- const types_1 = require("../types");
7
- const WARN_FILES = 50;
8
- const WARN_LINES = 1000;
4
+ const utils_1 = require("../../../utils");
5
+ const execa_1 = require("../../../utils/execa");
6
+ const types_1 = require("../../types");
7
+ const DEFAULT_MAX_FILES = 50;
8
+ const DEFAULT_MAX_LINES = 1000;
9
9
  exports.prSizeCheck = {
10
10
  name: 'PR Size',
11
11
  phase: 'informational',
12
12
  applies(ctx) {
13
- return Boolean(ctx.baseSha);
13
+ return ctx.config.prSize?.enabled !== false && Boolean(ctx.baseSha);
14
14
  },
15
15
  async run(ctx) {
16
+ const maxFiles = ctx.config.prSize?.maxFiles ?? DEFAULT_MAX_FILES;
17
+ const maxLines = ctx.config.prSize?.maxLines ?? DEFAULT_MAX_LINES;
16
18
  try {
17
- const { stdout } = await (0, execa_1.execa)('git', ['diff', '--shortstat', ctx.baseSha, 'HEAD'], {
19
+ const { stdout } = await (0, execa_1.execa)('git', ['diff', '--shortstat', ctx.baseSha, ctx.headSha ?? 'HEAD'], {
18
20
  cwd: ctx.cwd,
19
21
  });
20
22
  // "5 files changed, 123 insertions(+), 45 deletions(-)"
@@ -24,10 +26,10 @@ exports.prSizeCheck = {
24
26
  const lines = insertions + deletions;
25
27
  utils_1.logger.info(`[PR Size]: ${fileCount} files changed, ${lines} lines`);
26
28
  const issues = [];
27
- if (fileCount > WARN_FILES)
28
- issues.push(`${fileCount} files (recommended < ${WARN_FILES})`);
29
- if (lines > WARN_LINES)
30
- issues.push(`${lines} lines (recommended < ${WARN_LINES})`);
29
+ if (fileCount > maxFiles)
30
+ issues.push(`${fileCount} files (recommended < ${maxFiles})`);
31
+ if (lines > maxLines)
32
+ issues.push(`${lines} lines (recommended < ${maxLines})`);
31
33
  if (issues.length > 0) {
32
34
  issues.forEach(i => utils_1.logger.warn(`[PR Size]: ⚠️ Large PR: ${i}`));
33
35
  return (0, types_1.warn)(issues.join(', '));
@@ -1,2 +1,2 @@
1
- import { Check } from '../types';
1
+ import { Check } from '../../types';
2
2
  export declare const prTitleLintCheck: Check;
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.prTitleLintCheck = void 0;
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
- const utils_1 = require("../../utils");
9
- const types_1 = require("../types");
8
+ const utils_1 = require("../../../utils");
9
+ const types_1 = require("../../types");
10
10
  const CONVENTIONAL_PREFIX = /^(feat|fix|docs|style|refactor|test|chore|perf|ci|build|revert)(\(.+\))?!?: .+/;
11
11
  exports.prTitleLintCheck = {
12
12
  name: 'PR Title',
@@ -0,0 +1,8 @@
1
+ import { Check } from '../../types';
2
+ /**
3
+ * Flags tracked files whose paths differ only by case (e.g. `Foo.ts` vs
4
+ * `foo.ts`). Such pairs coexist on Linux (case-sensitive) but collide on macOS/
5
+ * Windows and in many Docker layers, silently breaking checkouts and builds.
6
+ * Whole-repo scan (not delta), scoped to `sourcePath` and honouring `ignoreDirs`.
7
+ */
8
+ export declare const caseCollisionCheck: Check;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.caseCollisionCheck = void 0;
4
+ const config_1 = require("../../../config");
5
+ const utils_1 = require("../../../utils");
6
+ const targets_1 = require("../../targets");
7
+ const types_1 = require("../../types");
8
+ /**
9
+ * Flags tracked files whose paths differ only by case (e.g. `Foo.ts` vs
10
+ * `foo.ts`). Such pairs coexist on Linux (case-sensitive) but collide on macOS/
11
+ * Windows and in many Docker layers, silently breaking checkouts and builds.
12
+ * Whole-repo scan (not delta), scoped to `sourcePath` and honouring `ignoreDirs`.
13
+ */
14
+ exports.caseCollisionCheck = {
15
+ name: 'Case Collision',
16
+ phase: 'informational',
17
+ applies(ctx) {
18
+ return ctx.config.caseCollision?.enabled !== false;
19
+ },
20
+ async run(ctx) {
21
+ const files = await (0, targets_1.listTrackedFiles)(ctx, ['*'], (0, config_1.getSourcePaths)());
22
+ if (files.length === 0)
23
+ return (0, types_1.skip)('no tracked files');
24
+ const byLower = new Map();
25
+ for (const f of files) {
26
+ const key = f.toLowerCase();
27
+ let set = byLower.get(key);
28
+ if (!set) {
29
+ set = new Set();
30
+ byLower.set(key, set);
31
+ }
32
+ set.add(f);
33
+ }
34
+ const collisions = [...byLower.values()].filter(set => set.size > 1);
35
+ if (collisions.length === 0)
36
+ return (0, types_1.pass)();
37
+ collisions.forEach(set => utils_1.logger.warn(`[Case Collision]: ⚠️ ${[...set].join(' ↔ ')}`));
38
+ return (0, types_1.warn)(`${collisions.length} case-collision(s) — paths differing only by case`);
39
+ },
40
+ };
@@ -0,0 +1,8 @@
1
+ import { Check } from '../../types';
2
+ /**
3
+ * Validates pr-checkmate.json itself: warns on unknown top-level keys (typos
4
+ * like `mergeConfict` that silently do nothing) and on invalid values in the
5
+ * `severity` map. Reads the raw file so it checks what the user actually wrote,
6
+ * not the merged defaults. `//`-comment keys and `$schema` are ignored.
7
+ */
8
+ export declare const configValidationCheck: Check;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.configValidationCheck = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const config_1 = require("../../../config");
10
+ const utils_1 = require("../../../utils");
11
+ const types_1 = require("../../types");
12
+ const VALID_SEVERITIES = ['error', 'warn', 'off'];
13
+ /**
14
+ * Validates pr-checkmate.json itself: warns on unknown top-level keys (typos
15
+ * like `mergeConfict` that silently do nothing) and on invalid values in the
16
+ * `severity` map. Reads the raw file so it checks what the user actually wrote,
17
+ * not the merged defaults. `//`-comment keys and `$schema` are ignored.
18
+ */
19
+ exports.configValidationCheck = {
20
+ name: 'Config Validation',
21
+ phase: 'informational',
22
+ applies(ctx) {
23
+ return ctx.config.configValidation?.enabled !== false;
24
+ },
25
+ async run(ctx) {
26
+ const file = node_path_1.default.join(ctx.cwd, 'pr-checkmate.json');
27
+ let raw;
28
+ try {
29
+ raw = node_fs_1.default.readFileSync(file, 'utf-8');
30
+ }
31
+ catch {
32
+ return (0, types_1.skip)('no pr-checkmate.json');
33
+ }
34
+ let json;
35
+ try {
36
+ json = JSON.parse(raw);
37
+ }
38
+ catch (err) {
39
+ const msg = err instanceof Error ? err.message.split('\n')[0] : String(err);
40
+ return (0, types_1.warn)(`pr-checkmate.json is not valid JSON: ${msg}`);
41
+ }
42
+ const issues = [];
43
+ for (const key of Object.keys(json)) {
44
+ if (key.startsWith('//') || key === '$schema')
45
+ continue;
46
+ if (!config_1.KNOWN_CONFIG_KEYS.has(key))
47
+ issues.push(`unknown key "${key}"`);
48
+ }
49
+ const sev = json.severity;
50
+ if (sev && typeof sev === 'object') {
51
+ for (const [name, val] of Object.entries(sev)) {
52
+ if (!VALID_SEVERITIES.includes(val)) {
53
+ issues.push(`severity["${name}"] must be error|warn|off (got ${JSON.stringify(val)})`);
54
+ }
55
+ }
56
+ }
57
+ if (issues.length === 0)
58
+ return (0, types_1.pass)();
59
+ issues.slice(0, 10).forEach(i => utils_1.logger.warn(`[Config Validation]: ⚠️ ${i}`));
60
+ const sample = issues.slice(0, 3).join('; ');
61
+ return (0, types_1.warn)(`${issues.length} config issue(s): ${sample}${issues.length > 3 ? ' …' : ''}`);
62
+ },
63
+ };
@@ -0,0 +1,2 @@
1
+ import { Check } from '../../types';
2
+ export declare const coverageCheck: Check;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.coverageCheck = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const types_1 = require("../../types");
10
+ const findings_1 = require("../findings");
11
+ /**
12
+ * Common coverage-report locations across languages/tools. Presence of any one
13
+ * means the test step produced coverage. Reports are usually git-ignored, so we
14
+ * probe the working tree with fs, not git. A client with a non-standard path
15
+ * sets `coverage.reportPath`.
16
+ */
17
+ const DEFAULT_REPORTS = [
18
+ 'coverage/lcov.info', // JS/TS (lcov), C++
19
+ 'lcov.info',
20
+ 'coverage/coverage-final.json', // istanbul
21
+ 'coverage/coverage-summary.json',
22
+ 'coverage/cobertura-coverage.xml', // Cobertura (JS, Python)
23
+ 'coverage/clover.xml',
24
+ 'coverage.xml', // Python (pytest-cov / coverage.py)
25
+ 'coverage.out', // Go
26
+ 'build/reports/jacoco/test/jacocoTestReport.xml', // Kotlin/Java (Gradle)
27
+ 'target/site/jacoco/jacoco.xml', // Java (Maven)
28
+ ];
29
+ exports.coverageCheck = {
30
+ name: 'Coverage',
31
+ phase: 'informational',
32
+ /**
33
+ * Opt-in: only runs when a repo explicitly enables it (`coverage.enabled:
34
+ * true`). Presence-warning by default everywhere would be pure noise in repos
35
+ * that don't collect coverage — so a client turns it on to say "we produce
36
+ * coverage", and the check then guards against the report silently going
37
+ * missing (a broken `--coverage` flag, tests not running, etc.).
38
+ */
39
+ applies(ctx) {
40
+ return ctx.config.coverage?.enabled === true;
41
+ },
42
+ async run(ctx) {
43
+ const cfg = ctx.config.coverage;
44
+ const candidates = cfg?.reportPath
45
+ ? Array.isArray(cfg.reportPath)
46
+ ? cfg.reportPath
47
+ : [cfg.reportPath]
48
+ : DEFAULT_REPORTS;
49
+ const found = candidates.find(rel => {
50
+ try {
51
+ return node_fs_1.default.statSync(node_path_1.default.join(ctx.cwd, rel)).size > 0;
52
+ }
53
+ catch {
54
+ return false;
55
+ }
56
+ });
57
+ if (found)
58
+ return (0, types_1.pass)(`coverage report found: ${found}`);
59
+ const sev = (0, findings_1.severityEmitter)(cfg?.severity, 'warn');
60
+ sev.log(`[Coverage]: ${sev.icon} no coverage report found (looked for ${candidates.length} location(s), e.g. ${candidates.slice(0, 3).join(', ')})`);
61
+ return sev.emit('no coverage report found — is the test step running with coverage enabled?');
62
+ },
63
+ };
@@ -1,2 +1,2 @@
1
- import { Check } from '../types';
1
+ import { Check } from '../../types';
2
2
  export declare const deadCodeCheck: Check;
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.deadCodeCheck = void 0;
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
- const constants_1 = require("../../config/constants");
10
- const utils_1 = require("../../utils");
11
- const execa_1 = require("../../utils/execa");
12
- const types_1 = require("../types");
9
+ const constants_1 = require("../../../config/constants");
10
+ const utils_1 = require("../../../utils");
11
+ const execa_1 = require("../../../utils/execa");
12
+ const types_1 = require("../../types");
13
13
  exports.deadCodeCheck = {
14
14
  name: 'Dead Code',
15
15
  phase: 'informational',