Skip to content

Commit 5a9fd2b

Browse files
Arthiefengmk2
andauthored
chore: replace husky with vp git hooks (#1001)
Replace husky and lint-staged with the built-in Vite+ hooks, so this repo dogfoods `vp config` and `vp staged`. - `.vite-hooks/pre-commit` runs `vp staged` - The lint-staged rules move to the `staged` block in `vite.config.ts` - `prepare` runs `vp config` instead of `husky` - Remove husky and lint-staged from the root package.json and husky from the catalog (`packages/cli` keeps lint-staged, it implements `vp staged`) Hooks stay opt-in: the repo sets `ignoreScripts: true`, so `prepare` does not run on `pnpm install`. To activate, run `vp config` after `pnpm build`. If a clone activated husky before, run `git config --unset core.hooksPath` once first. Earlier revisions also committed `vp config` agent files (`.claude/settings.json`, a skills symlink, a CLAUDE.md block). The rebase dropped them: `vp mcp` and the shipped skills directory no longer exist, and repo guidance now lives in AGENTS.md. --------- Co-authored-by: MK <fengmk2@gmail.com>
1 parent 302f2d7 commit 5a9fd2b

7 files changed

Lines changed: 10 additions & 25 deletions

File tree

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
This file was deleted.

.vite-hooks/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vp staged

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ To create a release build of Vite+ and all upstream dependencies, run:
5353
just build
5454
```
5555

56+
## Git Hooks (optional)
57+
58+
Pre-commit checks are opt-in. Run `vp config` after a build to install the hook dispatcher; each commit then runs `vp staged` on staged files. `vp staged` loads its config from `vite.config.ts` and needs the built JS packages, so build first. Opt out with `vp hooks disable`, or skip one run with `VP_GIT_HOOKS=0`. If husky was active in your clone before, run `git config --unset core.hooksPath` once first.
59+
5660
## Install the Vite+ Global CLI from source code
5761

5862
```bash

package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"docs:dev": "pnpm -C docs dev",
2121
"docs:build": "pnpm -C docs build",
2222
"docs:update-trusted-stack-stats": "pnpm -C docs update-trusted-stack-stats",
23-
"prepare": "husky"
23+
"prepare": "vp config"
2424
},
2525
"devDependencies": {
2626
"@emnapi/core": "catalog:",
@@ -30,18 +30,12 @@
3030
"@types/node": "catalog:",
3131
"@typescript/native-preview": "catalog:",
3232
"@voidzero-dev/vite-plus-tools": "workspace:*",
33-
"husky": "catalog:",
34-
"lint-staged": "catalog:",
3533
"playwright": "catalog:",
3634
"typescript": "catalog:",
3735
"vite": "catalog:",
3836
"vite-plus": "workspace:*",
3937
"vitest": "catalog:"
4038
},
41-
"lint-staged": {
42-
"*.@(js|ts|tsx|md|yaml|yml)": "vp check --fix",
43-
"*.rs": "cargo fmt --"
44-
},
4539
"engines": {
4640
"node": ">=22.18.0"
4741
},

pnpm-lock.yaml

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

pnpm-workspace.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ catalog:
8686
fresh-import: ^0.2.1
8787
fs-extra: ^11.4.0
8888
glob: ^13.0.0
89-
husky: ^9.1.7
9089
jsonc-parser: ^3.3.1
9190
# Kept in lockstep with the bundled @tsdown/css by .github/scripts/upgrade-deps.ts
9291
lightningcss: ^1.33.0

vite.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { defineConfig } from 'vite-plus';
22

33
export default defineConfig({
4+
staged: {
5+
'*.@(js|ts|tsx|md|yaml|yml)': 'vp check --fix',
6+
'*.rs': 'cargo fmt --',
7+
},
48
lint: {
59
options: {
610
typeAware: true,

0 commit comments

Comments
 (0)