Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre-commit hooks for lint and format commands #66

Closed
bhouston opened this issue Mar 4, 2025 · 1 comment
Closed

Add pre-commit hooks for lint and format commands #66

bhouston opened this issue Mar 4, 2025 · 1 comment

Comments

@bhouston
Copy link
Member

bhouston commented Mar 4, 2025

Overview

Implement pre-commit hooks to automatically run the project's lint and format commands before each commit. This will help maintain code quality and consistency throughout the codebase.

Implementation Plan

  1. Install required dependencies:

    pnpm add -D husky lint-staged
  2. Add configuration to package.json:

    "lint-staged": {
      "*.{js,jsx,ts,tsx}": [
        "pnpm lint",
        "pnpm format"
      ]
    }
  3. Initialize husky:

    pnpm husky install
  4. Add a prepare script to package.json to ensure husky is installed on npm install:

    "scripts": {
      "prepare": "husky install"
    }
  5. Create a pre-commit hook:

    pnpm husky add .husky/pre-commit "pnpm lint-staged"
  6. Add documentation in CONTRIBUTING.md about the pre-commit hooks

Benefits

  • Ensures all committed code meets the project's style guidelines
  • Prevents formatting inconsistencies
  • Catches linting errors before they're committed
  • Reduces the need for style-related code review comments

Additional Notes

  • We should consider only running lint/format on staged files to improve performance
  • We may want to make the hooks skippable with a flag for emergency situations
@bhouston
Copy link
Member Author

bhouston commented Mar 4, 2025

This is implemented.

@bhouston bhouston closed this as completed Mar 4, 2025
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

No branches or pull requests

1 participant