commit-lint
校验 commit 信息。
规则
commit 信息需要遵循 Conventional Commits 规范,格式为 type(scope?): message:
feat: 添加新功能
feat(ui/button): 在 ui/button 范围内添加新功能
fix: 修复一个 bug
fix(ui/button): 修复 ui/button 范围内的一个 bug支持的 type:
fix feat docs perf test types style build chore release refactor revert merge wip
使用
shell
rt commit-lint $1配置
ts
import { defineConfig } from 'rattail/vite-plus'
export default defineConfig({
rattail: {
hook: {
'commit-msg': ['rt commit-lint $1'],
},
},
})编程式使用
ts
import { commitLint } from 'rattail/cli'
commitLint({ commitMessagePath: '.git/COMMIT_EDITMSG' })选项
| 选项 | 类型 | 默认值 | 描述 |
|---|---|---|---|
commitMessagePath | string | - | Git commit 信息文件路径 |
commitMessageRe | string | RegExp | - | 自定义 commit 信息正则表达式 |
errorMessage | string | - | 自定义错误信息 |
warningMessage | string | - | 自定义警告信息 |