Skip to content

Conversation

@mishraa-G
Copy link

@mishraa-G mishraa-G commented Oct 25, 2025

Description

This pull request is a fix for issue #114.

The project's contribution guidelines ask developers to run npx prettier --write. manually before committing. To make this process automatic and foolproof, this PR introduces Husky and lint-staged to the frontend workflow.

I've added a new .husky directory with a pre-commit hook that will now automatically run Prettier on any staged files. This means that from now on, all frontend code will be perfectly formatted before it's even committed, ensuring a consistent style across the board.

This should make contributing a little smoother for everyone and save reviewers time checking for formatting issues.

I also ran Prettier once over the existing frontend codebase to get everything aligned from the start.

How to test it: You can pull down this branch, run npm install in the frontend folder (this will set up the new hooks), and then try committing a file with some messy formatting. It should get fixed automatically!

Let me know if you have any feedback. Thanks!

Checklist

  • Ran npx prettier --write . (for formatting)
  • Ran gofmt -w . (for Go backend)
  • Ran npm test (for JS/TS testing)
  • Added unit tests, if applicable
  • Verified all tests pass
  • Updated documentation, if needed

Copy link
Collaborator

@its-me-abhishek its-me-abhishek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix. Also if possible, maybe add go fmt to that husky script as well, so that both backend and frontend can be refactored automatically.

@@ -0,0 +1,2 @@
#!/usr/bin/env sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all files like this, inside ./husky and ./frontend/husky are all empty. Shall be removed if its safe to do so.

.gitignore Outdated
Comment on lines 4 to 37

# env
.env
.env.*.local
secrets.*
credentials*

# node / frontend
frontend/node_modules/
frontend/dist/
frontend/build/
frontend/coverage/

# backend data / DB
backend/data/
*.sqlite3
*.db
*.sql
*.dump

# keys/certs
*.pem
*.key
*.crt
*.p12
id_rsa*

# IDE / OS
.vscode/
.idea/
.DS_Store

# misc
*.logbackend/data/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these additions are unnecessary, shall be reverted

@mishraa-G
Copy link
Author

Thanks @its-me-abhishek so much for the detailed feedback. I've updated the pull request and addressed all the points you raised:
The pre-commit hook now handles both frontend and backend code. It will run gofmt on any staged Go files in addition to running Prettier on the frontend files.
I've removed the unnecessary .gitignore additions and cleaned up the empty/scaffolded Husky files as you suggested.
I've removed them to make sure the hook is compatible with future versions of Husky.

"test": "jest",
"coverage": "jest --coverage"
"coverage": "jest --coverage",
"prepare": "cd .. && husky frontend/.husky"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this required?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to test it: You can pull down this branch, run npm install in the frontend folder (this will set up the new hooks), and then try committing a file with some messy formatting. It should get fixed automatically!

do we need this if only npm i can setup husky though?

@its-me-abhishek
Copy link
Collaborator

Are you still working on this @mishraa-G ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants