diff --git a/.husky/_/husky.sh b/.husky/_/husky.sh new file mode 100755 index 0000000..4912ece --- /dev/null +++ b/.husky/_/husky.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env sh +if [ -z "$husky_skip_init" ]; then + debug () { + if [ "$HUSKY_DEBUG" = "1" ]; then + echo "husky (debug) - $1" + fi + } + + readonly hook_name="$(basename -- "$0")" + debug "starting $hook_name..." + + if [ "$HUSKY" = "0" ]; then + debug "HUSKY env variable is set to 0, skipping hook" + exit 0 + fi + + if [ -f ~/.huskyrc ]; then + debug "sourcing ~/.huskyrc" + . ~/.huskyrc + fi + + readonly husky_skip_init=1 + export husky_skip_init + sh -e "$0" "$@" + exitcode="$?" + + if [ $exitcode != 0 ]; then + echo "husky - $hook_name hook exited with code $exitcode (error)" + fi + + if [ $exitcode = 127 ]; then + echo "husky - command not found in PATH=$PATH" + fi + + exit $exitcode +fi \ No newline at end of file diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 0000000..e4b9545 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +echo "🔍 Running pre-push validation for web app..." +cd apps/web && pnpm validate \ No newline at end of file diff --git a/apps/web/package.json b/apps/web/package.json index da4aa5b..f1b7f34 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -21,6 +21,9 @@ "lint:fix": "eslint \"src/**/*.+(ts|tsx)\" --fix", "format": "prettier . --write", "format:check": "prettier . --check", + "type-check": "npx tsc --noEmit", + "validate": "pnpm format && pnpm lint:fix && pnpm type-check", + "prepare": "husky", "translations": "python3 scripts/run_translations.py all", "translations:check": "python3 scripts/run_translations.py check", "translations:sync": "python3 scripts/run_translations.py sync", @@ -86,6 +89,7 @@ "eslint-config-next": "15.3.4", "eslint-config-prettier": "9.1.0", "eslint-plugin-prettier": "5.5.1", + "husky": "^9.1.7", "prettier": "3.6.2", "prettier-plugin-sort-json": "4.1.1", "tailwindcss": "4.1.11", diff --git a/apps/web/pnpm-lock.yaml b/apps/web/pnpm-lock.yaml index b7dc18b..3d15169 100644 --- a/apps/web/pnpm-lock.yaml +++ b/apps/web/pnpm-lock.yaml @@ -176,6 +176,9 @@ importers: eslint-plugin-prettier: specifier: 5.5.1 version: 5.5.1(eslint-config-prettier@9.1.0(eslint@9.30.0(jiti@2.4.2)))(eslint@9.30.0(jiti@2.4.2))(prettier@3.6.2) + husky: + specifier: ^9.1.7 + version: 9.1.7 prettier: specifier: 3.6.2 version: 3.6.2 @@ -2265,6 +2268,12 @@ packages: { integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== } engines: { node: ">= 0.4" } + husky@9.1.7: + resolution: + { integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA== } + engines: { node: ">=18" } + hasBin: true + ignore@5.3.2: resolution: { integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g== } @@ -5294,6 +5303,8 @@ snapshots: dependencies: function-bind: 1.1.2 + husky@9.1.7: {} + ignore@5.3.2: {} ignore@7.0.5: {}