Skip to content

chore(lint): add pre-commit hooks to enforce eslint rules #798

@hemantch01

Description

@hemantch01

Setup husky and lint-staged for pre-commit linting 🛍️

Add pre-commit hooks that automatically run ESLint on staged files before allowing a commit to be created.

Use Case

Currently, developers can commit code that violates project linting rules. To improve code quality and prevent CI build failures, we should enforce linting locally at the commit level. When a developer runs git commit, a pre-commit hook should trigger, identifying only the .ts and .tsx files that have been staged, and automatically running eslint --fix on them. If ESLint detects unfixable errors, the commit should be aborted so the developer can address them.

Context

This change aims to automate code formatting and catch simple syntax or styling errors locally before code is pushed to remote branches or reviewed in pull requests. By automatically fixing simple issues and blocking commits on critical errors, we reduce manual review overhead, keep the codebase style consistent, and prevent "fixing lint errors" commits later in the process.

Detailed Description

The proposal adds two major dependencies: husky (to manage git hooks in the repository) and lint-staged (to efficiently run linters only on files changed in the current commit).

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