Use prek for pre-commit hooks
CI / checks (push) Successful in 1m40s

This commit is contained in:
ponas committed 2026-07-30 02:25:29 +02:00
1 parent 0e1f44d097
commit 4fe1a1cdc0
3 files changed
+66 -10

No files matched your search

+23 -10
View File
@@ -12,8 +12,21 @@ command-line tools.
mise trust
mise install
npm install
prek install
cp env-example .env.local
## Scripts
- `npm run start` - Start Expo development server on port 19001
- `npm run android` - Run app in Android emulator
- `npm run ios` - Run app in iOS simulator (requires macOS)
- `npm run web` - Run app in web browser
- `npm run lint` - Check code with ESLint
- `npm run format` - Fix code formatting with ESLint
- `npm run check-types` - Run TypeScript type checking
- `npm test` - Run the test suite
- `npm run test:watch` - Run the test suite in watch mode
## Development
This app uses native functionality that isn't supported by [Expo Go](https://expo.dev/client),
@@ -54,17 +67,17 @@ Many packages (`expo-*`, `react-native`, and more) are versioned in lockstep wit
Expo SDK. Check them with `npx expo install --check` and upgrade with
`npx expo install --fix` instead of `npm update`.
## Scripts
## Pre-commit hooks
- `npm run start` - Start Expo development server on port 19001
- `npm run android` - Run app in Android emulator
- `npm run ios` - Run app in iOS simulator (requires macOS)
- `npm run web` - Run app in web browser
- `npm run lint` - Check code with ESLint
- `npm run format` - Fix code formatting with ESLint
- `npm run check-types` - Run TypeScript type checking
- `npm test` - Run the test suite
- `npm run test:watch` - Run the test suite in watch mode
Git hooks are managed with [prek](https://prek.j178.dev/) (installed by `mise install`)
and configured in `prek.toml`. Enable them with:
prek install
Commits then only succeed if linting, type checking and the related tests pass. Run all
hooks against the whole repo with:
prek run --all-files
## History
+1
View File
@@ -2,3 +2,4 @@
android-sdk = "latest"
java = "temurin-17"
node = "24"
prek = "latest"
+42
View File
@@ -0,0 +1,42 @@
#:schema https://www.schemastore.org/prek.json
[[repos]]
repo = "builtin"
hooks = [
{ id = "check-added-large-files" },
{ id = "check-case-conflict" },
{ id = "check-json", exclude = '^tsconfig\.json$' }, # tsconfig is JSONC, comments allowed
{ id = "check-merge-conflict" },
{ id = "check-yaml" },
{ id = "detect-private-key" },
{ id = "end-of-file-fixer" },
{ id = "mixed-line-ending", args = ["--fix=lf"] },
{ id = "trailing-whitespace", args = ["--markdown-linebreak-ext=md"] },
]
[[repos]]
repo = "local"
[[repos.hooks]]
id = "eslint"
name = "eslint"
entry = "npx --no-install eslint --fix --no-warn-ignored"
language = "system"
types_or = ["javascript", "jsx", "ts", "tsx"]
[[repos.hooks]]
id = "check-types"
name = "tsc"
entry = "npx --no-install tsc"
language = "system"
files = '\.tsx?$|^tsconfig\.json$'
pass_filenames = false
[[repos.hooks]]
id = "jest"
name = "jest (tests related to staged files)"
entry = "npx --no-install jest --bail --findRelatedTests --passWithNoTests"
language = "system"
types_or = ["javascript", "jsx", "ts", "tsx"]
# One jest invocation for all files — parallel invocations contend and time out
require_serial = true