fix: `echo "feat: asdasd" | npx --yes @commitlint/cli` -> Please add rules to your `commitlint.config.js`
Expected Behavior
use default config and dont throw error
Current Behavior
$ echo "feat: asdasd" | npx --yes @commitlint/cli
â§— input: feat: asdasd
✖ Please add rules to your `commitlint.config.js`
- Getting started guide: https://commitlint.js.org/#/?id=getting-started
- Example config: https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/config-conventional/index.js [empty-rules]
✖ found 1 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
Affected packages
- [X] cli
- [ ] core
- [ ] prompt
- [ ] config-angular
Possible Solution
load default config
Steps to Reproduce
1. `echo "feat: asdasd" | npx --yes @commitlint/cli`
2. `echo "feat: asdasd" | npx --yes commitlint`
Context
https://commitlint.js.org/#/guides-local-setup?id=test-simple-usage says "For a first simple usage test of commitlint you can do the following: npx commitlint --from HEAD~1 --to HEAD --verbose" but if you adapt it to read from stdin it does not work.
commitlint --version
@commitlint/[email protected]
git --version
git version 2.42.0
node --version
v20.5.1
It seems that echo "feat: asdasd" | npx --yes commitlint -x @commitlint/config-conventional --verbose works. The cli docs are a bit misleading at https://commitlint.js.org/#/reference-cli
The default npx --yes commitlink should just work in my opinion.
Doubt we gonna fix this. But happy for a PR to adjust the docs.
I assume it might work with at least a commitlint-config (i.e. commitlint.config.js) but not sure.
Thanks for quick reply. Is there any way to run commitlint via npx without installing the @commitlint/config-conventional package via npm beforehand? It's so weird that the cli does not come with a default config!
Ah, sorry, see my updated comment above.
It's a bit weird, because my use case is to configure git to have a pre-receive hook that checks for properly formatted commit messages with commitlint. I want to run npx --yes commitlint so it downloads commitlint and stores it in a temp folder, but does not create any node_modules/ or package.json files.
As npx --yes commitlint only works with npx --yes commitlint -x @commitlint/config-conventional there needs to be a node_modules folder in near the git pre-receive hook which is not ideal.
Is nobody using commitlint in the git pre-receive? When I use it in a github action, the commit is already pushed to the repo and the damage is done.