Commitlint: Error when used with Husky: "Please add rules to your commitlint.config.js"

Created on 15 Feb 2019  路  5Comments  路  Source: conventional-changelog/commitlint

Expected Behavior

The following Husky hook used to work perfectly with "@commitlint/cli": "^7.2.1" and "husky": "^1.2.1"

  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  },

Current Behavior

Today I started getting the following error:

Please add rules to your commitlint.config.js

I have never needed this file before!

image

Affected packages

  • [x] cli
  • [ ] core
  • [ ] prompt
  • [ ] config-angular

Possible Solution

I added the commitlint.config.js file to fix the problem, but it seems mysterious how this started appearing suddenly.

Note: I do not understand how HUSKY_GIT_PARAMS works. The husky documents do not quite explain it.

Steps to Reproduce (for bugs)

You can see my fixed project here: https://github.com/archfirst/joinjs. The previous commit did not work.

question triage

All 5 comments

Looks like this change in behavior has been introduced after version 7.2.1. When I use version 7.5.2, I start getting the error message mentioned earlier: "Please add rules to your commitlint.config.js".

I looked through the change log, but there is no mention of it,

The warning about a missing commitlint.config.js was introduced exactly for this kind of scenario.

commitlint versions 7.2.1 and older essentially allowed any commit message to go through when no config was provided.

To avoid the confusion around this and make sure users actually get what they want from commitlint we introduced the warning.

Feel free to reopen if you think there is a problem not covered by my explanation.

Thanks for clarifying @marionebl. It makes total sense 馃憤

Not to re-open this issue, but I'm receiving the same error, but I actually use a global commitlint file located at ~/commitlint.config.js. This issue added support for a global configuration:

https://github.com/conventional-changelog/commitlint/pull/127

For some reason though, the interaction between Husky and Commitlint fails to read this global file.

In my case, I was following guidelines from https://commitlint.js.org/#/
There is a step asking as: _echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js_
This step is indeed creating this required file names as commitline.config.js. but the contents of this file are getting wrapped in double quotes.

So, fix for me was to remove these not needed double quotes and make the file contents syntactically correct as per JavaScript.
Hope this helps, Thanks...

Was this page helpful?
0 / 5 - 0 ratings