Skip to content

Set up Husky and lint-staged pre-commit hooks - #64

Merged
Muhammadcodes112 merged 1 commit into
MiHashport:mainfrom
chillwur:issue-4-husky-lint-staged
Jul 10, 2026
Merged

Muhammadcodes112 merged 1 commit into
MiHashport:mainfrom
chillwur:issue-4-husky-lint-staged

Conversation

@chillwur

Copy link
Copy Markdown
Contributor

Problem

Lint, format, and typecheck issues currently aren't caught until CI runs on a pushed branch. That feedback loop is slow — a contributor can push several commits before finding out a file wasn't formatted or has an ESLint error, when the fix would have taken seconds if caught locally at commit time.

Solution

  • Added husky and lint-staged as root dev dependencies, with a prepare: husky script so hooks are installed automatically on pnpm install.
  • Added a .husky/pre-commit hook that runs pnpm exec lint-staged.
  • Configured lint-staged in the root package.json:
    • Staged .ts files under apps/backend run that workspace's ESLint (--fix) then Prettier (--write).
    • Staged .ts/.tsx files under apps/frontend run that workspace's ESLint (--fix) then Prettier (--write).
    • Staged .rs files under contracts/* run cargo fmt --check against the contract's Cargo.toml.
  • Only staged files are touched, so the hook stays fast — it does not run the full pnpm build/pnpm test suite.
  • Documented the hook and how to bypass it in exceptional cases (git commit --no-verify) in CONTRIBUTING.md, noting CI still runs the full checks regardless.
  • Verified the hook end-to-end: staging a deliberately malformed .ts file and running lint-staged correctly reformatted it before commit.

closes #4

@Muhammadcodes112
Muhammadcodes112 merged commit f6ac1e7 into MiHashport:main Jul 10, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set up Husky + lint-staged pre-commit hooks

2 participants