Skip to content

chore: add pre-commit hooks (husky + lint-staged) - #4999

Merged
Jocs merged 1 commit into
marktext:developfrom
rkristelijn:chore/pre-commit-hooks
Sep 2, 2026
Merged

Jocs merged 1 commit into
marktext:developfrom
rkristelijn:chore/pre-commit-hooks

Conversation

@rkristelijn

Copy link
Copy Markdown
Contributor

Summary

Adds shift-left quality enforcement so lint/style errors are caught at commit time, not at PR review.

Changes

  • husky — git hook manager, runs .husky/pre-commit on every commit
  • lint-staged — runs ESLint --fix + Prettier only on staged files (fast)
  • pnpm.overrides migration — moved from package.json (deprecated in pnpm v10) to pnpm-workspace.yaml, eliminating the [WARN] The "pnpm" field in package.json is no longer read warning

What the pre-commit hook does

Staged files Action
packages/desktop/src/**/*.{ts,vue} eslint --fix → prettier --write
packages/desktop/test/**/*.ts eslint --fix → prettier --write
*.{json,md,yaml} prettier --write

Benefits

  • Auto-fixable style issues (spacing, quotes, semicolons) are fixed silently
  • Real lint errors block the commit with immediate feedback
  • No more "fix lint" follow-up commits in PRs
  • Consistent with CLAUDE.md guideline: "Run pnpm run lint before committing"

Verification

  • pnpm install ✅ (no more pnpm field warning)
  • pnpm exec lint-staged ✅ (runs on staged files)
  • Commit with the hook active ✅ (this commit itself was validated by the hook)

Closes #4998

…rcement

- Add husky for git hook management
- Add lint-staged to run ESLint --fix + Prettier on staged files
- Migrate pnpm.overrides from package.json to pnpm-workspace.yaml
  (fixes 'pnpm field is no longer read' warning in pnpm v10)
- Pre-commit runs: eslint --fix + prettier on src/test .ts/.vue files,
  prettier on .json/.md/.yaml files

Closes marktext#4998
@Jocs
Jocs merged commit e3dc23e into marktext:develop Sep 2, 2026
1 check 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.

chore: add pre-commit hooks (husky + lint-staged) for shift-left quality enforcement

2 participants