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"
}
複製代碼