pr-checkmate 1.6.0 → 1.7.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/cspell.json +8 -1
- package/dist/config/index.js +31 -5
- package/dist/index.js +5 -4
- package/dist/init.js +28 -35
- package/dist/scripts/dependency-check.js +8 -10
- package/dist/scripts/lint.js +11 -16
- package/dist/scripts/prettier-autoformat.js +26 -41
- package/dist/scripts/spellcheck.js +11 -11
- package/eslint.config.mjs +49 -59
- package/package.json +1 -1
package/cspell.json
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
"version": "0.2",
|
|
3
3
|
"language": "en",
|
|
4
4
|
"words": [
|
|
5
|
+
"Artur",
|
|
6
|
+
"Polishchuk",
|
|
5
7
|
"uiautomator",
|
|
6
8
|
"UiAutomator2",
|
|
7
9
|
"checkmate",
|
|
@@ -13,7 +15,12 @@
|
|
|
13
15
|
"playwright",
|
|
14
16
|
"pytest",
|
|
15
17
|
"creds",
|
|
16
|
-
"UITM"
|
|
18
|
+
"UITM",
|
|
19
|
+
"venv",
|
|
20
|
+
"pycache",
|
|
21
|
+
"wdio",
|
|
22
|
+
"htmlcov",
|
|
23
|
+
"mochawesome"
|
|
17
24
|
],
|
|
18
25
|
"ignorePaths": [
|
|
19
26
|
"**/node_modules/**",
|
package/dist/config/index.js
CHANGED
|
@@ -18,17 +18,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.SOURCE_PATH = exports.config = exports.CONFIG_FILE = void 0;
|
|
21
|
+
exports.getSourcePath = getSourcePath;
|
|
21
22
|
exports.getPackageConfigPath = getPackageConfigPath;
|
|
22
23
|
exports.hasLocalConfig = hasLocalConfig;
|
|
23
24
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
24
25
|
const node_path_1 = __importDefault(require("node:path"));
|
|
25
|
-
|
|
26
|
+
const utils_1 = require("../utils");
|
|
26
27
|
__exportStar(require("./constants"), exports);
|
|
27
28
|
exports.CONFIG_FILE = node_path_1.default.resolve(process.cwd(), 'pr-checkmate.json');
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Load configuration dynamically (always reads fresh config)
|
|
31
|
+
*/
|
|
32
|
+
function loadConfig() {
|
|
33
|
+
try {
|
|
34
|
+
if (node_fs_1.default.existsSync(exports.CONFIG_FILE)) {
|
|
35
|
+
const configContent = node_fs_1.default.readFileSync(exports.CONFIG_FILE, 'utf-8');
|
|
36
|
+
return JSON.parse(configContent);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
utils_1.logger.warn(`⚠️ Failed to read config from ${exports.CONFIG_FILE}, using defaults${err}`);
|
|
41
|
+
}
|
|
42
|
+
return { sourcePath: 'src' };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get SOURCE_PATH dynamically
|
|
46
|
+
* This ensures fresh config is always read
|
|
47
|
+
*/
|
|
48
|
+
function getSourcePath() {
|
|
49
|
+
const config = loadConfig();
|
|
50
|
+
return config.sourcePath;
|
|
51
|
+
}
|
|
32
52
|
/**
|
|
33
53
|
* Get path to package config files
|
|
34
54
|
*/
|
|
@@ -43,3 +63,9 @@ function hasLocalConfig(configNames) {
|
|
|
43
63
|
const projectRoot = process.cwd();
|
|
44
64
|
return configNames.some(name => node_fs_1.default.existsSync(node_path_1.default.join(projectRoot, name)));
|
|
45
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* For backward compatibility, also export as constant
|
|
68
|
+
* But this will be evaluated at module load time
|
|
69
|
+
*/
|
|
70
|
+
exports.config = loadConfig();
|
|
71
|
+
exports.SOURCE_PATH = exports.config.sourcePath;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.runSecurityScan = exports.runSpellcheck = exports.runPrettier = exports.runDependencyCheck = exports.runLint = exports.hasLocalConfig = exports.getPackageConfigPath = exports.getSourcePath = void 0;
|
|
4
4
|
exports.runAllChecks = runAllChecks;
|
|
5
5
|
exports.runChecks = runChecks;
|
|
6
6
|
/**
|
|
@@ -12,6 +12,10 @@ const lint_1 = require("./scripts/lint");
|
|
|
12
12
|
const dependency_check_1 = require("./scripts/dependency-check");
|
|
13
13
|
const prettier_autoformat_1 = require("./scripts/prettier-autoformat");
|
|
14
14
|
const spellcheck_1 = require("./scripts/spellcheck");
|
|
15
|
+
var config_1 = require("./config");
|
|
16
|
+
Object.defineProperty(exports, "getSourcePath", { enumerable: true, get: function () { return config_1.getSourcePath; } });
|
|
17
|
+
Object.defineProperty(exports, "getPackageConfigPath", { enumerable: true, get: function () { return config_1.getPackageConfigPath; } });
|
|
18
|
+
Object.defineProperty(exports, "hasLocalConfig", { enumerable: true, get: function () { return config_1.hasLocalConfig; } });
|
|
15
19
|
var lint_2 = require("./scripts/lint");
|
|
16
20
|
Object.defineProperty(exports, "runLint", { enumerable: true, get: function () { return lint_2.runLint; } });
|
|
17
21
|
var dependency_check_2 = require("./scripts/dependency-check");
|
|
@@ -22,8 +26,6 @@ var spellcheck_2 = require("./scripts/spellcheck");
|
|
|
22
26
|
Object.defineProperty(exports, "runSpellcheck", { enumerable: true, get: function () { return spellcheck_2.runSpellcheck; } });
|
|
23
27
|
var security_1 = require("./scripts/security");
|
|
24
28
|
Object.defineProperty(exports, "runSecurityScan", { enumerable: true, get: function () { return security_1.runSecurityScan; } });
|
|
25
|
-
var utils_1 = require("./utils");
|
|
26
|
-
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return utils_1.logger; } });
|
|
27
29
|
/**
|
|
28
30
|
* Run all checks sequentially
|
|
29
31
|
* @returns Promise that resolves when all checks complete
|
|
@@ -32,7 +34,6 @@ async function runAllChecks() {
|
|
|
32
34
|
await (0, lint_1.runLint)();
|
|
33
35
|
await (0, dependency_check_1.runDependencyCheck)();
|
|
34
36
|
await (0, spellcheck_1.runSpellcheck)();
|
|
35
|
-
// await runSecurityScan();
|
|
36
37
|
await (0, prettier_autoformat_1.runPrettier)(); // Last to commit any fixes
|
|
37
38
|
}
|
|
38
39
|
/**
|
package/dist/init.js
CHANGED
|
@@ -10,9 +10,6 @@ const path_1 = __importDefault(require("path"));
|
|
|
10
10
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
12
|
exports.CONFIG_FILE = path_1.default.resolve(process.cwd(), 'pr-checkmate.json');
|
|
13
|
-
/**
|
|
14
|
-
* Initialize pr-checkmate configuration file.
|
|
15
|
-
*/
|
|
16
13
|
async function init() {
|
|
17
14
|
if (!fs_1.default.existsSync(exports.CONFIG_FILE)) {
|
|
18
15
|
const answers = await inquirer_1.default.prompt([
|
|
@@ -26,43 +23,39 @@ async function init() {
|
|
|
26
23
|
type: 'input',
|
|
27
24
|
name: 'manualPath',
|
|
28
25
|
message: 'Enter path:',
|
|
29
|
-
when:
|
|
30
|
-
validate:
|
|
26
|
+
when: a => a.sourcePath === 'Enter manually',
|
|
27
|
+
validate: input => input.trim().length > 0 || 'Cannot be empty',
|
|
31
28
|
},
|
|
32
29
|
]);
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
};
|
|
30
|
+
const sourcePath = answers.sourcePath === 'Enter manually' ? answers.manualPath : answers.sourcePath;
|
|
31
|
+
const config = { sourcePath };
|
|
36
32
|
fs_1.default.writeFileSync(exports.CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
37
|
-
utils_1.logger.info(
|
|
33
|
+
utils_1.logger.info(`✅ Created pr-checkmate.json with sourcePath: ${sourcePath}`);
|
|
34
|
+
const root = process.cwd();
|
|
35
|
+
const tsconfigPath = path_1.default.join(root, 'tsconfig.json');
|
|
36
|
+
if (!fs_1.default.existsSync(tsconfigPath)) {
|
|
37
|
+
const newTsConfig = {
|
|
38
|
+
compilerOptions: {
|
|
39
|
+
target: 'ES2020',
|
|
40
|
+
module: 'NodeNext',
|
|
41
|
+
outDir: 'dist',
|
|
42
|
+
strict: true,
|
|
43
|
+
rootDir: sourcePath,
|
|
44
|
+
moduleResolution: 'NodeNext',
|
|
45
|
+
esModuleInterop: true,
|
|
46
|
+
resolveJsonModule: true,
|
|
47
|
+
forceConsistentCasingInFileNames: true,
|
|
48
|
+
skipLibCheck: true,
|
|
49
|
+
types: ['node'],
|
|
50
|
+
},
|
|
51
|
+
include: [`${sourcePath}/**/*.ts`],
|
|
52
|
+
exclude: ['node_modules', 'dist'],
|
|
53
|
+
};
|
|
54
|
+
fs_1.default.writeFileSync(tsconfigPath, JSON.stringify(newTsConfig, null, 2));
|
|
55
|
+
utils_1.logger.info('✅ Created tsconfig.json using your sourcePath');
|
|
56
|
+
}
|
|
38
57
|
}
|
|
39
58
|
else {
|
|
40
59
|
utils_1.logger.info('⚡ pr-checkmate.json already exists.');
|
|
41
60
|
}
|
|
42
|
-
const root = process.cwd();
|
|
43
|
-
const tsconfigPath = path_1.default.join(root, 'tsconfig.json');
|
|
44
|
-
if (!fs_1.default.existsSync(tsconfigPath)) {
|
|
45
|
-
const defaultTsConfig = {
|
|
46
|
-
compilerOptions: {
|
|
47
|
-
target: 'ES2020',
|
|
48
|
-
module: 'NodeNext',
|
|
49
|
-
outDir: 'dist',
|
|
50
|
-
strict: true,
|
|
51
|
-
rootDir: 'src',
|
|
52
|
-
moduleResolution: 'NodeNext',
|
|
53
|
-
esModuleInterop: true,
|
|
54
|
-
resolveJsonModule: true,
|
|
55
|
-
forceConsistentCasingInFileNames: true,
|
|
56
|
-
skipLibCheck: true,
|
|
57
|
-
types: ['node'],
|
|
58
|
-
},
|
|
59
|
-
include: ['src/**/*.ts'],
|
|
60
|
-
exclude: ['node_modules', 'dist'],
|
|
61
|
-
};
|
|
62
|
-
fs_1.default.writeFileSync(tsconfigPath, JSON.stringify(defaultTsConfig, null, 2));
|
|
63
|
-
utils_1.logger.info('✅ Created default tsconfig.json');
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
utils_1.logger.info('⚡ tsconfig.json already exists.');
|
|
67
|
-
}
|
|
68
61
|
}
|
|
@@ -9,10 +9,7 @@ const utils_1 = require("../utils");
|
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
10
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* Currently, only validates existence; can be extended for dependency checks.
|
|
14
|
-
*
|
|
15
|
-
* @throws Will throw an error if deeper checks are added and fail.
|
|
12
|
+
* Basic dependency checks with sourcePath support
|
|
16
13
|
*/
|
|
17
14
|
async function runDependencyCheck() {
|
|
18
15
|
utils_1.logger.info('📦 Checking dependencies...');
|
|
@@ -22,16 +19,17 @@ async function runDependencyCheck() {
|
|
|
22
19
|
utils_1.logger.warn('⚠️ No package.json — skipping dependency check');
|
|
23
20
|
return;
|
|
24
21
|
}
|
|
25
|
-
const
|
|
22
|
+
const sourcePath = (0, config_1.getSourcePath)();
|
|
23
|
+
const sourceFolder = node_path_1.default.join(projectRoot, sourcePath);
|
|
26
24
|
if (!node_fs_1.default.existsSync(sourceFolder)) {
|
|
27
|
-
utils_1.logger.warn(`⚠️ Source folder "${
|
|
25
|
+
utils_1.logger.warn(`⚠️ Source folder "${sourcePath}" not found — skipping deeper checks`);
|
|
28
26
|
return;
|
|
29
27
|
}
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
return sourceFolder.includes(
|
|
28
|
+
const ignored = config_1.IGNORE_PATTERNS.some(pattern => {
|
|
29
|
+
const clean = pattern.replace(/\*\*/g, '').replace(/\//g, '').trim();
|
|
30
|
+
return clean && sourceFolder.includes(clean);
|
|
33
31
|
});
|
|
34
|
-
if (
|
|
32
|
+
if (ignored) {
|
|
35
33
|
utils_1.logger.warn('⚠️ Source path contains ignored directories');
|
|
36
34
|
}
|
|
37
35
|
utils_1.logger.info('✅ Dependencies OK');
|
package/dist/scripts/lint.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.runLint = runLint;
|
|
4
7
|
const config_1 = require("../config");
|
|
5
8
|
const utils_1 = require("../utils");
|
|
6
9
|
const execa_1 = require("execa");
|
|
7
|
-
|
|
8
|
-
* Run ESLint on the project.
|
|
9
|
-
* Uses local ESLint configuration if available; otherwise uses packaged config.
|
|
10
|
-
*/
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
11
|
async function runLint() {
|
|
12
12
|
utils_1.logger.info('🔍 Running ESLint...');
|
|
13
13
|
const projectRoot = process.cwd();
|
|
14
|
+
const sourcePath = (0, config_1.getSourcePath)();
|
|
15
|
+
const sourceFullPath = node_path_1.default.join(projectRoot, sourcePath);
|
|
14
16
|
const hasLocal = (0, config_1.hasLocalConfig)([
|
|
15
17
|
'eslint.config.mjs',
|
|
16
18
|
'eslint.config.js',
|
|
@@ -20,30 +22,23 @@ async function runLint() {
|
|
|
20
22
|
]);
|
|
21
23
|
let args;
|
|
22
24
|
if (hasLocal) {
|
|
23
|
-
utils_1.logger.info(
|
|
24
|
-
args = [
|
|
25
|
-
'eslint',
|
|
26
|
-
projectRoot,
|
|
27
|
-
'--ext',
|
|
28
|
-
'.ts,.tsx,.js,.jsx',
|
|
29
|
-
'--fix',
|
|
30
|
-
...config_1.IGNORE_PATTERNS.flatMap(pattern => ['--ignore-pattern', pattern]),
|
|
31
|
-
];
|
|
25
|
+
utils_1.logger.info(`📋 Using local ESLint config (checking: ${sourcePath})`);
|
|
26
|
+
args = ['eslint', sourceFullPath, '--ext', '.ts,.tsx,.js,.jsx', '--fix'];
|
|
32
27
|
}
|
|
33
28
|
else {
|
|
34
|
-
utils_1.logger.info(
|
|
29
|
+
utils_1.logger.info(`📦 Using pr-checkmate ESLint config (checking: ${sourcePath})`);
|
|
35
30
|
const configPath = (0, config_1.getPackageConfigPath)('eslint.config.mjs');
|
|
36
31
|
args = [
|
|
37
32
|
'eslint',
|
|
38
|
-
|
|
33
|
+
sourceFullPath,
|
|
39
34
|
'--ext',
|
|
40
35
|
'.ts,.tsx,.js,.jsx',
|
|
41
36
|
'--fix',
|
|
42
37
|
'--config',
|
|
43
38
|
configPath,
|
|
44
|
-
...config_1.IGNORE_PATTERNS.flatMap(pattern => ['--ignore-pattern', pattern]),
|
|
45
39
|
];
|
|
46
40
|
}
|
|
41
|
+
config_1.IGNORE_PATTERNS.forEach(p => args.push('--ignore-pattern', p));
|
|
47
42
|
try {
|
|
48
43
|
await (0, execa_1.execa)('npx', args, { stdio: 'inherit' });
|
|
49
44
|
utils_1.logger.info('✅ ESLint passed');
|
|
@@ -13,37 +13,31 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
13
13
|
* Create temporary .prettierignore file with ignore patterns
|
|
14
14
|
*/
|
|
15
15
|
function createTempIgnoreFile() {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return tempIgnoreFile;
|
|
16
|
+
const file = node_path_1.default.join(process.cwd(), '.prettierignore.temp');
|
|
17
|
+
node_fs_1.default.writeFileSync(file, config_1.IGNORE_PATTERNS.join('\n'), 'utf-8');
|
|
18
|
+
return file;
|
|
20
19
|
}
|
|
21
20
|
/**
|
|
22
|
-
* Remove temporary
|
|
21
|
+
* Remove temporary file
|
|
23
22
|
*/
|
|
24
23
|
function cleanupTempIgnoreFile(filePath) {
|
|
25
24
|
try {
|
|
26
|
-
if (node_fs_1.default.existsSync(filePath))
|
|
25
|
+
if (node_fs_1.default.existsSync(filePath))
|
|
27
26
|
node_fs_1.default.unlinkSync(filePath);
|
|
28
|
-
}
|
|
29
27
|
}
|
|
30
28
|
catch (err) {
|
|
31
|
-
utils_1.logger.warn(`[cleanupTempIgnoreFile]: ⚠️ Failed
|
|
29
|
+
utils_1.logger.warn(`[cleanupTempIgnoreFile]: ⚠️ Failed cleanup: ${filePath}\n${err}`);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
async function runPrettier() {
|
|
35
33
|
utils_1.logger.info('🎨 Running Prettier...');
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
'.prettierrc.json',
|
|
42
|
-
'.prettierrc.js',
|
|
43
|
-
'prettier.config.js',
|
|
44
|
-
]);
|
|
45
|
-
let tempIgnoreFile = null;
|
|
34
|
+
const root = process.cwd();
|
|
35
|
+
const sourcePath = (0, config_1.getSourcePath)();
|
|
36
|
+
const targetGlob = `${node_path_1.default.join(root, sourcePath)}/**/*.{ts,tsx,js,jsx,json,md}`;
|
|
37
|
+
const projectIgnore = node_path_1.default.join(root, '.prettierignore');
|
|
38
|
+
const gitignore = node_path_1.default.join(root, '.gitignore');
|
|
46
39
|
let ignorePath;
|
|
40
|
+
let temp = null;
|
|
47
41
|
if (node_fs_1.default.existsSync(projectIgnore)) {
|
|
48
42
|
ignorePath = projectIgnore;
|
|
49
43
|
}
|
|
@@ -51,32 +45,24 @@ async function runPrettier() {
|
|
|
51
45
|
ignorePath = gitignore;
|
|
52
46
|
}
|
|
53
47
|
else {
|
|
54
|
-
|
|
55
|
-
ignorePath =
|
|
48
|
+
temp = createTempIgnoreFile();
|
|
49
|
+
ignorePath = temp;
|
|
56
50
|
}
|
|
51
|
+
const hasLocal = (0, config_1.hasLocalConfig)([
|
|
52
|
+
'.prettierrc',
|
|
53
|
+
'.prettierrc.json',
|
|
54
|
+
'.prettierrc.js',
|
|
55
|
+
'prettier.config.js',
|
|
56
|
+
]);
|
|
57
57
|
let args;
|
|
58
58
|
if (hasLocal) {
|
|
59
|
-
utils_1.logger.info(
|
|
60
|
-
args = [
|
|
61
|
-
'prettier',
|
|
62
|
-
'--write',
|
|
63
|
-
`${projectRoot}/**/*.{ts,tsx,js,jsx,json,md}`,
|
|
64
|
-
'--ignore-path',
|
|
65
|
-
ignorePath,
|
|
66
|
-
];
|
|
59
|
+
utils_1.logger.info(`📋 Using local Prettier config (checking: ${sourcePath})`);
|
|
60
|
+
args = ['prettier', '--write', targetGlob, '--ignore-path', ignorePath];
|
|
67
61
|
}
|
|
68
62
|
else {
|
|
69
|
-
utils_1.logger.info(
|
|
63
|
+
utils_1.logger.info(`📦 Using pr-checkmate Prettier config (checking: ${sourcePath})`);
|
|
70
64
|
const configPath = (0, config_1.getPackageConfigPath)('.prettierrc');
|
|
71
|
-
args = [
|
|
72
|
-
'prettier',
|
|
73
|
-
'--write',
|
|
74
|
-
`${projectRoot}/**/*.{ts,tsx,js,jsx,json,md}`,
|
|
75
|
-
'--config',
|
|
76
|
-
configPath,
|
|
77
|
-
'--ignore-path',
|
|
78
|
-
ignorePath,
|
|
79
|
-
];
|
|
65
|
+
args = ['prettier', '--write', targetGlob, '--config', configPath, '--ignore-path', ignorePath];
|
|
80
66
|
}
|
|
81
67
|
try {
|
|
82
68
|
await (0, execa_1.execa)('npx', args, { stdio: 'inherit' });
|
|
@@ -87,8 +73,7 @@ async function runPrettier() {
|
|
|
87
73
|
throw err;
|
|
88
74
|
}
|
|
89
75
|
finally {
|
|
90
|
-
if (
|
|
91
|
-
cleanupTempIgnoreFile(
|
|
92
|
-
}
|
|
76
|
+
if (temp)
|
|
77
|
+
cleanupTempIgnoreFile(temp);
|
|
93
78
|
}
|
|
94
79
|
}
|
|
@@ -4,31 +4,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.runSpellcheck = runSpellcheck;
|
|
7
|
+
const config_1 = require("../config");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
7
9
|
const execa_1 = require("execa");
|
|
8
10
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const utils_1 = require("../utils");
|
|
10
|
-
const config_1 = require("../config");
|
|
11
11
|
/**
|
|
12
|
-
* Build
|
|
12
|
+
* Build cspell patterns + ignore patterns
|
|
13
13
|
*/
|
|
14
14
|
function buildSpellcheckPatterns(projectRoot, sourcePath) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return [basePattern, ...excludeArgs];
|
|
15
|
+
const base = node_path_1.default.join(projectRoot, sourcePath, '**/*.{ts,tsx,js,jsx,md,mdx,json}');
|
|
16
|
+
const excludes = config_1.IGNORE_PATTERNS.map(p => `--exclude=${p}`);
|
|
17
|
+
return [base, ...excludes];
|
|
19
18
|
}
|
|
20
19
|
async function runSpellcheck() {
|
|
21
|
-
utils_1.logger.info('🔤 Running
|
|
20
|
+
utils_1.logger.info('🔤 Running Spellcheck...');
|
|
22
21
|
const projectRoot = process.cwd();
|
|
23
|
-
const
|
|
22
|
+
const sourcePath = (0, config_1.getSourcePath)();
|
|
23
|
+
const patterns = buildSpellcheckPatterns(projectRoot, sourcePath);
|
|
24
24
|
const hasLocal = (0, config_1.hasLocalConfig)(['cspell.json', '.cspell.json', 'cspell.config.json']);
|
|
25
25
|
let args;
|
|
26
26
|
if (hasLocal) {
|
|
27
|
-
utils_1.logger.info(
|
|
27
|
+
utils_1.logger.info(`📋 Using local cspell config (checking: ${sourcePath})`);
|
|
28
28
|
args = ['cspell', ...patterns, '--no-progress'];
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
|
-
utils_1.logger.info(
|
|
31
|
+
utils_1.logger.info(`📦 Using pr-checkmate cspell config (checking: ${sourcePath})`);
|
|
32
32
|
const configPath = (0, config_1.getPackageConfigPath)('cspell.json');
|
|
33
33
|
args = ['cspell', ...patterns, '--config', configPath, '--no-progress'];
|
|
34
34
|
}
|
package/eslint.config.mjs
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
1
2
|
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
|
2
3
|
import tsParser from '@typescript-eslint/parser';
|
|
3
4
|
import prettierPlugin from 'eslint-plugin-prettier';
|
|
4
5
|
|
|
6
|
+
const config = JSON.parse(fs.readFileSync('./pr-checkmate.json', 'utf-8'));
|
|
7
|
+
const SRC = config.sourcePath;
|
|
8
|
+
|
|
5
9
|
export default [
|
|
6
10
|
{
|
|
7
|
-
files: [
|
|
11
|
+
files: [`${SRC}/**/*.{ts,tsx,js,jsx}`],
|
|
12
|
+
|
|
13
|
+
ignores: [
|
|
14
|
+
'**/node_modules/**',
|
|
15
|
+
'**/dist/**',
|
|
16
|
+
'**/.git/**',
|
|
17
|
+
'**/build/**',
|
|
18
|
+
'**/coverage/**',
|
|
19
|
+
],
|
|
20
|
+
|
|
8
21
|
languageOptions: {
|
|
9
22
|
parser: tsParser,
|
|
10
23
|
parserOptions: {
|
|
@@ -19,64 +32,41 @@ export default [
|
|
|
19
32
|
prettier: prettierPlugin,
|
|
20
33
|
},
|
|
21
34
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
arrowParens: 'avoid',
|
|
58
|
-
printWidth: 100,
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
{
|
|
65
|
-
files: [
|
|
66
|
-
'*.config.js',
|
|
67
|
-
'*.config.ts',
|
|
68
|
-
'jest.config.js',
|
|
69
|
-
'wdio.config.js',
|
|
70
|
-
'playwright.config.js',
|
|
71
|
-
'cypress.config.js',
|
|
72
|
-
],
|
|
73
|
-
languageOptions: {
|
|
74
|
-
parser: tsParser,
|
|
75
|
-
parserOptions: {
|
|
76
|
-
ecmaVersion: 2020,
|
|
77
|
-
sourceType: 'module',
|
|
78
|
-
project: undefined,
|
|
35
|
+
rules: {
|
|
36
|
+
'no-console': 'warn',
|
|
37
|
+
'no-debugger': 'error',
|
|
38
|
+
'prefer-const': 'error',
|
|
39
|
+
eqeqeq: ['error', 'always'],
|
|
40
|
+
'@typescript-eslint/no-unused-vars': [
|
|
41
|
+
'error',
|
|
42
|
+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
|
43
|
+
],
|
|
44
|
+
'@typescript-eslint/explicit-function-return-type': ['warn'],
|
|
45
|
+
'@typescript-eslint/no-explicit-any': ['warn'],
|
|
46
|
+
'@typescript-eslint/no-floating-promises': ['error'],
|
|
47
|
+
'space-before-function-paren': 'off',
|
|
48
|
+
'operator-linebreak': 'off',
|
|
49
|
+
'max-len': ['warn', { code: 100 }],
|
|
50
|
+
semi: ['error', 'always'],
|
|
51
|
+
quotes: ['error', 'single', { avoidEscape: true }],
|
|
52
|
+
'object-curly-spacing': ['error', 'always'],
|
|
53
|
+
'space-infix-ops': 'error',
|
|
54
|
+
'keyword-spacing': ['error', { before: true, after: true }],
|
|
55
|
+
'padding-line-between-statements': [
|
|
56
|
+
'error',
|
|
57
|
+
{ blankLine: 'always', prev: 'block', next: '*' },
|
|
58
|
+
{ blankLine: 'always', prev: '*', next: 'return' },
|
|
59
|
+
],
|
|
60
|
+
'prettier/prettier': [
|
|
61
|
+
'error',
|
|
62
|
+
{
|
|
63
|
+
semi: true,
|
|
64
|
+
singleQuote: true,
|
|
65
|
+
bracketSpacing: true,
|
|
66
|
+
arrowParens: 'avoid',
|
|
67
|
+
printWidth: 100,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
79
70
|
},
|
|
80
|
-
},
|
|
81
71
|
},
|
|
82
72
|
];
|