当前位置: 首页 > 后端技术 > Node.js

使用commitlint标准化git提交

时间:2023-04-03 22:35:44 Node.js

我们在开始一个项目的时候,通常会使用eslint来规范js代码。我们也可以使用一些命令行工具来规范我们的git提交信息,在每次git操作的时候进行一些测试。最快commitlint可以根据git提交信息生成CHANGELOG文件:git提交信息规范和验证husky:makeghookmoreEasystandard-version:自动生成CHANGELOG和releaseversioninstallnpminstall--save-dev@commitlint/{config-conventional,cli}npmi--save-devstandard-versionnpminstallhusky--save-dev配置commitlintech"module.exports={extends:['@commitlint/config-conventional']}">commitlint.config.js//commitlint.config.jsmodule.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']}};标准版和husky//package.json"scripts":{"lint":"eslint.","commitmsg":"commitlint-e$GIT_PARAMS","release":"standard-version","validate":"npmprune","pre-commit":"npmrunlint","pre-push":"npmrunvalidate","npmi":"npmi","post-merge":"npmrunnpmi","post-rewrite":"npmrunnpmi"}参考对应官网