Skip to content

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

Closed

Description

@rkristelijn

Problem

Style and lint errors (e.g. @stylistic/space-before-function-paren, unused vars) regularly slip into PRs because there is no automated check before commit. Reviewers spend time on mechanical issues that a tool should catch.

The project has ESLint, Prettier, and vue-tsc configured — but nothing enforces them before code reaches CI.

Proposed solution

Add husky + lint-staged so every git commit automatically runs:

  1. ESLint --fix on staged .ts, .vue, .js files
  2. Prettier on staged files (already configured via .prettierrc.yaml)
  3. vue-tsc type-check (optional — may be too slow for pre-commit; could be pre-push instead)

Implementation sketch

pnpm add -D husky lint-staged -w
pnpm exec husky init

.husky/pre-commit:

pnpm exec lint-staged

Root package.json:

{
  "lint-staged": {
    "packages/desktop/**/*.{ts,vue}": ["eslint --fix", "prettier --write"],
    "packages/desktop/**/*.{json,md,yaml}": ["prettier --write"]
  }
}

Benefits

  • Zero lint errors in PRs (shift-left)
  • Faster review cycles — reviewers focus on logic, not style
  • Consistent with CLAUDE.md guideline: "Run pnpm run lint before committing"
  • Auto-fixable issues are silently fixed; only real errors block the commit

Considerations

  • vue-tsc takes ~7s — may be better as a pre-push hook or CI-only
  • The existing pnpm run lint CI gate stays as the safety net
  • First-time contributors get immediate feedback instead of CI failure minutes later

Activity

  1. added a commit that references this issue on Sep 2, 2026
    e3dc23e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions