Files
Genarrative/scripts/lint-staged-eslint.mjs
T
kdletters fd423770d8
Project CI / Repository checks (push) Successful in 1m18s
Project CI / Frontend tests (push) Successful in 3m1s
Project CI / Backend tests (push) Successful in 4m17s
Project CI / Native shell tests (push) Failing after 12m32s
根治Repository checks本地漏检
修复 Agent 失败展示变更中的 import 排序错误
统一 CI 与 master pre-push 的 Repository checks 入口
让 staged JS 和 TS 自动执行 ESLint 修复与 Prettier
补充部分暂存、忽略文件和待推 SHA 回归测试
同步分支保护与本地门禁流程文档
2026-08-12 22:06:35 +08:00

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;
}