使用cz-conventional-changelog
安装:yarn add cz-conventional-changelog -D
在package.json
配置
{
"scripts": {
"cz": "git add . && npx git-cz"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
使用 @commitlint/cli
和 @commitlint/config-conventional
- @commitlint/cli: 强制执行常规提交
- @commitlint/config-conventional: 作为校验的配置
npx husky add .husky/pre-commit 'yarn lint'
前提是要配置好
lint
的脚本
使用 husky
yarn add husky -D
设置 husky(适合版本大于 5.0.0)
- 执行
npx husky install
安装git
钩子 - 执行
npx husky add .husky/commit-msg 'npx commitlint --edit $1'
启用适配commitlint
的commit-msg hook
安装 yarn add eslint -D
在 package.josn 中添加启动脚本
{
"script": {
"lint": "eslint src --fix --ext .ts,.js,.vue"
}
}
命令:--fix:修复 src:指定哪些文件 --ext:指定哪些文件类型