Files
read_book/commitlint.config.cjs

102 lines
4.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module.exports = {
// 继承通用提交规范规则
extends: ['@commitlint/config-conventional'],
// 自定义提交校验规则
rules: {
// 强制提交类型必须是以下列表中的值
'type-enum': [
2, // 2 = 必须符合不满足则报错1 = 警告0 = 关闭规则
'always',
[
'feat', // 新增功能
'fix', // 修复缺陷
'docs', // 文档变更(如 README 修改)
'style', // 代码格式调整(不影响功能,如空格、分号)
'refactor', // 代码重构既不是新增功能也不是修复bug
'perf', // 性能优化
'test', // 新增/修改测试用例
'build', // 构建流程/外部依赖变更(如 npm 包升级、webpack 配置修改)
'ci', // CI 配置/脚本修改
'revert', // 回滚之前的提交
'chore' // 辅助工具/构建过程变更(不影响源码和测试)
]
],
'subject-case': [0], // 不校验提交描述subject的大小写
'scope-empty': [2, 'never'] // 强制必须填写模块范围scope不允许空
},
// 交互式提交配置(配合 cz-git 使用,优化提交体验)
prompt: {
messages: {
type: '选择你要提交的类型 :',
scope: '选择一个提交范围(模块):',
customScope: '请输入自定义的模块名称 :',
subject: '填写简短精炼的变更描述 :\n',
body: '填写更加详细的变更描述(可选)。使用 "|" 换行 :\n',
breaking: '列举非兼容性重大的变更(可选)。使用 "|" 换行 :\n',
footerPrefixesSelect: '选择关联issue前缀可选:',
customFooterPrefix: '输入自定义issue前缀 :',
footer: '列举关联issue (可选) 例如: #31, #I3244 :\n',
generatingByAI: '正在通过 AI 生成你的提交简短描述...',
generatedSelectByAI: '选择一个 AI 生成的简短描述:',
confirmCommit: '是否提交或修改commit ?'
},
// 提交类型选项(用直观的 Emoji 字符,避免 Windows 解析失败)
types: [
{ value: 'feat', name: '特性: ✨ 新增功能', emoji: '✨' },
{ value: 'fix', name: '修复: 🐛 修复缺陷', emoji: '🐛' },
{ value: 'docs', name: '文档: 📝 文档变更', emoji: '📝' },
{ value: 'style', name: '格式: 🌈 代码格式调整', emoji: '🌈' },
{ value: 'refactor', name: '重构: 🔄 代码重构', emoji: '🔄' },
{ value: 'perf', name: '性能: 🚀 性能优化', emoji: '🚀' },
{ value: 'test', name: '测试: 🧪 测试相关修改', emoji: '🧪' },
{ value: 'build', name: '构建: 📦️ 构建流程变更', emoji: '📦️' },
{ value: 'ci', name: '集成: ⚙️ CI配置修改', emoji: '⚙️' },
{ value: 'revert', name: '回退: ↩️ 回滚提交', emoji: '↩️' },
{ value: 'chore', name: '其他: 🛠️ 辅助工具变更', emoji: '🛠️' }
],
useEmoji: true, // 启用 Emoji 显示
emojiAlign: 'center', // Emoji 居中对齐
useAI: false, // 关闭 AI 生成提交描述功能
aiNumber: 1,
themeColorCode: '',
// 项目模块范围(适配你的 pnpm workspace 结构)
scopes: [{ value: 'desktop', name: 'desktop: 桌面应用' }],
allowCustomScopes: true, // 允许手动输入自定义模块名称
allowEmptyScopes: false, // 不允许空模块(与 rules 中的 scope-empty 规则对应)
customScopesAlign: 'bottom',
customScopesAlias: 'custom',
emptyScopesAlias: 'empty',
upperCaseSubject: false, // 不强制提交描述首字母大写
markBreakingChangeMode: false, // 不启用「重大变更」标记模式
allowBreakingChanges: ['feat', 'fix'], // 仅 feat/fix 类型可标注重大变更
breaklineNumber: 100, // 提交描述超过 100 字符自动换行
breaklineChar: '|', // 手动换行的分隔符
skipQuestions: [], // 不跳过任何交互式问题
// Issue 关联配置
issuePrefixes: [{ value: 'closed', name: 'closed: ISSUES has been processed' }],
customIssuePrefixAlign: 'top',
emptyIssuePrefixAlias: 'skip',
customIssuePrefixAlias: 'custom',
allowCustomIssuePrefix: true,
allowEmptyIssuePrefix: true,
confirmColorize: true, // 提交确认时高亮显示文本
maxHeaderLength: Infinity, // 不限制提交标题长度
maxSubjectLength: Infinity, // 不限制提交描述长度
minSubjectLength: 0, // 不限制提交描述最小长度
scopeOverrides: undefined,
defaultBody: '', // 默认提交详情为空
defaultIssues: '', // 默认不关联任何 Issue
defaultScope: '', // 默认不指定模块
defaultSubject: '' // 默认不填写提交描述
}
}