-
Notifications
You must be signed in to change notification settings - Fork 914
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
feat: exit with a code >3 when configuration is missing or incomplete #4142
Comments
Digged a bit. This is what happens if there's no config: ...
⧗ input: foo
✖ Please add rules to your `commitlint.config.js`
- Getting started guide: https://commitlint.js.org/guides/getting-started
- Example config: https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/config-conventional/src/index.ts [empty-rules]
✖ found 1 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
husky - commit-msg script failed (code 1) In this case it's husky failing with code 1, right? You mean that? Looks like we're just using the commitlint default errors to display the "missing config"-error. I'm not sure how to adjust the husky error code based on commitlints outcome. I assume this would be necessary here? Edit: Sorry, just saw your steps now and seeing this looks like it's coming from commitlint directly. Need to check if this can be adjusted somewhere. |
@ferrarimarco have a look at the PR. Does this make sense to you? |
Thanks! I'll have a look at the PR :) |
@escapedcat maybe it could be useful to update the CLI docs page as well, so users are aware of this feature? Thanks! |
What kind of update would you expect to see there? |
Maybe an addition to the |
And thanks for releasing a new version so quickly! |
Updated the docs as well |
Thanks! |
Expected Behavior
Exit with a code that's greater than
0
, and different from1
,2
, and3
when the configuration from the CLI is incomplete (such as when missing--extends
), or when there's no configuration file.Current Behavior
Commitlint exits with an exit code equal to
1
when there are configuration errors or when there are linting errors. This makes it impossible to differentiate between linting issues and commitlint configuration issues.Affected packages
Possible Solution
I don't know much about commitlint implementation to suggest a possible design. :(
I'm suggesting something different from:
1
(commit linting errors)2
and3
(commit linting errors and warnings in strict mode)Context
Steps to reproduce the behavior:
mkdir /tmp/test-commitlint
cd /tmp/test-commitlint
git init
touch test.txt
git add test.txt
git commit -m "Initial commit"
commitlint --last
Output (expected):
echo $?
commitlint --version
Output:
Thanks!
The text was updated successfully, but these errors were encountered: