Skip to content
New issue

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

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

Already on GitHub? # to your account

Integrating Husky Pre-Commit Hook with ESLint and Prettier #36

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Naman-B-Parlecha
Copy link

Description

This PR introduces a Husky pre-commit hook to automatically run ESLint and Prettier before committing code.
It ensures that only properly linted and formatted code is committed, preventing errors and enforcing consistency across the codebase.

Why is this needed?

  • Prevents committing code with linting errors.
  • Ensures consistent formatting, reducing unnecessary PR changes.
  • Saves time in code reviews and CI by catching issues early.

Changes Introduced

  • Added Husky pre-commit hook.
  • Integrated ESLint for linting staged files.
  • Configured Prettier for automatic formatting.
  • Ensured the hook runs only on staged files before commit.

steps to replicate and test the pr

# Navigate to the frontend directory
cd frontend

# Install dependencies
npm install

# Make changes to any file and stage them
git add <file-name>

# Try committing the changes
git commit -m "Test commit"

Type

  • New Feature
  • Bug Fix
  • Refactoring
  • Documentation

Commiting with no Error

Screenshot from 2025-02-13 00-31-33

Commiting with Errors

Screenshot from 2025-02-13 00-31-28

@Naman-B-Parlecha
Copy link
Author

@keshav-nischal can u review this!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant