cz-cli icon indicating copy to clipboard operation
cz-cli copied to clipboard

Understanding: usage with commitlint

Open gaurav5430 opened this issue 5 years ago • 9 comments

I am already using commitlint with conventional commits in my project to lint my commit messages as part of husky commit-msg githook.

I also want to have the ability to prompt users for correctly format messages while they are committing instead of checking before the actual commit, which commitlint enables with commitlint prompt Ofcourse, commitizen enables this as well with

"config": {
    "commitizen": {
      "path": "path/to/adapter"
    }
  },

Is there any benefit of using commitizen if I am using commitlint already?

Or, would it make sense to only use commitizen?

Does commitizen provide a commit-msg hook? as i would like to still lint my git commit messages if a user does not follow the prompt that commitizen provides for commit.

Assuming I do get some benefits by using both commitizen and commitlint, would it be better for me to use the commitlint adapter with config-conventional or cz-conventional-changelog?

gaurav5430 avatar May 23 '20 18:05 gaurav5430

Hi @gaurav5430 , in the issue #742 you can see how I configured commitizen + commitlint + husky. It works quite well.

castarco avatar May 24 '20 12:05 castarco

@castarco I don't have any issues with making the setup work with cz-conventional-changelog and commitlint with husky, my question is more to understand whether I should be using cz-conventional-changelog at all if I am already using commitlint, should I just use the commitlint adapter instead of cz-conventional-changelog? And further, should I even use commitizen at all if I am already using commitlint? Can I not just use the commitlint prompt to setup a commit script same as git-cz, is there a benefit one approach provides over the other?

gaurav5430 avatar May 24 '20 12:05 gaurav5430

Oh, sorry. I will speak for my specific case.

I'm using commitizen as a wizard helper, while I still rely on commitlint to ensure that no one breaks the rules (I also execute commitlint in the CI pipeline to reject branches where the rules were not followed).

As far as I know, commitlint does not provide the kind of nice wizard that commitizen offers.

Also, I don't use the commitlint adapter, it was easier for me to keep both tools without integrating them too tightly.

castarco avatar May 24 '20 12:05 castarco

commitlint does have a wizard: https://www.github.com/conventional-changelog/commitlint/tree/master/docs%2Fguides-use-prompt.md

Also, if you use commitlint as well as cz-conventional-changelog then you might be (assuming this because both of these repos are maintained separately) sourcing your conventional commits/rules from 2 different sources as commitlint has its own separate conventional commit config and cz-conventional-changelog has its own, Although it is highly unlikely that there are any discrepancies between these two but they are indeed separate sources to do the same checks.

To me it would make more sense to use the same tool/config for creating the commit as well as linting it. This can be achieved by using commitlint adapter with commitizen when creating the commit, which uses the same config as commitlint uses when linting the commit.

gaurav5430 avatar May 24 '20 12:05 gaurav5430

commitizen & cz-conventional-changelog are able to read and use the commitlint configuration (I checked it).

castarco avatar May 24 '20 12:05 castarco

Oh Ok, so are you suggesting that when I use cz-conventional-changelog as well as commitlint, cz-conventional-changelog would use the commilint configuration by default?

gaurav5430 avatar May 24 '20 12:05 gaurav5430

commitizen & cz-conventional-changelog are able to read and use the commitlint configuration (I checked it).

As per my current understanding, commitizen would use the commitlint config if I use the commitlint adapter How does cz-conventional-changelog use the commitlint config?

gaurav5430 avatar May 24 '20 14:05 gaurav5430

How does cz-conventional-changelog use the commitlint config?

I would like to know that too

Axedyson avatar Aug 24 '21 08:08 Axedyson

Seems there is no dependency between commitlint/husky and Commitizen. Both are separate solutions for tackling conventional commits and adhering to that.

siddharth3586 avatar May 16 '23 03:05 siddharth3586