使用commitlint规范git提交
在我们开始一个项目的时候通常会用eslint去规范js代码。我们还可以用一些命令行工具去规范我们的git提交信息以及在每次git操作过程中执行一些测试,最快可以依据git提交信息生成CHANGELOG文件
commitlint: git 提交信息规范与验证
husky: 使ghook更容易
standard-version: 自动生成CHANGELOG 并发布版本
安装
npm install --save-dev @commitlint/{config-conventional,cli} npm i --save-dev standard-version npm install husky --save-dev
配置
commitlint echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js // commitlint.config.js module.exports = { extends: ['@commitlint/config-conventional'], rules: { 'type-enum': [2, 'always', [ "feat", "fix", "docs", "style", "refactor", "perf", "test", "build", "ci", "chore", "revert" ]], 'scope-empty': [2, 'never'], 'subject-full-stop': [0, 'never'], 'subject-case': [0, 'never'] }};
Standard-version 和 husky
// package.json "scripts": { "lint": "eslint .", "commitmsg": "commitlint -e $GIT_PARAMS", "release": "standard-version", "validate": "npm prune", "pre-commit": "npm run lint", "pre-push": "npm run validate", "npmi": "npm i", "post-merge": "npm run npmi", "post-rewrite": "npm run npmi" }
使用
具体参考相应官网
相关推荐
formula 2020-11-12
huhongfei 2020-11-05
乾坤一碼農 2020-10-27
liumengyanysu 2020-10-22
E哥的aws认证攻略 2020-10-15
tianyafengxin 2020-10-08
guying 2020-10-05
好脑筋不如烂笔头 2020-09-17
nebulali 2020-09-11
佛系程序员J 2020-09-15
fenggit 2020-09-15
JustHaveTry 2020-09-11
兄dei努力赚钱吧 2020-09-06
IngeniousIT 2020-08-25
liumengyanysu 2020-08-17
guying 2020-08-16