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

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

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

Conversation

Naman-B-Parlecha
Copy link
Contributor

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
Contributor Author

@keshav-nischal can u review this!

@Naman-B-Parlecha
Copy link
Contributor Author

@keshav-nischal refactored as asked

@keshav-nischal
Copy link
Contributor

is this tested(the change is more than eslint, something related to dependency was also change)? for frontend
please mension the test scenarios over here

@Naman-B-Parlecha
Copy link
Contributor Author

Naman-B-Parlecha commented Feb 27, 2025

@keshav-nischal Yep this is tested, I have added the screenshot in the description of this pr.

There was aws-amplify which was not being used anywhere so I removed it, apart from that I have added the recommended dependencies for prettier husky and eslints.

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

Successfully merging this pull request may close these issues.

2 participants