chore(hooks): 优化 lint-staged 和 git hooks 配置
- lint-staged: 本地开发仅自动修复不阻塞,CI 环境严格检查 - pre-commit: 后台运行 tsc 类型检查,前台运行 lint-staged - pre-push: 新增严格检查闸门(tsc + eslint --max-warnings=0)
This commit is contained in:
+5
-1
@@ -1 +1,5 @@
|
|||||||
npx lint-staged
|
# 后台运行类型检查,结果输出到 stderr 但不阻塞提交
|
||||||
|
npx tsc --noEmit &
|
||||||
|
|
||||||
|
# 前台运行 lint-staged(自动修复 + 格式化)
|
||||||
|
npx lint-staged
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# pre-push: 严格检查,阻塞有问题的代码推送到远程
|
||||||
|
# 类型检查
|
||||||
|
npx tsc --noEmit
|
||||||
|
|
||||||
|
# ESLint 严格检查(不允许 warning)
|
||||||
|
npx eslint . --max-warnings=0
|
||||||
@@ -1,4 +1,12 @@
|
|||||||
|
/* global process */
|
||||||
|
|
||||||
|
const isCI = process.env.CI === 'true';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
'*.{ts,tsx,js,jsx,mjs}': ['eslint --fix --max-warnings=0 --no-warn-ignored', 'prettier --write'],
|
'*.{ts,tsx,js,jsx,mjs}': [
|
||||||
|
'eslint --fix --no-warn-ignored',
|
||||||
|
...(isCI ? ['eslint --max-warnings=0'] : []),
|
||||||
|
'prettier --write',
|
||||||
|
],
|
||||||
'*.{json,css,scss,md}': ['prettier --write'],
|
'*.{json,css,scss,md}': ['prettier --write'],
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user