pr-checkmate 1.0.5 → 1.0.7
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 +60 -66
- package/dist/scripts/dependency-check.js +1 -1
- package/dist/scripts/index.js +38 -34
- package/dist/scripts/lint.js +13 -6
- package/dist/scripts/prettier-autoformat.js +10 -7
- package/dist/scripts/spellcheck.js +10 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,107 +1,101 @@
|
|
|
1
1
|
# 🔍 PR CheckMate
|
|
2
2
|
|
|
3
|
-
> **PR CheckMate** is
|
|
3
|
+
> **PR CheckMate** is an npm package for automating Pull Request checks.
|
|
4
|
+
> It helps teams maintain code quality by automatically validating linting, formatting, dependencies, and spelling before merging to `main`.
|
|
4
5
|
|
|
5
6
|
---
|
|
6
7
|
|
|
7
8
|
## ⚡ Why PR CheckMate?
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* ✅
|
|
12
|
-
* ✅
|
|
13
|
-
* ✅
|
|
14
|
-
* ✅ **Spellcheck** — checks spelling in code, documentation, and JSON files using `cspell`
|
|
10
|
+
* ✅ Automatic checks on every PR without extra setup.
|
|
11
|
+
* ✅ No need to install ESLint, Prettier, or cspell in your project — all included.
|
|
12
|
+
* ✅ Enforces a unified code style across repositories.
|
|
13
|
+
* ✅ Checks `package.json` / `package-lock.json` for dependency changes.
|
|
14
|
+
* ✅ Spellcheck for code, documentation, and JSON files.
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
18
|
## 🛠 How It Works
|
|
19
19
|
|
|
20
|
-
### 1. Install
|
|
20
|
+
### 1. Install
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
npm install --save-dev
|
|
23
|
+
npm install --save-dev pr-checkmate
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
### 2.
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npx pr-checks <job>
|
|
26
|
+
### 2. Initialize
|
|
30
27
|
```
|
|
28
|
+
npx pr-checkmate init
|
|
29
|
+
```
|
|
30
|
+
This creates a pr-checkmate.json config file, where you can specify the source code path.
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
### 3. Run Checks
|
|
33
|
+
```
|
|
34
|
+
npx pr-checkmate <job>
|
|
35
|
+
```
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|-----|-------------|
|
|
36
|
-
| `lint` | Lint code using ESLint |
|
|
37
|
-
| `prettier` | Format code with Prettier and push changes |
|
|
38
|
-
| `deps` | Check for dependency changes |
|
|
39
|
-
| `spellcheck` | Run spellcheck on source and documentation |
|
|
37
|
+
#### ⚡ Jobs
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
| Job | Description |
|
|
40
|
+
|------------|-------------|
|
|
41
|
+
| `all` | Run all checks: ESLint, dependency check, Prettier, spellcheck |
|
|
42
|
+
| `lint` | Lint code using ESLint |
|
|
43
|
+
| `prettier` | Format code using Prettier |
|
|
44
|
+
| `deps` | Check project dependencies |
|
|
45
|
+
| `spellcheck` | Run spellcheck via cspell |
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
## 📦 Example GitHub Actions Workflow
|
|
44
48
|
|
|
45
49
|
```yaml
|
|
50
|
+
name: PR CheckMate Quality Checks
|
|
51
|
+
|
|
52
|
+
on:
|
|
53
|
+
pull_request:
|
|
54
|
+
|
|
46
55
|
jobs:
|
|
47
56
|
pr-checks:
|
|
48
57
|
runs-on: ubuntu-latest
|
|
49
58
|
steps:
|
|
50
|
-
-
|
|
51
|
-
|
|
59
|
+
- name: 📥 Checkout code
|
|
60
|
+
uses: actions/checkout@v4
|
|
61
|
+
with:
|
|
62
|
+
fetch-depth: 0
|
|
63
|
+
|
|
64
|
+
- name: 🔧 Setup Node.js
|
|
65
|
+
uses: actions/setup-node@v4
|
|
52
66
|
with:
|
|
53
67
|
node-version: 20
|
|
54
|
-
|
|
55
|
-
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
-
|
|
68
|
+
|
|
69
|
+
- name: 📦 Install project dependencies
|
|
70
|
+
run: npm ci
|
|
71
|
+
|
|
72
|
+
- name: 🔍 Run PR CheckMate
|
|
73
|
+
run: npx pr-checkmate all
|
|
59
74
|
```
|
|
75
|
+
> Fully automated process: no need to install ESLint, Prettier, or cspell in your repository.
|
|
60
76
|
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## 🧰 Tech Stack
|
|
64
|
-
|
|
65
|
-
* **Node.js 20** — executes scripts
|
|
66
|
-
* **TypeScript** — fully typed code
|
|
67
|
-
* **ESLint + @typescript-eslint** — code linting
|
|
68
|
-
* **Prettier** — auto-formatting
|
|
69
|
-
* **cspell** — spellchecking
|
|
70
|
-
* **execa** — running CLI commands from Node.js
|
|
71
77
|
|
|
72
78
|
---
|
|
73
79
|
|
|
74
|
-
##
|
|
80
|
+
## 🧰 Tech Stack
|
|
75
81
|
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
82
|
+
* **Node.js 20** — executes CLI scripts
|
|
83
|
+
* **TypeScript** — fully typed code
|
|
84
|
+
* **ESLint + @typescript-eslint** — code linting
|
|
85
|
+
* **Prettier** — auto-formatting
|
|
86
|
+
* **cspell** — spellchecking
|
|
87
|
+
* **execa** — running CLI commands from Node.js
|
|
80
88
|
|
|
81
89
|
---
|
|
82
90
|
|
|
83
|
-
##
|
|
84
|
-
|
|
85
|
-
```javascript
|
|
86
|
-
import {
|
|
87
|
-
runLint,
|
|
88
|
-
runDependencyCheck,
|
|
89
|
-
runPrettier,
|
|
90
|
-
runSpellcheck
|
|
91
|
-
} from 'pr_checkmate';
|
|
91
|
+
## 📌 Benefits
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
runAllChecks();
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
---
|
|
93
|
+
* ✅ Self-contained — the package handles all checks internally
|
|
94
|
+
* ✅ Works locally and in CI/CD (GitHub Actions, GitLab CI, etc.)
|
|
95
|
+
* ✅ Enforces a unified code style across repositories
|
|
96
|
+
* ✅ Automatic formatting and commits when needed
|
|
97
|
+
* ✅ Minimal setup — just `init` and `npx pr-checkmate all`
|
|
104
98
|
|
|
105
|
-
## 📜 License
|
|
106
99
|
|
|
107
|
-
|
|
100
|
+
## 📜 License
|
|
101
|
+
LicenseRef Proprietary © 2025
|
package/dist/scripts/index.js
CHANGED
|
@@ -6,40 +6,44 @@ const prettier_autoformat_1 = require("./prettier-autoformat");
|
|
|
6
6
|
const spellcheck_1 = require("./spellcheck");
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
8
|
const lint_1 = require("./lint");
|
|
9
|
-
/**
|
|
10
|
-
* CLI entry point for PR CheckMate.
|
|
11
|
-
*
|
|
12
|
-
* Usage:
|
|
13
|
-
* npx pr-checks <job>
|
|
14
|
-
*
|
|
15
|
-
* Available jobs:
|
|
16
|
-
* all - Run ESLint + Dependency check + Prettier + spellcheck
|
|
17
|
-
* lint - Run ESLint
|
|
18
|
-
* deps - Check for dependency changes
|
|
19
|
-
* prettier - Run Prettier auto-format
|
|
20
|
-
* spellcheck - Run cspell spellcheck
|
|
21
|
-
*/
|
|
22
9
|
async function runJob(jobName) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
10
|
+
utils_1.logger.info(`🚀 Running job: ${jobName}`);
|
|
11
|
+
try {
|
|
12
|
+
switch (jobName) {
|
|
13
|
+
case 'all':
|
|
14
|
+
await (0, lint_1.runLint)();
|
|
15
|
+
await (0, dependency_check_1.runDependencyCheck)();
|
|
16
|
+
try {
|
|
17
|
+
await (0, prettier_autoformat_1.runPrettier)();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
utils_1.logger.warn('⚠️ Prettier failed, continuing...');
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
await (0, spellcheck_1.runSpellcheck)();
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
utils_1.logger.warn('⚠️ Spellcheck failed, continuing...');
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
case 'lint':
|
|
30
|
+
await (0, lint_1.runLint)();
|
|
31
|
+
break;
|
|
32
|
+
case 'deps':
|
|
33
|
+
await (0, dependency_check_1.runDependencyCheck)();
|
|
34
|
+
break;
|
|
35
|
+
case 'prettier':
|
|
36
|
+
await (0, prettier_autoformat_1.runPrettier)();
|
|
37
|
+
break;
|
|
38
|
+
case 'spellcheck':
|
|
39
|
+
await (0, spellcheck_1.runSpellcheck)();
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
utils_1.logger.warn(`[runJob]: Unknown job "${jobName}". Available: all, lint, deps, prettier, spellcheck`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
utils_1.logger.error(`❌ Job "${jobName}" failed: ${err}`);
|
|
47
|
+
throw err;
|
|
44
48
|
}
|
|
45
49
|
}
|
package/dist/scripts/lint.js
CHANGED
|
@@ -10,7 +10,7 @@ const config_1 = require("../config");
|
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
/**
|
|
12
12
|
* Run ESLint on the project.
|
|
13
|
-
*
|
|
13
|
+
* Ignores node_modules, dist, and .git automatically.
|
|
14
14
|
*
|
|
15
15
|
* @throws Will throw an error if ESLint detects issues that cannot be fixed automatically.
|
|
16
16
|
*/
|
|
@@ -19,15 +19,22 @@ async function runLint() {
|
|
|
19
19
|
const hasLocalConfig = node_fs_1.default.existsSync('eslint.config.mjs') ||
|
|
20
20
|
node_fs_1.default.existsSync('.eslintrc.js') ||
|
|
21
21
|
node_fs_1.default.existsSync('.eslintrc.json');
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const basePath = hasLocalConfig ? '.' : config_1.SOURCE_PATH;
|
|
23
|
+
const ignorePatterns = ['**/node_modules/**', '**/dist/**', '**/.git/**'];
|
|
24
|
+
const args = [
|
|
25
|
+
'eslint',
|
|
26
|
+
basePath,
|
|
27
|
+
'--ext',
|
|
28
|
+
'.ts,.tsx',
|
|
29
|
+
'--fix',
|
|
30
|
+
...ignorePatterns.flatMap(p => ['--ignore-pattern', p]),
|
|
31
|
+
];
|
|
25
32
|
try {
|
|
26
33
|
await (0, execa_1.execa)('npx', args, { stdio: 'inherit' });
|
|
27
|
-
utils_1.logger.info('ESLint passed');
|
|
34
|
+
utils_1.logger.info('✅ ESLint passed');
|
|
28
35
|
}
|
|
29
36
|
catch (err) {
|
|
30
|
-
utils_1.logger.warn('ESLint issues found');
|
|
37
|
+
utils_1.logger.warn('⚠️ ESLint issues found');
|
|
31
38
|
throw err;
|
|
32
39
|
}
|
|
33
40
|
}
|
|
@@ -10,7 +10,7 @@ const config_1 = require("../config");
|
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
/**
|
|
12
12
|
* Run Prettier to auto-format project files.
|
|
13
|
-
*
|
|
13
|
+
* Ignores node_modules, dist, and .git folders automatically.
|
|
14
14
|
*
|
|
15
15
|
* @throws Will throw an error if Prettier fails.
|
|
16
16
|
*/
|
|
@@ -19,15 +19,18 @@ async function runPrettier() {
|
|
|
19
19
|
const hasConfig = node_fs_1.default.existsSync('.prettierrc') ||
|
|
20
20
|
node_fs_1.default.existsSync('.prettierrc.json') ||
|
|
21
21
|
node_fs_1.default.existsSync('prettier.config.js');
|
|
22
|
-
|
|
22
|
+
// Run on whole project if config exists, otherwise only SOURCE_PATH
|
|
23
|
+
const pattern = hasConfig
|
|
24
|
+
? '**/*.{ts,tsx,js,jsx,json,md}'
|
|
25
|
+
: `${config_1.SOURCE_PATH}/**/*.{ts,tsx,js,jsx,json,md}`;
|
|
26
|
+
// Prettier ignore patterns
|
|
27
|
+
const ignorePatterns = ['**/node_modules/**', '**/dist/**', '**/.git/**'];
|
|
23
28
|
try {
|
|
24
|
-
await (0, execa_1.execa)('npx', ['prettier', '--write',
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
utils_1.logger.info('Prettier completed');
|
|
29
|
+
await (0, execa_1.execa)('npx', ['prettier', '--write', pattern, ...ignorePatterns.flatMap(p => ['--ignore-path', p])], { stdio: 'inherit' });
|
|
30
|
+
utils_1.logger.info('✅ Prettier completed');
|
|
28
31
|
}
|
|
29
32
|
catch (err) {
|
|
30
|
-
utils_1.logger.error('Prettier failed');
|
|
33
|
+
utils_1.logger.error('❌ Prettier failed');
|
|
31
34
|
throw err;
|
|
32
35
|
}
|
|
33
36
|
}
|
|
@@ -2,23 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runSpellcheck = runSpellcheck;
|
|
4
4
|
const execa_1 = require("execa");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
5
|
const config_1 = require("../config");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
7
|
/**
|
|
8
|
-
* Run
|
|
9
|
-
*
|
|
8
|
+
* Run cspell to check spelling in project files.
|
|
9
|
+
* Ignores node_modules, dist, and .git folders automatically.
|
|
10
10
|
*
|
|
11
|
-
* @throws Will throw an error if
|
|
11
|
+
* @throws Will throw an error if spelling issues are detected.
|
|
12
12
|
*/
|
|
13
13
|
async function runSpellcheck() {
|
|
14
14
|
utils_1.logger.info('Running spellcheck...');
|
|
15
15
|
const pattern = `${config_1.SOURCE_PATH}/**/*`;
|
|
16
|
+
const ignorePatterns = ['**/node_modules/**', '**/dist/**', '**/.git/**'];
|
|
16
17
|
try {
|
|
17
|
-
await (0, execa_1.execa)('npx', ['cspell', pattern
|
|
18
|
-
|
|
18
|
+
await (0, execa_1.execa)('npx', ['cspell', pattern, ...ignorePatterns.flatMap(p => ['--ignore', p])], {
|
|
19
|
+
stdio: 'inherit',
|
|
20
|
+
});
|
|
21
|
+
utils_1.logger.info('✅ Spellcheck passed');
|
|
19
22
|
}
|
|
20
23
|
catch (err) {
|
|
21
|
-
utils_1.logger.warn('Spellcheck found issues');
|
|
24
|
+
utils_1.logger.warn('⚠️ Spellcheck found issues');
|
|
22
25
|
throw err;
|
|
23
26
|
}
|
|
24
27
|
}
|