Skip to content

Commit d8bfa38

Browse files
feat(config): check if the commit message is a conventional commit
- For the husky v.8 not use the `.huskyrc` file for set the configuration. Set the configuration inside the `.husky` folder, in the individual files as the `commit-msg` hook. https://typicode.github.io/husky/#/?id=migrate-from-v4-to-v8 Steps: - Add the next command to the `commit-msg` hook: `npx --no -- commitlint --edit $1` Error: - Error: Cannot find module "@commitlint/config-conventional" from "/Applications/MAMP/htdocs/vue-todolist" at resolveId (/Users/beatrizsmerino/.npm/_npx/16d437951fea4b5e/node_modules/@commitlint/resolve-extends/src/index.ts:131:14) - ✖ body's lines must not be longer than 100 characters [body-max-line-length] ✖ found 1 problems, 0 warnings ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint Solution: - Install locally the packages: `npm install @commitlint/cli @commitlint/config-conventional --save-dev` `npm install commitizen cz-conventional-changelog --save-dev` - Update the configuration `commitlint`, increase the `body-max-line-length` References: - https://www.youtube.com/watch?v=jNxDNoYEGVU - https://www.youtube.com/watch?v=OJqUWvmf4gg - https://gist.github.com/qoomon/5dfcdf8eec66a051ecd85625518cfd13 - https://github.com/qoomon/git-conventional-commits - https://remarkablemark.org/blog/2019/05/29/git-husky-commitlint/ - https://typicode.github.io/husky/#/?id=husky_git_params-ie-commitlint- - https://stackoverflow.com/a/67074398 - https://rahulgurung.com/How-to-use-the-latest-Husky-8-with-Commitizen-for-adding-git-hooks-to-your-projects/ - https://www.techiediaries.com/git-hooks-husky-commitlint/ - https://www.freecodecamp.org/news/how-to-use-commitlint-to-write-good-commit-messages/ - https://medium.com/dottech/mejorando-los-mensajes-de-git-commit-con-husky-y-commitlint-7bddf6ab22c2 - commitizen/cz-cli#289 - https://github.com/conventional-changelog/commitlint - conventional-changelog/commitlint#613 - https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/config-conventional/index.js - https://github.com/conventional-changelog/commitlint/blob/master/docs/reference-rules.md#body-max-line-length
1 parent 2d46888 commit d8bfa38

File tree

4 files changed

+2215
-659
lines changed

4 files changed

+2215
-659
lines changed

.commitlintrc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
module.exports = {
2-
extends: [
1+
{
2+
"extends": [
33
"@commitlint/config-conventional"
4-
]
5-
};
4+
],
5+
"rules": {
6+
"body-max-line-length": [
7+
2,
8+
"always",
9+
2000
10+
]
11+
}
12+
}

.husky/commit-msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
echo "pre-received"
4+
npx --no -- commitlint --edit "$1"

0 commit comments

Comments
 (0)