commitlint 提交信息的格式化
安装
pnpm add @commitlint/config-conventional @commitlint/cli -D
创建配置文件
commitlint.config.cjs
module.exports = {
ignores: [(commit) => commit.includes('init')],
extends: ['@commitlint/config-conventional'],
rules: {
'body-leading-blank': [2, 'always'],
'footer-leading-blank': [1, 'always'],
'header-max-length': [2, 'always', 108],
'subject-empty': [2, 'never'],
'type-empty': [2, 'never'],
'subject-case': [0],
},
};
package.json中添加脚本
"commitlint": "commitlint --config commitlint.config.cjs -e -V",
配置husky
npx husky add .husky/commit-msg
修改生成文件内容
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
pnpm commitlint
网友评论