Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: echo "feat: asdasd" | npx --yes @commitlint/cli -> Please add rules to your commitlint.config.js #3662

Open
1 of 4 tasks
bf opened this issue Aug 31, 2023 · 5 comments
Open
1 of 4 tasks
Labels

Comments

@bf
Copy link

bf commented Aug 31, 2023

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

  • 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/cli@17.7.1

git --version

git version 2.42.0

node --version

v20.5.1

@bf bf added the bug label Aug 31, 2023
@bf
Copy link
Author

bf commented Aug 31, 2023

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.

@escapedcat
Copy link
Member

escapedcat commented Aug 31, 2023

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.

@bf
Copy link
Author

bf commented Aug 31, 2023

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!

@escapedcat
Copy link
Member

Ah, sorry, see my updated comment above.

@bf
Copy link
Author

bf commented Aug 31, 2023

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.

@escapedcat escapedcat added feature and removed bug labels Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants