Add commitlint for commit message linting
See original GitHub issueThe version of ESLint you are using.
7.0.0-alpha.3
The problem you want to solve. Easing the commit message formatting. Currently after committing and pushing it, In PR/push the commit messages gets checked and if there is an error it fails the CI.
Your take on the correct solution to problem.
Eslint does have githooks setup for linting the stage files.
We can use commitlint
in order to lint the commit message in commit-msg
git hook.
commitlint
does provides rules configuration in order to write rules as per our needs and lint on that basis.
Packages needs to add (all devDep)
@commitlint/cli
husky
@commitlint/config-conventional
(optional if want to extend the base rules)`
Rules which I think will satisfy eslint’s format
"commitlint": {
"rules": {
"header-max-length": [
2,
"always",
72
],
"scope-empty": [
2,
"always"
],
"type-enum": [
2,
"always",
[
"Fix",
"Update",
"New",
"Breaking",
"Docs",
"Build",
"Upgrade",
"Chore",
"Sponsors"
]
],
"type-case": [
2,
"always",
"start-case"
],
"type-empty": [
2,
"never"
],
"body-leading-blank": [
1,
"always"
]
}
},
Screen Shot for wrong commit message
Screenshot of correct commit message
Are you willing to submit a pull request to implement this change?
Yes
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (8 by maintainers)
I’m not a fan of front-loading anything but the most important things into the precommit check. It’s already a bit slow and I’m not sure this is important enough to take another hit.
That said, I don’t feel strongly and am happy to go along with consensus if the team wants to move forward.
I think it only lints the latest one of current branch. I will have to confirm that though