feat: 添加 pre-commit hooks 配置

- 安装 husky 和 lint-staged 用于 Git hooks 管理
- 配置 pre-commit 检查:ESLint、TypeScript、Prettier
- 添加 Prettier 代码格式化配置和插件
- 更新项目文档说明 pre-commit 工作流程
- 配置文件包括:
  - .husky/pre-commit: Git pre-commit hook 脚本
  - lint-staged.config.js: lint-staged 配置
  - frontend/.prettierrc: Prettier 配置
  - frontend/.prettierignore: Prettier 忽略文件

现在每次提交前会自动运行代码检查和格式化
This commit is contained in:
xujiang
2025-07-09 09:29:33 +08:00
parent fc90eb3fa9
commit fe59c8b499
10 changed files with 166 additions and 6 deletions

View File

@ -7,7 +7,10 @@
"dev": "next dev",
"lint": "next lint",
"start": "next start",
"type-check": "tsc --noEmit"
"type-check": "tsc --noEmit",
"format": "prettier --write .",
"format:check": "prettier --check .",
"prepare": "husky"
},
"dependencies": {
"@hookform/resolvers": "^3.9.1",
@ -71,8 +74,10 @@
"@types/react-dom": "^19",
"eslint": "^9.30.1",
"eslint-config-next": "^15.3.5",
"husky": "^9.1.7",
"lint-staged": "^16.1.2",
"postcss": "^8.5",
"tailwindcss": "^3.4.17",
"typescript": "^5"
}
}
}