commitizen / cz-cli

The commitizen command line utility. #BlackLivesMatter
http://commitizen.github.io/cz-cli/
MIT License
16.57k stars 552 forks source link

[Config loader] check if config key is in package.json before accepting it as a config file #975

Open simrobin opened 1 year ago

simrobin commented 1 year ago

Hello,

I'm working on a monorepo with backend and frontend and a .czrc at the directory's root to enforce commit rules with commitizen.

All frontend-related files are in a subdirectory, including the package.json file at different filesystem levels.

My issue: In a subdirectory with a package.json between pwd and git repository root, commitizen seems to acknowledge this file as a configuration file despite the lack of config.commitizen key.

Fix proposal: There seems to be a mechanism to check the package.json has a commitizen configuration, but it is commented: https://github.com/commitizen/cz-cli/blob/2e57fd02a5fd2b2dcf89d3235a6956edaeaf672c/src/configLoader/loader.js#L30-L36

I tried to uncomment it in a local version of commitizen, and it works as expected. Would it be possible to uncomment it or does it have unwanted side effects?

simrobin commented 1 year ago

For now, I'm bypassing this problem with a symlink of .czrc in my home directory, which prevails on repository config files:

ln -s /path/to/my/repository/.czrc ~/.czrc

But it's not perfect and it only works for me 🙂.