Skip to content

Setup Husky and Linting Checks Before Commit #29

Description

@Benjtalkshow

Setup Husky and Linting Checks Before Commit

Description
Set up Husky to automatically run linting and formatting checks before a commit is made.
This ensures code consistency, prevents lint errors from being committed, and maintains a clean and standardized codebase.


Tasks

  • Install and configure Husky for Git hooks
  • Install lint-staged to run checks only on staged files
  • Ensure ESLint and Prettier configurations are in place
  • Create a pre-commit hook to run linting and formatting
  • Add scripts in package.json for:
    • "lint"
    • "format"
    • "prepare" (for Husky installation)
  • Verify that lint and format run automatically before commits

Acceptance Criteria

  • Pre-commit hook successfully prevents commits when linting fails
  • ESLint and Prettier run only on staged files (using lint-staged)
  • Developers can commit only clean, formatted code
  • Setup works across all packages in the monorepo (if applicable)

Example Configuration

package.json

{
  "scripts": {
    "prepare": "husky install",
    "lint": "eslint . --ext .ts,.tsx,.js",
    "format": "prettier --write ."
  },
  "lint-staged": {
    "*.{ts,tsx,js,jsx}": ["eslint --fix", "prettier --write"]
  }
}

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions