pr-checkmate 1.19.19 → 1.20.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/.eslintrc.js ADDED
@@ -0,0 +1,97 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ /**
5
+ * Load user's pr-checkmate.json from project root
6
+ */
7
+ function loadUserConfig() {
8
+ let currentDir = process.cwd();
9
+ let configPath = path.join(currentDir, 'pr-checkmate.json');
10
+
11
+ // If running from node_modules, find project root
12
+ if (currentDir.includes('node_modules')) {
13
+ const parts = currentDir.split(path.sep);
14
+ const nodeModulesIndex = parts.lastIndexOf('node_modules');
15
+ if (nodeModulesIndex > 0) {
16
+ currentDir = parts.slice(0, nodeModulesIndex).join(path.sep);
17
+ configPath = path.join(currentDir, 'pr-checkmate.json');
18
+ }
19
+ }
20
+
21
+ if (fs.existsSync(configPath)) {
22
+ try {
23
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
24
+ console.log(`[ESLint]: ✅ Loaded config from: ${configPath}`);
25
+ return config;
26
+ } catch (err) {
27
+ console.warn(`[ESLint]: ⚠️ Failed to parse ${configPath}:`, err.message);
28
+ }
29
+ }
30
+
31
+ return { sourcePath: 'src', eslint: {} };
32
+ }
33
+
34
+ const userConfig = loadUserConfig();
35
+
36
+ module.exports = {
37
+ root: true,
38
+ parser: '@typescript-eslint/parser',
39
+ parserOptions: {
40
+ ecmaVersion: 2020,
41
+ sourceType: 'module',
42
+ project: './tsconfig.json',
43
+ },
44
+ plugins: ['@typescript-eslint', 'prettier', 'import'],
45
+ extends: [
46
+ 'eslint:recommended',
47
+ 'plugin:@typescript-eslint/recommended',
48
+ 'plugin:prettier/recommended',
49
+ ],
50
+ rules: {
51
+ 'no-console': 'warn',
52
+ 'no-debugger': 'error',
53
+ 'prefer-const': 'error',
54
+ eqeqeq: ['error', 'always'],
55
+ '@typescript-eslint/no-unused-vars': [
56
+ 'error',
57
+ { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
58
+ ],
59
+ '@typescript-eslint/explicit-function-return-type': ['warn'],
60
+ '@typescript-eslint/no-explicit-any': ['warn'],
61
+ '@typescript-eslint/no-floating-promises': ['error'],
62
+ 'space-before-function-paren': 'off',
63
+ 'operator-linebreak': 'off',
64
+ 'max-len': ['warn', { code: 100 }],
65
+ semi: ['error', 'always'],
66
+ quotes: ['error', 'single', { avoidEscape: true }],
67
+ 'object-curly-spacing': ['error', 'always'],
68
+ 'space-infix-ops': 'error',
69
+ 'keyword-spacing': ['error', { before: true, after: true }],
70
+ 'padding-line-between-statements': [
71
+ 'error',
72
+ { blankLine: 'always', prev: 'block', next: '*' },
73
+ { blankLine: 'always', prev: '*', next: 'return' },
74
+ ],
75
+ 'prettier/prettier': [
76
+ 'error',
77
+ {
78
+ semi: true,
79
+ singleQuote: true,
80
+ bracketSpacing: true,
81
+ arrowParens: 'avoid',
82
+ printWidth: 100,
83
+ },
84
+ ],
85
+ // Merge user rules
86
+ ...(userConfig.eslint?.rules || {}),
87
+ },
88
+ ignorePatterns: [
89
+ '**/node_modules/**',
90
+ '**/dist/**',
91
+ '**/.git/**',
92
+ '**/build/**',
93
+ '**/coverage/**',
94
+ // Merge user ignores
95
+ ...(userConfig.eslint?.ignorePatterns || []),
96
+ ],
97
+ };
@@ -0,0 +1,147 @@
1
+ name: PR Checkmate Quality Checks
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main, master, develop]
6
+ types: [opened, synchronize, reopened]
7
+
8
+ permissions:
9
+ contents: write
10
+ pull-requests: write
11
+
12
+ jobs:
13
+ pr-checkmate-all:
14
+ name: PR Checkmate All Checks
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - name: Checkout code
18
+ uses: actions/checkout@v4
19
+ with:
20
+ ref: ${{ github.head_ref }}
21
+ fetch-depth: 0
22
+
23
+ - name: Setup Node.js
24
+ uses: actions/setup-node@v4
25
+ with:
26
+ node-version: 20
27
+
28
+ - name: Install dependencies
29
+ run: npm ci
30
+
31
+ - name: Run PR Checkmate All Checks
32
+ run: npx pr-checkmate all
33
+ continue-on-error: true
34
+
35
+ - name: Auto-commit formatting changes
36
+ run: |
37
+ git config user.name "github-actions[bot]"
38
+ git config user.email "github-actions[bot]@users.noreply.github.com"
39
+ git add -A
40
+ if ! git diff --cached --quiet; then
41
+ git commit -m "style: auto-format code with Prettier"
42
+ git push origin HEAD:${{ github.head_ref }}
43
+ echo "Formatting changes committed and pushed"
44
+ else
45
+ echo "No formatting changes needed"
46
+ fi
47
+ env:
48
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49
+
50
+ lint:
51
+ name: ESLint
52
+ runs-on: ubuntu-latest
53
+ steps:
54
+ - name: Checkout code
55
+ uses: actions/checkout@v4
56
+
57
+ - name: Setup Node.js
58
+ uses: actions/setup-node@v4
59
+ with:
60
+ node-version: 20
61
+
62
+ - name: Install dependencies
63
+ run: npm ci
64
+
65
+ - name: Run ESLint
66
+ run: npx pr-checkmate lint
67
+ continue-on-error: true
68
+
69
+ prettier:
70
+ name: Prettier
71
+ runs-on: ubuntu-latest
72
+ steps:
73
+ - name: Checkout code
74
+ uses: actions/checkout@v4
75
+
76
+ - name: Setup Node.js
77
+ uses: actions/setup-node@v4
78
+ with:
79
+ node-version: 20
80
+
81
+ - name: Install dependencies
82
+ run: npm ci
83
+
84
+ - name: Run Prettier
85
+ run: npx pr-checkmate prettier
86
+ continue-on-error: true
87
+
88
+ spellcheck:
89
+ name: Spellcheck
90
+ runs-on: ubuntu-latest
91
+ steps:
92
+ - name: Checkout code
93
+ uses: actions/checkout@v4
94
+
95
+ - name: Setup Node.js
96
+ uses: actions/setup-node@v4
97
+ with:
98
+ node-version: 20
99
+
100
+ - name: Install dependencies
101
+ run: npm ci
102
+
103
+ - name: Run Spellcheck
104
+ run: npx pr-checkmate spellcheck
105
+ continue-on-error: true
106
+
107
+ security:
108
+ name: Security Scan
109
+ runs-on: ubuntu-latest
110
+ steps:
111
+ - name: Checkout code
112
+ uses: actions/checkout@v4
113
+ with:
114
+ fetch-depth: 0
115
+
116
+ - name: Setup Node.js
117
+ uses: actions/setup-node@v4
118
+ with:
119
+ node-version: 20
120
+
121
+ - name: Install dependencies
122
+ run: npm ci
123
+
124
+ - name: Run Security Scan
125
+ run: npx pr-checkmate security
126
+ continue-on-error: true
127
+
128
+ dependency-check:
129
+ name: Dependency Check
130
+ runs-on: ubuntu-latest
131
+ steps:
132
+ - name: Checkout code
133
+ uses: actions/checkout@v4
134
+ with:
135
+ fetch-depth: 0
136
+
137
+ - name: Setup Node.js
138
+ uses: actions/setup-node@v4
139
+ with:
140
+ node-version: 20
141
+
142
+ - name: Install dependencies
143
+ run: npm ci
144
+
145
+ - name: Run Dependency Check
146
+ run: npx pr-checkmate dependencies
147
+ continue-on-error: true
@@ -9,10 +9,12 @@ const node_path_1 = __importDefault(require("node:path"));
9
9
  const utils_1 = require("../utils");
10
10
  const configFiles = [
11
11
  { source: 'src/config/eslint.config.mjs', dest: 'eslint.config.mjs' },
12
+ { source: 'src/config/.eslintrc.js', dest: '.eslintrc.js' },
12
13
  { source: 'src/config/.prettierrc', dest: '.prettierrc' },
13
14
  { source: 'src/config/.eslintignore', dest: '.eslintignore' },
14
15
  { source: 'src/config/cspell.json', dest: 'cspell.json' },
15
16
  { source: 'tsconfig.json', dest: 'tsconfig.json' },
17
+ { source: 'src/config/pr-checkmate-workflow.yml', dest: 'dist/config/pr-checkmate-workflow.yml' },
16
18
  ];
17
19
  function copyConfigs() {
18
20
  const root = node_path_1.default.resolve(__dirname, '../..');
@@ -24,6 +26,11 @@ function copyConfigs() {
24
26
  utils_1.logger.warn(`[copyConfigs]: ⚠️ Source not found: ${source}`);
25
27
  return;
26
28
  }
29
+ // Create destination directory if it doesn't exist
30
+ const destDir = node_path_1.default.dirname(destPath);
31
+ if (!node_fs_1.default.existsSync(destDir)) {
32
+ node_fs_1.default.mkdirSync(destDir, { recursive: true });
33
+ }
27
34
  node_fs_1.default.copyFileSync(srcPath, destPath);
28
35
  utils_1.logger.log(`[copyConfigs]: ✅ Copied ${dest}`);
29
36
  });
@@ -27,7 +27,7 @@ async function runLint() {
27
27
  }
28
28
  else {
29
29
  utils_1.logger.info(`📦 Using pr-checkmate ESLint config (checking: ${sourcePath})`);
30
- const configPath = (0, config_1.getPackageConfigPath)('eslint.config.mjs');
30
+ const configPath = (0, config_1.getPackageConfigPath)('.eslintrc.js');
31
31
  args = [
32
32
  'eslint',
33
33
  sourceFullPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-checkmate",
3
- "version": "1.19.19",
3
+ "version": "1.20.0",
4
4
  "description": "Automated PR quality checks: linting, formatting, dependency analysis, and spellcheck",
5
5
  "keywords": [
6
6
  "github-actions",
@@ -21,6 +21,7 @@
21
21
  "README.md",
22
22
  "scripts/copy-configs.js",
23
23
  "eslint.config.mjs",
24
+ ".eslintrc.js",
24
25
  ".prettierrc",
25
26
  ".eslintignore",
26
27
  "cspell.json",
@@ -0,0 +1,97 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ /**
5
+ * Load user's pr-checkmate.json from project root
6
+ */
7
+ function loadUserConfig() {
8
+ let currentDir = process.cwd();
9
+ let configPath = path.join(currentDir, 'pr-checkmate.json');
10
+
11
+ // If running from node_modules, find project root
12
+ if (currentDir.includes('node_modules')) {
13
+ const parts = currentDir.split(path.sep);
14
+ const nodeModulesIndex = parts.lastIndexOf('node_modules');
15
+ if (nodeModulesIndex > 0) {
16
+ currentDir = parts.slice(0, nodeModulesIndex).join(path.sep);
17
+ configPath = path.join(currentDir, 'pr-checkmate.json');
18
+ }
19
+ }
20
+
21
+ if (fs.existsSync(configPath)) {
22
+ try {
23
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
24
+ console.log(`[ESLint]: ✅ Loaded config from: ${configPath}`);
25
+ return config;
26
+ } catch (err) {
27
+ console.warn(`[ESLint]: ⚠️ Failed to parse ${configPath}:`, err.message);
28
+ }
29
+ }
30
+
31
+ return { sourcePath: 'src', eslint: {} };
32
+ }
33
+
34
+ const userConfig = loadUserConfig();
35
+
36
+ module.exports = {
37
+ root: true,
38
+ parser: '@typescript-eslint/parser',
39
+ parserOptions: {
40
+ ecmaVersion: 2020,
41
+ sourceType: 'module',
42
+ project: './tsconfig.json',
43
+ },
44
+ plugins: ['@typescript-eslint', 'prettier', 'import'],
45
+ extends: [
46
+ 'eslint:recommended',
47
+ 'plugin:@typescript-eslint/recommended',
48
+ 'plugin:prettier/recommended',
49
+ ],
50
+ rules: {
51
+ 'no-console': 'warn',
52
+ 'no-debugger': 'error',
53
+ 'prefer-const': 'error',
54
+ eqeqeq: ['error', 'always'],
55
+ '@typescript-eslint/no-unused-vars': [
56
+ 'error',
57
+ { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
58
+ ],
59
+ '@typescript-eslint/explicit-function-return-type': ['warn'],
60
+ '@typescript-eslint/no-explicit-any': ['warn'],
61
+ '@typescript-eslint/no-floating-promises': ['error'],
62
+ 'space-before-function-paren': 'off',
63
+ 'operator-linebreak': 'off',
64
+ 'max-len': ['warn', { code: 100 }],
65
+ semi: ['error', 'always'],
66
+ quotes: ['error', 'single', { avoidEscape: true }],
67
+ 'object-curly-spacing': ['error', 'always'],
68
+ 'space-infix-ops': 'error',
69
+ 'keyword-spacing': ['error', { before: true, after: true }],
70
+ 'padding-line-between-statements': [
71
+ 'error',
72
+ { blankLine: 'always', prev: 'block', next: '*' },
73
+ { blankLine: 'always', prev: '*', next: 'return' },
74
+ ],
75
+ 'prettier/prettier': [
76
+ 'error',
77
+ {
78
+ semi: true,
79
+ singleQuote: true,
80
+ bracketSpacing: true,
81
+ arrowParens: 'avoid',
82
+ printWidth: 100,
83
+ },
84
+ ],
85
+ // Merge user rules
86
+ ...(userConfig.eslint?.rules || {}),
87
+ },
88
+ ignorePatterns: [
89
+ '**/node_modules/**',
90
+ '**/dist/**',
91
+ '**/.git/**',
92
+ '**/build/**',
93
+ '**/coverage/**',
94
+ // Merge user ignores
95
+ ...(userConfig.eslint?.ignorePatterns || []),
96
+ ],
97
+ };