commitlint
commitlint copied to clipboard
CommitLint with Yarn v2 (Plug'n'play)
Expected Behavior
In the yarn v1 and yarn v2 (with nodeLinker: node_modules), commitlint work perfectly
Current Behavior
It doesn't work at all. I've tried these command in git-hook (husky):
npx --no-install commitlint --edit "$1"yarn --no-install commitlint --edit "$1"yarn run --no-install commitlint --edit "$1"
Here is the pictures of this problem:



Affected packages
- [x] cli
- [ ] core
- [ ] prompt
- [ ] config-angular
Steps to Reproduce (for bugs)
Link for my repo (bypass git hook)
- yarn init && yarn set version berry
- yarn add -D @commitlint/config-conventional @commitlint/cli husky
- yarn husky install
- echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js
- npx husky add .husky/commit-msg 'npx --no-install commitlint --edit "$1"'
- Commit change
Context
Your Environment
Mac OS X 10.11.6 El Captain
| Executable | Version |
|---|---|
commitlint --version |
bash: commitlint: command not found |
yarn run commitlint --version |
@commitlint/[email protected] (Need yarn run, see here |
git --version |
git version 2.29.2 |
node --version |
v14.15.3 |
Tbh I think we don't support yarn 2 at the moment.
Probably should mention this in the docs.
Happy for a PR.
Tbh I think we don't support yarn 2 at the moment. Probably should mention this in the docs. Happy for a PR.
I've created it here: #2638
I've just tried in a fresh Yarn 2 (PNP) monorepo project and it works.
yarn --version
2.4.2
yarn run commitlint --edit "$1"
Do you mind sharing your monorepo?
sure, here is a trimmed copy: https://github.com/plus-/yarn-commitlint-sample
@loctran016 do we need to udpate the docs in a way?
Context for anyone that stumbles upon this: If you're using Plug n Play, you'll want to go .husky/commit-msg and update the npx command to be the yarn run command, as listed here: https://github.com/conventional-changelog/commitlint/issues/2637#issuecomment-866118830
It essentially works, but the current documentation doesn't fully account for it.
@reywright thanks for your comment! Wanna create a PR to fix the docs?
With yarn ~v3~ v2 (3.2.1), I'm running into an issue when amending commits -- it seems the last commit message is being checked, rather than the new amending message.
Here's an example:
❯ yarn -v
3.2.1
❯ touch .temp && git add .temp
❯ git commit -m "build: add .temp"
.husky/pre-commit
[build/wip d55d5ec] build: add .temp
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 .temp
❯ git commit --amend -m "nonsense: blah"
.husky/pre-commit
[build/wip 87555c4] nonsense: blah
Date: Thu May 26 06:03:06 2022 -0400
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 .temp
❯ git commit --amend -m "build: add .temp"
.husky/pre-commit
⧗ input: nonsense: blah
✖ type must be one of [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test] [type-enum]
✖ found 1 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
husky - pre-commit hook exited with code 1 (error)
has anyone else run into this issue?
Your Environment
MacOS Monterey 12.4 (21F79)
| Executable | Version |
|---|---|
| commitlint --version | zsh: commitlint: command not found |
| yarn run commitlint --version | @commitlint/[email protected] |
| git --version | git version 2.36.1 |
| node --version | v17.3.1 |
@sbolel is v3 very different from v2 (plug 'n play)?
If yes, wanna create a new issue for yarn v3? Might be worth to tackle this separately? I'm not too familiar with v3.
@escapedcat sorry, yarn 3.2.1 is actually still "yarn v2"
https://stackoverflow.com/a/69089979/1526037