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 CHANGED
@@ -1,107 +1,101 @@
1
1
  # 🔍 PR CheckMate
2
2
 
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.
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
- 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`
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 via npm
20
+ ### 1. Install
21
21
 
22
22
  ```bash
23
- npm install --save-dev pr_checkmate
23
+ npm install --save-dev pr-checkmate
24
24
  ```
25
25
 
26
- ### 2. Run as a CLI command
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
- **`<job>` options:**
32
+ ### 3. Run Checks
33
+ ```
34
+ npx pr-checkmate <job>
35
+ ```
33
36
 
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 |
37
+ #### Jobs
40
38
 
41
- ### 3. Use in GitHub Actions
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
- Automatically check PRs by adding to your workflow:
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
- - uses: actions/checkout@v4
51
- - uses: actions/setup-node@v3
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
- - 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
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
- ## 📦 Features
80
+ ## 🧰 Tech Stack
75
81
 
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
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
- ## 💻 Example Usage in Node.js
84
-
85
- ```javascript
86
- import {
87
- runLint,
88
- runDependencyCheck,
89
- runPrettier,
90
- runSpellcheck
91
- } from 'pr_checkmate';
91
+ ## 📌 Benefits
92
92
 
93
- async function runAllChecks() {
94
- await runLint();
95
- await runPrettier();
96
- await runDependencyCheck();
97
- await runSpellcheck();
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
- LicenseRef Proprietary © 2025
100
+ ## 📜 License
101
+ 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,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
- const pattern = hasConfig ? '.' : config_1.SOURCE_PATH;
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', `${pattern}/**/*`], {
25
- stdio: 'inherit',
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 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.5",
3
+ "version": "1.0.7",
4
4
  "description": "Automated PR quality checks: linting, formatting, dependency analysis, and spellcheck",
5
5
  "keywords": [
6
6
  "github-actions",