Problems encountered when installing commitlint

Git address:
https://github.com/conventional-changelog/commitlint#getting-started


The project is a new project, vue3 + vite + ts, configured with ESlint.
However, after installing commitlint according to the documentation, I encountered the following problems:

  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.”

⚠ Some tasks use the git add command. Please remove it from the configuration as all modifications made by the task are automatically added to the Git commit index.

This problem is because when configuring ESlint, 'git add' is configured in lint-staged in the package.json file, which conflicts with the newly installed commitlint plug-in. Both of them will be automatically added to the Git commit index. Therefore, just delete the lint-staged configuration.
Insert image description here
2. The second problem is the prompt
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.

This problem is because I specified the type as module in package.json and used the specification of the ES module. When submitting the commit, the verification error was reported.
Insert image description here
The reason is that when configuring the commitlint.config.js file, the CommonJS module specification is used.
Insert image description here
Solution: Just change it to ES specification.
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_40887836/article/details/132071532