Skip to content

Commit 930ec0b

Browse files
committed
chore: add pre-commit checks for the commit message
1 parent 3146a13 commit 930ec0b

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

.husky/pre-commit

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
commit_msg_file=$(git rev-parse --git-path COMMIT_EDITMSG)
4+
commit_msg=$(head -n1 "$commit_msg_file")
5+
6+
regex="^(fix|feat|chore|docs): [a-z].+$"
7+
8+
if ! echo "$commit_msg" | grep -Eq "$regex"; then
9+
echo "Commit message does not follow Conventional Commits format: <type>: <lowercase message>"
10+
echo "Allowed types: fix, feat, chore, docs"
11+
exit 1
12+
fi

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"test:ci": "pnpm lint:fix && pnpm build && pnpm test && pnpm test:e2e",
2525
"docs:dev": "vitepress dev docs",
2626
"docs:build": "vitepress build docs",
27-
"docs:preview": "vitepress preview docs"
27+
"docs:preview": "vitepress preview docs",
28+
"prepare": "husky"
2829
},
2930
"dependencies": {
3031
"@popperjs/core": "2.11.8",
@@ -57,6 +58,7 @@
5758
"eslint-plugin-prettier": "5.4.0",
5859
"eslint-plugin-vue": "10.1.0",
5960
"html-minifier-terser": "7.2.0",
61+
"husky": "9.1.7",
6062
"prettier": "3.5.3",
6163
"sass": "1.89.0",
6264
"typescript": "5.8.3",

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)