Skip to content

Commit ccf0a9d

Browse files
committed
chore(ci): make the lefthook pre-push hook installable + documented
Add lefthook as a devDependency (^2.1.10) and a prepare: lefthook install script (plus a pnpm onlyBuiltDependencies entry) so the hook installs on pnpm install instead of being a no-op wrapper. Exclude .worktrees from oxfmt and oxlint so nested worktrees don't false-fail the local run. On a failing job the hook now prints the fix command (pnpm run format / pnpm run lint:fix). Document the hook, install, and opt-in/opt-out in CONTRIBUTING.md.
1 parent a686a61 commit ccf0a9d

6 files changed

Lines changed: 140 additions & 2 deletions

File tree

.oxfmtrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"**/storybook-static/",
2222
"**/.changeset/",
2323
"**/dist/",
24+
"**/.worktrees/",
2425
"internal-packages/tsql/src/grammar/",
2526
"internal-packages/llm-model-catalog/src/defaultPrices.ts",
2627
"internal-packages/llm-model-catalog/src/modelCatalog.ts",

.oxlintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"ignorePatterns": [
66
"**/dist/**",
77
"**/build/**",
8+
"**/.worktrees/**",
89
"**/*.d.ts",
910
"**/seed.js",
1011
"**/seedCloud.ts",

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,19 @@ pnpm exec trigger dev --log-level debug
214214
5. Commit the generated migration files as well as the changes to `schema.prisma`.
215215
6. If you're using VSCode you may need to restart the TypeScript server in the webapp to get updated type inference. Open a TypeScript file, then open the Command Palette (View > Command Palette) and run `TypeScript: Restart TS server`.
216216

217+
## Git hooks (lefthook)
218+
219+
We use [lefthook](https://lefthook.dev) for local git hooks, configured in `lefthook.yml` (the source of truth for what runs and when). Today that's a pre-push hook mirroring the CI `code-quality` checks; the set may grow, so check `lefthook.yml` rather than this guide.
220+
221+
Hooks install automatically on `pnpm install`. A failing hook prints exactly what to run to fix it.
222+
223+
**Opting out**
224+
225+
- GitButler skips hooks on `but push` unless you enable **Run hooks** in the project settings (off by default).
226+
- Plain git: `LEFTHOOK=0 git push` / `--no-verify` to skip once; `pnpm exec lefthook uninstall` to remove.
227+
228+
This never affects correctness — CI enforces the same checks on every PR; the hooks just give you faster feedback.
229+
217230
## Making a pull request
218231

219232
**If you get errors, be sure to fix them before committing.**

lefthook.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ pre-push:
1313
parallel: true
1414
jobs:
1515
- name: format
16-
run: pnpm exec oxfmt --check .
16+
run: |
17+
pnpm exec oxfmt --check . || {
18+
echo ""
19+
echo "✖ Formatting issues found. Fix them with:"
20+
echo ""
21+
echo " pnpm run format"
22+
echo ""
23+
echo " then stage the changes and re-push."
24+
echo ""
25+
exit 1
26+
}
1727
- name: lint
18-
run: pnpm exec oxlint .
28+
run: |
29+
pnpm exec oxlint . || {
30+
echo ""
31+
echo "✖ Lint errors found. Auto-fix what's fixable with:"
32+
echo ""
33+
echo " pnpm run lint:fix"
34+
echo ""
35+
echo " then review, stage, and re-push (some rules need a manual fix)."
36+
echo ""
37+
exit 1
38+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"format:prisma": "pnpm --filter @trigger.dev/database run format:prisma && pnpm --filter @internal/run-ops-database run format:prisma",
2323
"lint": "oxlint",
2424
"lint:fix": "oxlint --fix",
25+
"prepare": "lefthook install",
2526
"knip:deps": "knip --production --dependencies",
2627
"docker": "node scripts/docker.mjs -f docker/docker-compose.yml up -d --build --remove-orphans",
2728
"docker:stop": "node scripts/docker.mjs -f docker/docker-compose.yml stop",
@@ -62,6 +63,7 @@
6263
"@vitest/coverage-v8": "4.1.7",
6364
"autoprefixer": "^10.4.12",
6465
"knip": "6.25.0",
66+
"lefthook": "^2.1.10",
6567
"oxfmt": "^0.54.0",
6668
"oxlint": "^1.69.0",
6769
"pkg-pr-new": "0.0.75",
@@ -150,6 +152,7 @@
150152
"better-sqlite3",
151153
"cpu-features",
152154
"esbuild",
155+
"lefthook",
153156
"prisma",
154157
"protobufjs",
155158
"sharp",

pnpm-lock.yaml

Lines changed: 100 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)