安装commitlint时候遇到的问题

git地址:
https://github.com/conventional-changelog/commitlint#getting-started


项目是一个新项目,vue3 + vite + ts, 配置了ESlint。
但是按照文档安装完commitlint之后,遇到以下问题:

  1. “⚠ Some of your tasks use git add command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.”

⚠ 一些任务使用了 git add 命令。请从配置中移除它,因为所有由任务进行的修改都会自动添加到 Git 提交索引中。

这个问题是因为配置ESlint的时候,在 package.json 文件里面的 lint-staged 中配置了 'git add ', 和新安装的 commitlint 插件冲突了,这俩都会自动添加到 Git 提交索引中。所以,删掉 lint-staged的这个配置就可以了。
在这里插入图片描述
2. 第二个问题是提示
D:\study\shop-admin-with-vue3-vite-ts\node_modules\ts-node\dist\index.js:851
return old(m, filename);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module D:\study\shop-admin-with-vue3-vite-ts\commitlint.config.js from D:\study\shop-admin-with-vue3-vite-ts\node_modules\cosmiconfig\dist\loaders.js not supported.
commitlint.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains “type”: “module” which declares all .js files in that package scope as ES modules.

这个问题是因为,我在 package.json 指定了type是module, 使用的ES 模块的规范,提交commit的时候,校验报错了。
在这里插入图片描述
原因在于配置commitlint.config.js文件的时候,使用的是 CommonJS 模块规范。
在这里插入图片描述
解决:改成ES规范即可。
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值