You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

@commitlint/prompt-cli配置异常:无法显示提交类型选择列表

解决@commitlint/prompt-cli自定义提交类型不生效的问题

你的配置结构有误,@commitlint/prompt-cli不识别prompt.questions.type.enum配置项,需要调整配置结构来指定自定义提交类型,以下是两种可行方案:

方案一:在prompt.questions.type中配置choices数组

修改commitlint.config.js为如下内容:

module.exports = {
  extends: ['@commitlint/config-conventional'],
  prompt: {
    questions: {
      type: {
        description: "请选择提交类型:",
        choices: [
          {
            value: 'feat',
            name: 'feat:     新功能',
            description: '添加新的功能'
          },
          {
            value: 'fix',
            name: 'fix:      修复Bug',
            description: '修复代码中的Bug'
          }
        ]
      }
    }
  }
};

方案二:使用prompt.types定义提交类型(官方推荐)

这种方式会自动生成类型选择列表,配置更简洁:

module.exports = {
  extends: ['@commitlint/config-conventional'],
  prompt: {
    types: [
      {
        value: 'feat',
        name: 'feat:     新功能',
        description: '添加新的功能'
      },
      {
        value: 'fix',
        name: 'fix:      修复Bug',
        description: '修复代码中的Bug'
      }
    ]
  }
};

额外检查

确保已正确安装依赖:

npm install --save-dev @commitlint/cli @commitlint/config-conventional @commitlint/prompt-cli

并在package.json中配置提交脚本:

{
  "scripts": {
    "commit": "commit"
  }
}

之后执行npm run commit即可看到自定义的中文提交类型选择列表。

内容的提问来源于stack exchange,提问作者Diego Garcia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 19:20:57