最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Issue with CommitLint: "Please add rules to your `commitlint.config.js`" error despite having rul

programmeradmin2浏览0评论

I am implementing a mit linting hook for a team project. I successfully installed Husky and moved on to configuring my CommitLint. Wanting to use the basic conventional mits convention, I installed the following packages. Here is my package.json:

devDependencies": {
    "@mitlint/cli": "^17.6.1",
    "@mitlint/config-conventional": "^17.6.1",
    "@types/lodash": "^4.14.192",
    "@typescript-eslint/eslint-plugin": "^5.53.0",
    "@typescript-eslint/parser": "^5.53.0",
    "eslint": "^8.35.0",
    "eslint-config-prettier": "^8.6.0",
    "eslint-plugin-prettier": "^4.2.1",
    "husky": "^8.0.0",
    "prettier": "^2.8.4"
  }

And these are the contents of my mitlint.config.js:

const Configuration = {
  /*
   * Resolve and load @mitlint/config-conventional from node_modules.
   * Referenced packages must be installed
   */
  extends: ["@mitlint/config-conventional"],
};

export default Configuration;

I've also tried using the following mand from the docs for initializing the config file, but to no avail. echo "module.exports = {extends: ['@mitlint/config-conventional']}" > mitlint.config.js

My mitlint hook looks like this:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx mitlint --edit $1

I am at my wits' end. The config file is clearly exporting something in both cases, but I am still getting the error to add rules. The husky folder is in a subdirectory of the git repo, if that could cause issues.

Besides using the echo mand to create a config file, I also tried to use both the typescript and the javascript full configurations, presented in the mitlint docs. I've also tried pasting the full configuration from here /@mitlint/config-conventional/index.js

Nothing works so far.

I am implementing a mit linting hook for a team project. I successfully installed Husky and moved on to configuring my CommitLint. Wanting to use the basic conventional mits convention, I installed the following packages. Here is my package.json:

devDependencies": {
    "@mitlint/cli": "^17.6.1",
    "@mitlint/config-conventional": "^17.6.1",
    "@types/lodash": "^4.14.192",
    "@typescript-eslint/eslint-plugin": "^5.53.0",
    "@typescript-eslint/parser": "^5.53.0",
    "eslint": "^8.35.0",
    "eslint-config-prettier": "^8.6.0",
    "eslint-plugin-prettier": "^4.2.1",
    "husky": "^8.0.0",
    "prettier": "^2.8.4"
  }

And these are the contents of my mitlint.config.js:

const Configuration = {
  /*
   * Resolve and load @mitlint/config-conventional from node_modules.
   * Referenced packages must be installed
   */
  extends: ["@mitlint/config-conventional"],
};

export default Configuration;

I've also tried using the following mand from the docs for initializing the config file, but to no avail. echo "module.exports = {extends: ['@mitlint/config-conventional']}" > mitlint.config.js

My mitlint hook looks like this:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx mitlint --edit $1

I am at my wits' end. The config file is clearly exporting something in both cases, but I am still getting the error to add rules. The husky folder is in a subdirectory of the git repo, if that could cause issues.

Besides using the echo mand to create a config file, I also tried to use both the typescript and the javascript full configurations, presented in the mitlint docs. I've also tried pasting the full configuration from here https://github./conventional-changelog/mitlint/blob/master/@mitlint/config-conventional/index.js

Nothing works so far.

Share Improve this question asked Apr 24, 2023 at 16:47 len4o17len4o17 631 silver badge3 bronze badges 1
  • try with npx --no -- mitlint --edit $1 in husky's hook – Jimish Gamit Commented Aug 9, 2023 at 13:08
Add a ment  | 

2 Answers 2

Reset to default 8

I had the same issue and was able to overe it by adding this section to my package.json, which configures mitlint to use config-conventional.

"mitlint": {
  "extends": [
    "@mitlint/config-conventional"
  ]
},

Also ensure that you installed both dev dependencies.

"@mitlint/cli": "18.0.0",
"@mitlint/config-conventional": "18.0.0",

You can find this also in the mitlint projects package.json. ;- ) https://github./conventional-changelog/mitlint/blob/master/package.json

This is my dependency package

"devDependencies": {
    "@mitlint/cli": "^19.7.1",
    "@mitlint/config-conventional": "^19.7.1",
    "@types/node": "18.18.13",
    "mitizen": "^4.3.1",
    "cz-conventional-changelog": "^3.3.0",
    "husky": "^9.1.7"
  }

You can try changing the file name of mitilint.config. js to mitilint.config. cjs

// mitlint.config.cjs

module.exports = {
    extends: ['@mitlint/config-conventional']
}

Please also note that the file encoding is utf-8

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论