Skip to content

Commit bb4c1b0

Browse files
committed
chore: add git hooks
1 parent dfa8e51 commit bb4c1b0

File tree

6 files changed

+240
-2
lines changed

6 files changed

+240
-2
lines changed

.husky/pre-commit

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh
2+
3+
if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
4+
set -x
5+
fi
6+
7+
if [ "$LEFTHOOK" = "0" ]; then
8+
exit 0
9+
fi
10+
11+
call_lefthook()
12+
{
13+
if test -n "$LEFTHOOK_BIN"
14+
then
15+
"$LEFTHOOK_BIN" "$@"
16+
elif lefthook.exe -h >/dev/null 2>&1
17+
then
18+
lefthook.exe "$@"
19+
elif lefthook.bat -h >/dev/null 2>&1
20+
then
21+
lefthook.bat "$@"
22+
else
23+
dir="$(git rev-parse --show-toplevel)"
24+
osArch=$(uname | tr '[:upper:]' '[:lower:]')
25+
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
26+
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook.exe"
27+
then
28+
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook.exe" "$@"
29+
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook.exe"
30+
then
31+
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook.exe" "$@"
32+
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook.exe"
33+
then
34+
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook.exe" "$@"
35+
elif test -f "$dir/node_modules/lefthook/bin/index.js"
36+
then
37+
"$dir/node_modules/lefthook/bin/index.js" "$@"
38+
39+
elif bundle exec lefthook -h >/dev/null 2>&1
40+
then
41+
bundle exec lefthook "$@"
42+
elif yarn lefthook -h >/dev/null 2>&1
43+
then
44+
yarn lefthook "$@"
45+
elif pnpm lefthook -h >/dev/null 2>&1
46+
then
47+
pnpm lefthook "$@"
48+
elif swift package plugin lefthook >/dev/null 2>&1
49+
then
50+
swift package --disable-sandbox plugin lefthook "$@"
51+
elif command -v mint >/dev/null 2>&1
52+
then
53+
mint run csjones/lefthook-plugin "$@"
54+
elif command -v npx >/dev/null 2>&1
55+
then
56+
npx lefthook "$@"
57+
else
58+
echo "Can't find lefthook in PATH"
59+
fi
60+
fi
61+
}
62+
63+
call_lefthook run "pre-commit" "$@"

.husky/prepare-commit-msg

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh
2+
3+
if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
4+
set -x
5+
fi
6+
7+
if [ "$LEFTHOOK" = "0" ]; then
8+
exit 0
9+
fi
10+
11+
call_lefthook()
12+
{
13+
if test -n "$LEFTHOOK_BIN"
14+
then
15+
"$LEFTHOOK_BIN" "$@"
16+
elif lefthook.exe -h >/dev/null 2>&1
17+
then
18+
lefthook.exe "$@"
19+
elif lefthook.bat -h >/dev/null 2>&1
20+
then
21+
lefthook.bat "$@"
22+
else
23+
dir="$(git rev-parse --show-toplevel)"
24+
osArch=$(uname | tr '[:upper:]' '[:lower:]')
25+
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
26+
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook.exe"
27+
then
28+
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook.exe" "$@"
29+
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook.exe"
30+
then
31+
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook.exe" "$@"
32+
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook.exe"
33+
then
34+
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook.exe" "$@"
35+
elif test -f "$dir/node_modules/lefthook/bin/index.js"
36+
then
37+
"$dir/node_modules/lefthook/bin/index.js" "$@"
38+
39+
elif bundle exec lefthook -h >/dev/null 2>&1
40+
then
41+
bundle exec lefthook "$@"
42+
elif yarn lefthook -h >/dev/null 2>&1
43+
then
44+
yarn lefthook "$@"
45+
elif pnpm lefthook -h >/dev/null 2>&1
46+
then
47+
pnpm lefthook "$@"
48+
elif swift package plugin lefthook >/dev/null 2>&1
49+
then
50+
swift package --disable-sandbox plugin lefthook "$@"
51+
elif command -v mint >/dev/null 2>&1
52+
then
53+
mint run csjones/lefthook-plugin "$@"
54+
elif command -v npx >/dev/null 2>&1
55+
then
56+
npx lefthook "$@"
57+
else
58+
echo "Can't find lefthook in PATH"
59+
fi
60+
fi
61+
}
62+
63+
call_lefthook run "prepare-commit-msg" "$@"

lefthook.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pre-commit:
2+
parallel: true
3+
commands:
4+
prettier:
5+
glob: "*.{js,jsx,ts,tsx,json,md,mdx,yml}"
6+
run: npx prettier --write {staged_files}
7+
eslint:
8+
glob: "*.{js,jsx,ts,tsx}"
9+
run: npx eslint --fix {staged_files}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"next.js",
1414
"react-aria",
1515
"tailwind",
16-
"typescript"
16+
"typescript"
1717
],
1818
"scripts": {
1919
"build": "turbo run build",
@@ -48,6 +48,7 @@
4848
"eslint-config-next": "^14.0.4",
4949
"eslint-config-prettier": "^9.1.0",
5050
"eslint-config-turbo": "^2.1.3",
51+
"lefthook": "^1.7.18",
5152
"prettier": "^3.3.3",
5253
"prettier-plugin-tailwindcss": "^0.6.8",
5354
"turbo": "^2.0.12"

pnpm-lock.yaml

+101
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

www/src/config/site-config.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ export const searchConfig = {
3131
{ name: "Installation", href: "/docs/getting-started/installation" },
3232
{ name: "Button", href: "/docs/components/buttons/button" },
3333
{ name: "TextField", href: "/docs/components/inputs/text-field" },
34-
{ name: "Menu", href: "/docs/components/menus-and-selection/menu" }, ],
34+
{ name: "Menu", href: "/docs/components/menus-and-selection/menu" },
35+
],
3536
};

0 commit comments

Comments
 (0)