commit messge
规范十分有助于项目管理,目前使用最多的是Angular团队的规范 主要规范是:css
feat(subject): title
1. change some
2. do some
复制代码
配置本身的commit规范html
npm i -D cz-customizable commitizen cz-conventional-changelog
复制代码
项目目录下.cz-config.js配置 package.jsongit
"script": {
"commit": "git-cz"
}
...
"config": {
"commitizen": {
"path": "cz-customizable"
}
}
复制代码
经过npm run commit
能够提交,可是没法对git commit
起做用,因此须要CommitLint
校验一下github
npm i -D @commitlint/config-conventional @commitlint/cli
复制代码
commitlint.config.js
配置文档npm
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', [
"feat", "fix", "docs", "style", "refactor", "test", "chore", "revert"
]],
'subject-full-stop': [0, 'never'],
'subject-case': [0, 'never']
}
};
复制代码
Husky能够生成git hook
,提交前能够进行自定义操做,咱们能够规范代码和校验提交json
npm i -D husky lint-staged prettier
复制代码
prettier是一个代码规范,配置文件.prettierrc
配置文档bash
{
"eslintIntegration": true,
"stylelintIntegration": true,
"tabWidth": 2,
"sigleQuote": true,
"semi": true,
"bracketSpacing": true
}
复制代码
package.json
添加ide
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -e $HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"src/**/*.{js,jsx}": [
"prettier --write",
"git add"
]
},
复制代码
npm i -D standard-version
复制代码
package.json 配置:测试
"scirpt": {
...,
"release": "standard-version"
}
复制代码