pr-checkmate 1.0.6 → 1.0.8

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 CHANGED
@@ -1,107 +1,96 @@
1
1
  # 🔍 PR CheckMate
2
+ > **PR CheckMate** is an npm package for automating Pull Request checks.
3
+ > It helps teams maintain code quality by automatically validating linting, formatting, dependencies, and spelling before merging to `main`.
2
4
 
3
- > **PR CheckMate** is a public npm package for automating Pull Request checks. It helps teams maintain code quality by validating linting, formatting, dependency changes, and spelling before merging to the main branch.
4
-
5
- ---
6
5
 
7
6
  ## ⚡ Why PR CheckMate?
7
+ * ✅ Automatic checks on every PR without extra setup.
8
+ * ✅ No need to install ESLint, Prettier, or cspell in your project — all included.
9
+ * ✅ Enforces a unified code style across repositories.
10
+ * ✅ Checks `package.json` / `package-lock.json` for dependency changes.
11
+ * ✅ Spellcheck for code, documentation, and JSON files.
8
12
 
9
- When a PR is opened, it's essential that the code follows project standards. PR CheckMate automatically checks:
10
-
11
- * ✅ **Linting** — TypeScript/JavaScript code compliance with ESLint rules
12
- * ✅ **Prettier Auto-Format** — automatically formats code and commits changes if needed
13
- * ✅ **Dependency Changes** — checks for updates in `package.json`/`package-lock.json` and warns about potential risks
14
- * ✅ **Spellcheck** — checks spelling in code, documentation, and JSON files using `cspell`
15
-
16
- ---
17
13
 
18
14
  ## 🛠 How It Works
19
-
20
- ### 1. Install via npm
15
+ ### 1. Install
21
16
 
22
17
  ```bash
23
- npm install --save-dev pr_checkmate
18
+ npm install --save-dev pr-checkmate
24
19
  ```
25
20
 
26
- ### 2. Run as a CLI command
21
+ ### 2. Initialize
22
+ ```
23
+ npx pr-checkmate init
24
+ ```
25
+ This creates a pr-checkmate.json config file, where you can specify the source code path.
27
26
 
28
- ```bash
29
- npx pr-checks <job>
27
+ ### 3. Run Checks
28
+ ```
29
+ npx pr-checkmate <job>
30
30
  ```
31
31
 
32
- **`<job>` options:**
32
+ #### ⚡ Jobs
33
+ | Job | Description |
34
+ |------------|-------------|
35
+ | `all` | Run all checks: ESLint, dependency check, Prettier, spellcheck |
36
+ | `lint` | Lint code using ESLint |
37
+ | `prettier` | Format code using Prettier |
38
+ | `deps` | Check project dependencies |
39
+ | `spellcheck` | Run spellcheck via cspell |
40
+ <br>
33
41
 
34
- | Job | Description |
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 |
42
+ ## 📦 Example GitHub Actions Workflow
40
43
 
41
- ### 3. Use in GitHub Actions
44
+ ![pipeline](./assets/pipelineex.png)
42
45
 
43
- Automatically check PRs by adding to your workflow:
44
46
 
45
47
  ```yaml
48
+ name: PR CheckMate Quality Checks
49
+
50
+ on:
51
+ pull_request:
52
+
46
53
  jobs:
47
54
  pr-checks:
48
55
  runs-on: ubuntu-latest
49
56
  steps:
50
- - uses: actions/checkout@v4
51
- - uses: actions/setup-node@v3
57
+ - name: 📥 Checkout code
58
+ uses: actions/checkout@v4
59
+ with:
60
+ fetch-depth: 0
61
+
62
+ - name: 🔧 Setup Node.js
63
+ uses: actions/setup-node@v4
52
64
  with:
53
65
  node-version: 20
54
- - run: npm ci
55
- - run: npx pr-checks lint
56
- - run: npx pr-checks prettier
57
- - run: npx pr-checks deps
58
- - run: npx pr-checks spellcheck
66
+
67
+ - name: 📦 Install project dependencies
68
+ run: npm ci
69
+
70
+ - name: 🔍 Run PR CheckMate
71
+ run: npx pr-checkmate all
59
72
  ```
73
+ > Fully automated process: no need to install ESLint, Prettier, or cspell in your repository.
60
74
 
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
-
72
- ---
73
75
 
74
- ## 📦 Features
76
+ ## 📌 Benefits
75
77
 
76
- * ✅ Works locally and in CI/CD pipelines (GitHub Actions, GitLab CI, etc.)
77
- * ✅ Uses a built-in `logger` for console output
78
- * ✅ Automatically detects the current Git branch and pushes commits after auto-formatting
79
- * ✅ Self-contained package no external environment variables required
78
+ * ✅ Self-contained the package handles all checks internally
79
+ * ✅ Works locally and in CI/CD (GitHub Actions, GitLab CI, etc.)
80
+ * ✅ Enforces a unified code style across repositories
81
+ * ✅ Automatic formatting and commits when needed
82
+ * ✅ Minimal setup — just `init` and `npx pr-checkmate all`
80
83
 
81
- ---
82
84
 
83
- ## 💻 Example Usage in Node.js
84
-
85
- ```javascript
86
- import {
87
- runLint,
88
- runDependencyCheck,
89
- runPrettier,
90
- runSpellcheck
91
- } from 'pr_checkmate';
92
-
93
- async function runAllChecks() {
94
- await runLint();
95
- await runPrettier();
96
- await runDependencyCheck();
97
- await runSpellcheck();
98
- }
99
-
100
- runAllChecks();
101
- ```
85
+ ## 🧰 Tech Stack
102
86
 
103
- ---
87
+ * **Node.js 20** — executes CLI scripts
88
+ * **TypeScript** — fully typed code
89
+ * **ESLint + @typescript-eslint** — code linting
90
+ * **Prettier** — auto-formatting
91
+ * **cspell** — spellchecking
92
+ * **execa** — running CLI commands from Node.js
104
93
 
105
- ## 📜 License
106
94
 
107
- LicenseRef Proprietary © 2025
95
+ ## 📜 License
96
+ LicenseRef Proprietary © 2025
@@ -26,5 +26,5 @@ async function runDependencyCheck() {
26
26
  utils_1.logger.warn(`Source folder "${config_1.SOURCE_PATH}" not found — skipping deeper checks`);
27
27
  return;
28
28
  }
29
- utils_1.logger.info('Dependencies OK');
29
+ utils_1.logger.info('Dependencies OK');
30
30
  }
@@ -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
- switch (jobName) {
24
- case 'all':
25
- await (0, lint_1.runLint)();
26
- await (0, dependency_check_1.runDependencyCheck)();
27
- await (0, prettier_autoformat_1.runPrettier)();
28
- await (0, spellcheck_1.runSpellcheck)();
29
- break;
30
- case 'lint':
31
- await (0, lint_1.runLint)();
32
- break;
33
- case 'deps':
34
- await (0, dependency_check_1.runDependencyCheck)();
35
- break;
36
- case 'prettier':
37
- await (0, prettier_autoformat_1.runPrettier)();
38
- break;
39
- case 'spellcheck':
40
- await (0, spellcheck_1.runSpellcheck)();
41
- break;
42
- default:
43
- utils_1.logger.log('[runJob]: Available jobs: lint, deps, prettier, spellcheck');
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
  }
@@ -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
- * Uses local ESLint configuration if available; otherwise defaults to SOURCE_PATH.
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 args = hasLocalConfig
23
- ? ['eslint', '.', '--ext', '.ts,.tsx', '--fix']
24
- : ['eslint', config_1.SOURCE_PATH, '--ext', '.ts,.tsx', '--fix'];
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
- * If a Prettier config file exists, it runs on the whole project; otherwise on SOURCE_PATH.
13
+ * Ignores node_modules, dist, and .git folders automatically.
14
14
  *
15
15
  * @throws Will throw an error if Prettier fails.
16
16
  */
@@ -19,17 +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
+ // Run on whole project if config exists, otherwise only SOURCE_PATH
22
23
  const pattern = hasConfig
23
- ? '.' // run on whole project if config exists
24
- : `${config_1.SOURCE_PATH}/**/*.{ts,tsx,js,jsx,json,md}`; // otherwise only supported extensions
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/**'];
25
28
  try {
26
- await (0, execa_1.execa)('npx', ['prettier', '--write', pattern], {
27
- stdio: 'inherit',
28
- });
29
- 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');
30
31
  }
31
32
  catch (err) {
32
- utils_1.logger.error('Prettier failed');
33
+ utils_1.logger.error('Prettier failed');
33
34
  throw err;
34
35
  }
35
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 spellcheck using cspell on the project source files.
9
- * Only runs on SOURCE_PATH.
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 cspell detects spelling issues.
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], { stdio: 'inherit' });
18
- utils_1.logger.info('Spellcheck passed');
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-checkmate",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Automated PR quality checks: linting, formatting, dependency analysis, and spellcheck",
5
5
  "keywords": [
6
6
  "github-actions",