- husky: Git hooks made easy
- lint-staged: Run linters on git staged files
- 用 husky 和 lint-staged 构建超溜的代码检查工作流
- 用 husky 和 prettier 保证团队代码格式一致性
- commitlint: Lint commit messages
yarn add husky lint-staged --dev
在package.json
中
{
...
...
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": ["eslint --fix", "git add"]
}
}