Skip to content

Commit f01a7ce

Browse files
committed
chore: setup husky
1 parent dfb3938 commit f01a7ce

File tree

7 files changed

+658
-15
lines changed

7 files changed

+658
-15
lines changed

.commitlintrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
extends: ['@commitlint/config-conventional'],
3+
};

.husky/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/commit-msg

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
yarn commitlint --edit "$1"

.husky/pre-commit

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
# Get the current branch name
5+
branch_name=$(git symbolic-ref --short HEAD)
6+
7+
# Prevent direct commits to the main or dev branch
8+
if [ "$branch_name" = "main" ]; then
9+
echo "Direct commits to the $branch_name branch are prohibited."
10+
echo "Please commit to an appropriate branch and merge it instead."
11+
exit 1
12+
fi
13+
14+
yarn lint-staged

.lintstagedrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"**/*.{ts,tsx,js,cjs,mjs,json}": ["prettier --write"],
3+
"**/*.{ts,mjs,cjs,spec.js}": ["eslint --fix"],
4+
".github/workflows/*.yml": ["actionlint"],
5+
"**": ["cspell --no-must-find-files --no-progress --show-suggestions"]
6+
}

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
"xterm": "5.3.0"
3434
},
3535
"devDependencies": {
36+
"@commitlint/cli": "^19.4.0",
37+
"@commitlint/config-conventional": "^19.2.2",
3638
"@egoist/tailwindcss-icons": "1.8.1",
3739
"@iconify-json/heroicons-solid": "1.1.12",
3840
"@iconify-json/majesticons": "1.1.12",
@@ -60,7 +62,9 @@
6062
"eslint-plugin-react-refresh": "0.4.9",
6163
"eslint-plugin-testing-library": "6.3.0",
6264
"eslint-plugin-vitest": "0.5.4",
65+
"husky": "^9.1.5",
6366
"jsdom": "24.1.1",
67+
"lint-staged": "^15.2.9",
6468
"npm-run-all2": "6.2.2",
6569
"postcss": "8.4.41",
6670
"prettier": "3.3.3",

0 commit comments

Comments
 (0)