fd423770d8
修复 Agent 失败展示变更中的 import 排序错误 统一 CI 与 master pre-push 的 Repository checks 入口 让 staged JS 和 TS 自动执行 ESLint 修复与 Prettier 补充部分暂存、忽略文件和待推 SHA 回归测试 同步分支保护与本地门禁流程文档
35 lines
800 B
JavaScript
Executable File
35 lines
800 B
JavaScript
Executable File
import process from 'node:process';
|
|
|
|
import { ESLint } from 'eslint';
|
|
|
|
const eslint = new ESLint({ fix: true });
|
|
const candidates = [];
|
|
|
|
for (const filePath of process.argv.slice(2)) {
|
|
if (!(await eslint.isPathIgnored(filePath))) {
|
|
candidates.push(filePath);
|
|
}
|
|
}
|
|
|
|
if (candidates.length === 0) {
|
|
process.exit(0);
|
|
}
|
|
|
|
const results = await eslint.lintFiles(candidates);
|
|
await ESLint.outputFixes(results);
|
|
|
|
const formatter = await eslint.loadFormatter('stylish');
|
|
const output = formatter.format(results);
|
|
if (output) {
|
|
process.stderr.write(output);
|
|
}
|
|
|
|
const errorCount = results.reduce((sum, result) => sum + result.errorCount, 0);
|
|
const warningCount = results.reduce(
|
|
(sum, result) => sum + result.warningCount,
|
|
0,
|
|
);
|
|
if (errorCount > 0 || warningCount > 0) {
|
|
process.exitCode = 1;
|
|
}
|