fix(#190): add husky pre-commit + pre-push hooks with lint-staged#287
Open
Yzgaming005 wants to merge 1 commit into
Open
fix(#190): add husky pre-commit + pre-push hooks with lint-staged#287Yzgaming005 wants to merge 1 commit into
Yzgaming005 wants to merge 1 commit into
Conversation
…nt-staged
- Add husky 9 + lint-staged 15 as root devDependencies
- Add `"prepare": "husky"` so `npm install` installs the hooks
- Add lint-staged config:
- `*.{ts,tsx,js,jsx,mjs,cjs}` → prettier --write + eslint --fix --max-warnings=0
- `*.{json,md,yml,yaml}` → prettier --write
- `*.rs` → cargo fmt --manifest-path=apps/contracts/Cargo.toml --check
- Add `.husky/pre-commit` → `npx lint-staged`
- Add `.husky/pre-push` → `npm test --workspaces --if-present`
- Document hooks + `--no-verify` bypass in CONTRIBUTING.md
- Add root convenience scripts: `lint`, `format:check`, `test`
Verification:
- `npm install` runs `prepare` → husky installs both hooks
- `npx lint-staged --version` → 15.5.2
- Both hooks are chmod +x in the working tree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #190
Summary
Adds Husky + lint-staged so formatting, linting, and tests run before code leaves the
developer's machine — instead of being caught only by CI minutes later.
Changes
Root package.json
husky ^9.1.7,lint-staged ^15.5.2scripts.prepare: "husky"→npm installwires the hooks automaticallylint,format:check,test(workspace-aware)lint-stagedconfig:*.{ts,tsx,js,jsx,mjs,cjs}→ prettier --write + eslint --fix --max-warnings=0*.{json,md,yml,yaml}→ prettier --write*.rs→ cargo fmt --manifest-path=apps/contracts/Cargo.toml --check.husky/pre-commit (chmod +x)
npx lint-stagedagainst staged files. Bypass withgit commit --no-verify..husky/pre-push (chmod +x)
Runs
npm test --workspace=<dir>only for workspaces touched by the commits beingpushed — so doc-only / config-only pushes don't block on unrelated test failures.
Overrides:
HUSKY_PRE_PUSH_FORCE=1→ always run all workspacesHUSKY_PRE_PUSH_SKIP=1→ skip the hook entirelygit push --no-verifyCONTRIBUTING.md
npm installtriggeringprepare→ husky--no-verifyescape hatchmaintainer agreement
Verification
npm install→ husky installed under.husky/, both files chmod +xnpx lint-staged --version→ 15.5.2apps/backendorapps/frontendfiles are in the commits being pushed--no-verify(tested locally)(
lib/stellar-amount.spec.ts+app/components/BountyCard.spec.tsx) — these areunrelated to this change; the pre-push hook deliberately skips them when the frontend
files aren't touched.
Acceptance criteria (from #190)
pre-commitrunning lint-stagedbuildscript which CI already invokes)--no-verifydocumented in CONTRIBUTING.md