commitlint.config.cjs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // @see: https://cz-git.qbenben.com/zh/guide
  2. const fs = require('fs')
  3. const path = require('path')
  4. const scopes = fs
  5. .readdirSync(path.resolve(__dirname, 'src'), { withFileTypes: true })
  6. .filter(dirent => dirent.isDirectory())
  7. .map(dirent => dirent.name.replace(/s$/, ''))
  8. /** @type {import('cz-git').UserConfig} */
  9. module.exports = {
  10. ignores: [commit => commit.includes('init')],
  11. extends: ['@commitlint/config-conventional'],
  12. rules: {
  13. // @see: https://commitlint.js.org/#/reference-rules
  14. 'body-leading-blank': [2, 'always'],
  15. 'footer-leading-blank': [1, 'always'],
  16. 'header-max-length': [2, 'always', 108],
  17. 'subject-empty': [2, 'never'],
  18. 'type-empty': [2, 'never'],
  19. 'subject-case': [0],
  20. 'type-enum': [
  21. 2,
  22. 'always',
  23. [
  24. 'feat',
  25. 'fix',
  26. 'docs',
  27. 'style',
  28. 'refactor',
  29. 'perf',
  30. 'test',
  31. 'build',
  32. 'ci',
  33. 'chore',
  34. 'revert',
  35. 'wip',
  36. 'workflow',
  37. 'types',
  38. 'release'
  39. ]
  40. ]
  41. },
  42. prompt: {
  43. messages: {
  44. // type: "Select the type of change that you're committing:",
  45. // scope: 'Denote the SCOPE of this change (optional):',
  46. // customScope: 'Denote the SCOPE of this change:',
  47. // subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
  48. // body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
  49. // breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
  50. // footerPrefixsSelect: 'Select the ISSUES type of changeList by this change (optional):',
  51. // customFooterPrefixs: 'Input ISSUES prefix:',
  52. // footer: 'List any ISSUES by this change. E.g.: #31, #34:\n',
  53. // confirmCommit: 'Are you sure you want to proceed with the commit above?'
  54. // 中文版
  55. type: '选择你要提交的类型 :',
  56. scope: '选择一个提交范围(可选):',
  57. customScope: '请输入自定义的提交范围 :',
  58. subject: '填写简短精炼的变更描述 :\n',
  59. body: '填写更加详细的变更描述(可选)。使用 "|" 换行 :\n',
  60. breaking: '列举非兼容性重大的变更(可选)。使用 "|" 换行 :\n',
  61. footerPrefixsSelect: '选择关联issue前缀(可选):',
  62. customFooterPrefixs: '输入自定义issue前缀 :',
  63. footer: '列举关联issue (可选) 例如: #31, #I3244 :\n',
  64. confirmCommit: '是否提交或修改commit ?'
  65. },
  66. types: [
  67. // {
  68. // value: 'feat',
  69. // name: 'feat: 🚀 A new feature',
  70. // emoji: '🚀'
  71. // },
  72. // {
  73. // value: 'fix',
  74. // name: 'fix: 🧩 A bug fix',
  75. // emoji: '🧩'
  76. // },
  77. // {
  78. // value: 'docs',
  79. // name: 'docs: 📚 Documentation only changes',
  80. // emoji: '📚'
  81. // },
  82. // {
  83. // value: 'style',
  84. // name: 'style: 🎨 Changes that do not affect the meaning of the code',
  85. // emoji: '🎨'
  86. // },
  87. // {
  88. // value: 'refactor',
  89. // name: 'refactor: ♻️ A code change that neither fixes a bug nor adds a feature',
  90. // emoji: '♻️'
  91. // },
  92. // {
  93. // value: 'perf',
  94. // name: 'perf: ⚡️ A code change that improves performance',
  95. // emoji: '⚡️'
  96. // },
  97. // {
  98. // value: 'test',
  99. // name: 'test: ✅ Adding missing tests or correcting existing tests',
  100. // emoji: '✅'
  101. // },
  102. // {
  103. // value: 'build',
  104. // name: 'build: 📦️ Changes that affect the build system or external dependencies',
  105. // emoji: '📦️'
  106. // },
  107. // {
  108. // value: 'ci',
  109. // name: 'ci: 🎡 Changes to our CI configuration files and scripts',
  110. // emoji: '🎡'
  111. // },
  112. // {
  113. // value: 'chore',
  114. // name: "chore: 🔨 Other changes that don't modify src or test files",
  115. // emoji: '🔨'
  116. // },
  117. // {
  118. // value: 'revert',
  119. // name: 'revert: ⏪️ Reverts a previous commit',
  120. // emoji: '⏪️'
  121. // },
  122. // {
  123. // value: 'wip',
  124. // name: 'wip: 🕔 work in process',
  125. // emoji: '🕔'
  126. // },
  127. // {
  128. // value: 'workflow',
  129. // name: 'workflow: 📋 workflow improvements',
  130. // emoji: '📋'
  131. // },
  132. // {
  133. // value: 'type',
  134. // name: 'type: 🔰 type definition file changes',
  135. // emoji: '🔰'
  136. // }
  137. // 中文版
  138. { value: 'feat', name: '特性: 🚀 新增功能', emoji: '🚀' },
  139. { value: 'fix', name: '修复: 🧩 修复缺陷', emoji: '🧩' },
  140. { value: 'docs', name: '文档: 📚 文档变更', emoji: '📚' },
  141. { value: 'style', name: '格式: 🎨 代码格式(不影响功能,例如空格、分号等格式修正)', emoji: '🎨' },
  142. { value: 'refactor', name: '重构: ♻️ 代码重构(不包括 bug 修复、功能新增)', emoji: '♻️' },
  143. { value: 'perf', name: '性能: ⚡️ 性能优化', emoji: '⚡️' },
  144. { value: 'test', name: '测试: ✅ 添加疏漏测试或已有测试改动', emoji: '✅' },
  145. { value: 'build', name: '构建: 📦️ 构建流程、外部依赖变更(如升级 npm 包、修改 webpack 配置等)', emoji: '📦️' },
  146. { value: 'ci', name: '集成: 🎡 修改 CI 配置、脚本', emoji: '🎡' },
  147. { value: 'revert', name: '回退: ⏪️ 回滚 commit', emoji: '⏪️' },
  148. { value: 'chore', name: '其他: 🔨 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)', emoji: '🔨' },
  149. { value: 'wip', name: '开发: 🕔 正在开发中', emoji: '🕔' },
  150. { value: 'workflow', name: '工作流: 📋 工作流程改进', emoji: '📋' },
  151. { value: 'types', name: '类型: 🔰 类型定义文件修改', emoji: '🔰' }
  152. ],
  153. useEmoji: true,
  154. scopes: [...scopes],
  155. customScopesAlign: 'bottom',
  156. emptyScopesAlias: 'empty',
  157. customScopesAlias: 'custom',
  158. allowBreakingChanges: ['feat', 'fix']
  159. }
  160. }