r-util-js/commitlint.config.cjs

182 lines
5.6 KiB
JavaScript
Raw Normal View History

/**
* feat新增功能
* fixbug 修复
* docs文档更新
* style不影响程序逻辑的代码修改(修改空白字符格式缩进补全缺失的分号等没有改变代码逻辑)
* refactor重构代码(既没有新增功能也没有修复 bug)
* perf性能, 体验优化
* test新增测试用例或是更新现有测试
* build主要目的是修改项目构建系统(例如 glupwebpackrollup 的配置等)的提交
* ci主要目的是修改项目继续集成流程(例如 TravisJenkinsGitLab CICircle等)的提交
* chore不属于以上类型的其他类型比如构建流程, 依赖管理
* revert回滚某个更早之前的提交
*/
module.exports = {
extends: ["@commitlint/config-conventional"],
2026-03-17 17:36:55 +08:00
rules: {
// 限制提交类型
"type-enum": [
2,
"always",
[
"feat",
"fix",
"docs",
"style",
"refactor",
"perf",
"test",
"build",
"ci",
"chore",
"revert",
],
],
// scope 可选,但如果提供必须是以下之一
"scope-enum": [
2,
"always",
["common", "vue3", "vue2", "uni-app", "deps", "release"],
],
// subject 不能为空
"subject-empty": [2, "never"],
// subject 不能以句号结尾
"subject-full-stop": [2, "never", "."],
// subject 不限制大小写
"subject-case": [0],
// type 必须小写
"type-case": [2, "always", "lower-case"],
// scope 必须小写
"scope-case": [2, "always", "lower-case"],
// subject 最小长度
"subject-min-length": [2, "always", 4],
// subject 最大长度
"subject-max-length": [2, "always", 100],
// header 最大长度(type + scope + subject)
"header-max-length": [2, "always", 120],
// body 每行最大长度
"body-max-line-length": [2, "always", 200],
// footer 每行最大长度
"footer-max-line-length": [2, "always", 200],
},
prompt: {
2026-03-17 17:36:55 +08:00
useEmoji: true,
emojiAlign: "center",
allowCustomIssuePrefix: false,
allowEmptyIssuePrefix: false,
// 定义 scope 选项
scopes: [
{ value: "common", name: "common: @r-utils/common 包" },
{ value: "vue3", name: "vue3: @r-utils/vue3 包" },
{ value: "vue2", name: "vue2: @r-utils/vue2 包" },
{ value: "uni-app", name: "uni-app: @r-utils/uni-app 包" },
{ value: "deps", name: "deps: 依赖更新" },
{ value: "release", name: "release: 版本发布" },
],
allowCustomScopes: false,
allowEmptyScopes: true,
messages: {
skip: "跳过",
max: "最多 %d 个字符",
min: "最少 %d 个字符",
emptyWarning: "不能为空",
upperLimitWarning: "超出字数限制",
lowerLimitWarning: "低于字数限制",
},
questions: {
type: {
description: "选择提交类型",
enum: {
feat: {
description: "一个新特性",
title: "新特性",
emoji: "✨",
},
fix: {
description: "一个漏洞修复",
title: "漏洞修复",
emoji: "🐛",
},
docs: {
description: "仅更改文档",
title: "文档",
emoji: "📚",
},
style: {
description: "不影响代码含义的更改(空白符、格式化、缺少分号等)",
title: "样式",
emoji: "💎",
},
refactor: {
description: "既不修复错误也不添加功能的代码更改",
title: "重构",
emoji: "📦",
},
perf: {
description: "提高性能的代码更改",
title: "性能提升",
emoji: "🚀",
},
test: {
description: "添加缺失的测试或纠正现有的测试",
title: "测试",
emoji: "🚨",
},
build: {
description:
"影响构建系统或外部依赖项的更改例如gulp、broccoli、npm",
title: "构建",
emoji: "🛠",
},
ci: {
description:
"更改我们的集成配置文件和脚本例如Travis、Circle、BrowserStack、SauceLabs",
title: "集成",
emoji: "⚙️",
},
chore: {
description: "不修改源码或测试文件的其他更改",
title: "杂项",
emoji: "♻️",
},
revert: {
description: "恢复之前的提交",
title: "还原",
emoji: "🗑",
},
},
},
scope: {
2026-03-17 17:36:55 +08:00
description: "更改的范围scopecommon、vue3、uni-app",
},
subject: {
description: "主题subject",
},
body: {
description: "主体body",
},
isBreaking: {
description: "是否有破坏性更改BREAKING CHANGE",
},
breakingBody: {
description:
"破坏性更改BREAKING CHANGE需要一个主体body请输入详细描述",
},
breaking: {
description: "描述破坏性更改BREAKING CHANGE",
},
isIssueAffected: {
description: "此改变是否影响打开的问题open ssues",
},
issuesBody: {
description: "如果问题关闭则需要提交一个主体body请输入详细描述",
},
issues: {
description:
'添加问题参考issue references (例: "fix #123"、"re #123"',
},
},
},
};