-
Notifications
You must be signed in to change notification settings - Fork 33
feat: Automate code formatting with Husky pre-commit hooks #129
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
.husky/_/post-applypatch
Outdated
| @@ -0,0 +1,2 @@ | |||
| #!/usr/bin/env sh | |||
There was a problem hiding this comment.
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
|
|
||
| # 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/ |
There was a problem hiding this comment.
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
|
Thanks @its-me-abhishek so much for the detailed feedback. I've updated the pull request and addressed all the points you raised: |
| "test": "jest", | ||
| "coverage": "jest --coverage" | ||
| "coverage": "jest --coverage", | ||
| "prepare": "cd .. && husky frontend/.husky" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this required?
There was a problem hiding this comment.
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?
|
Are you still working on this @mishraa-G ? |
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
npx prettier --write .(for formatting)gofmt -w .(for Go backend)npm test(for JS/TS testing)