husky: [windows] husky is not working with commitlint
I used below commands to install husky and commitlint npm install --save-dev @commitlint/config-conventional @commitlint/cli echo “module.exports = {extends: [‘@commitlint/config-conventional’]}” > commitlint.config.js npm install husky --save-dev
Expected Behavior I shouldnt be able to commit without adding feat: chore: etc
Current Behavior I am able to commit without feat: chore: i have configured husky for commit-msg
Steps to Reproduce (for bugs) https://github.com/indraraj26/github-test
Version
"husky": "^3.0.2",
Link to commitlint opened issue : https://github.com/conventional-changelog/commitlint/issues/770
Output:
PS C:\indraraj\github-test> echo "foo" | ./node_modules/.bin/commitlint
⧗ input: foo
✖ subject may not be empty [subject-empty]
✖ type may not be empty [type-empty]
✖ found 2 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 23 (5 by maintainers)
I have the same issue. I am working with Windows 10. My node version is 12.14.1 and git version 2.25.0.windows.1
This is the output when trying to commit with git commandline
`λ git commit -m deletebutton husky > commit-msg (node v12.14.1) ⧗ input: deletebutton ✖ subject may not be empty [subject-empty] ✖ type may not be empty [type-empty]
✖ found 2 problems, 0 warnings ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
husky > commit-msg hook failed (add --no-verify to bypass)`
The same happens to me on MacOS after doing npm install. So it seems it is not only happening on windows.
The subject of a commit must respect a template <type>: <subject>. Type can be: ‘build’, ‘chore’, ‘ci’, ‘docs’, ‘feat’, ‘fix’, ‘perf’, ‘refactor’, ‘revert’, ‘style’ and ‘test’. The subject must be write in lower case.
See the documentation of the conventional config of commitlint. https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional
Here is the answer that solve my problem
If anyone still have problem with this I would advise to read this article. https://dev.to/talohana/husky-and-commitlint-for-clean-git-log-44be
If you are using yarn or the GIT configuration and commit is using type and message the you need to add that. e.g.
git commit -m "TYPE-OF-MESSAGE: Your-msg"
type of message should be upper case.
To suppress the error you may add
--no-verify
at the end of your commit line.git commit -m "your-msg" --no-verify
Unsure if I should open a new issue but have exactly same problem on Windows.
Tried to re-setup commitlint and husky, upgrade node from 10 to 12.
Might be commitlint that does not fire a non-zero exit code?
@przemyslawzalewski No CI for me. but I reran
yarn add husky --dev
and it worked. Maybe part of the issue would of been I installed husky before I init the Git repo.So it works for me now.
Please see if you have a
CI=true
environmental variable defined somewhere in the system settings or during packages install.I had it enabled and it caused the git hooks to be skipped during husky install:
HUSKY_DEBUG=1 git commit
didn’t show anything for me as well. Please inspect yournpm install
logs.