Use npmnpm i -D husky @commitlint/config-conventional @commitlint/cliUse yarnyarn add husky @commitlint/config-conventional @commitlint/cli -D
commitlint只能做格式规范,无法触及内容。对于内容质量的把控只能靠我们自己。
3. 添加相应配置
创建commitlint.config.js
# In the same path as package.jsonecho 'module.exports = {extends: ["@commitlint/config-conventional"]};' > ./commitlint.config.js引入husky# package.json...,"husky": { "hooks": { "commit-msg": "commitlint -e $GIT_PARAMS" }}
4. 使用
执行git cz进入interactive模式,根据提示依次填写
1.Select the type of change that you're committing 选择改动类型 ( )2.What is the scope of this change (e.g. component or file name)? 填写改动范围 ( )3.Write a short, imperative tense description of the change: 写一个精简的描述 ( )4.Provide a longer description of the change: (press enter to skip) 对于改动写一段长描述 ()5.Are there any breaking changes? (y/n) 是破坏性修改吗?默认n (