feat: add pre-commit hooks for SQLx preparation, backend check, and frontend linting

This commit is contained in:
SquidSpirit 2025-10-15 12:38:48 +08:00
parent d22f8cc292
commit 2df96e966d
4 changed files with 36 additions and 0 deletions

18
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,18 @@
repos:
- repo: local
hooks:
- id: sqlx-prepare
name: sqlx prepare
language: script
entry: ./script/sqlx-prepare.sh
pass_filenames: false
- id: backend-check
name: backend check
language: system
entry: ./script/backend-check.sh
pass_filenames: false
- id: frontend-lint
name: frontend lint
language: system
entry: ./script/frontend-lint.sh
pass_filenames: false

6
script/backend-check.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
cd "$SCRIPT_DIR/../backend"
cargo check

6
script/frontend-lint.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
cd "$SCRIPT_DIR/../frontend"
pnpm lint

6
script/sqlx-prepare.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
cd "$SCRIPT_DIR/../backend"
cargo sqlx prepare --workspace