-
Notifications
You must be signed in to change notification settings - Fork 24
[onhold] chore: setup frontend pre commit hook #1161
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
Draft
khaledosman
wants to merge
8
commits into
main
Choose a base branch
from
frontend-pre-commit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5b2f883
setup husky & lint-staged
khaledosman 2574e89
unset hooksPath before running pre-commit install
khaledosman 771664b
remove --all-files
khaledosman 308a473
reinstall husky after uv pre-commit
khaledosman 6fea93f
Merge branch 'main' into frontend-pre-commit
khaledosman eafa81a
Merge branch 'main' into frontend-pre-commit
khaledosman 4ce0d50
remove unnecessary uv pre-commit install
khaledosman b274e83
Merge branch 'main' into frontend-pre-commit
khaledosman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/bin/sh | ||
| . "$(dirname "$0")/_/husky.sh" | ||
|
|
||
| # FRONTEND_DIR="$(dirname "$0")/../lumigator/frontend" | ||
|
|
||
| # Run backend linting with pre-commit | ||
| echo "Running backend linting..." | ||
| uv run pre-commit run | ||
|
|
||
| # Run frontend linting with lint-staged | ||
| echo "Running frontend lint-staged..." | ||
| cd lumigator/frontend | ||
| npx lint-staged | ||
|
|
||
| echo "✅ Pre-commit checks passed!" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
when running
npm installit will now run thepreparescript inlumigator/lumigator/frontend/package.json
Line 18 in 2574e89
husky sets the
core.hooksPathtofrontend/.huskyduring its installation which breaks whatever checksuv pre-commitdoes when runningmake local-up(core.hooksPathdefines the folder/path where github looks at to see where the hooks are defined)I was getting this error when running
make local-upuv run pre-commit install [ERROR] Cowardly refusing to install hooks with core.hooksPath set. hint: git config --unset-all core.hooksPath make: *** [local-up] Error 1so this is a workaround to unset
core.hooksPathbefore runninguv run pre-commit installto make things work then run the npm prepare script to install husky (which setsgit config core.hooksPathtofrontend/.husky) and make the frontend pre-commit hook work alongside the backend one, where we run theuv run pre-commit runfromfrontend/.husky/pre-commit(so technically I think we can even get rid of runninguv run pre-commit installin the make file since its already part of the pre-commit hook in.husky)This feels hacky, but I'm not sure if there's a better way to do it. cc @macaab26, essentially all the frontend needs to do is run
npx lint-stagedfrom the frontend folder, so to avoid all this setting/unsettinghooksPathstuff, we could technically get rid of husky and rely on the normal.git/hooks/pre-commithowever this file is automatically generated/overwritten by ruff so that wouldn't work either, perhaps we could create a custom pre-commit hook file and manually append to the generated pre-commit hooks or something along these lines which would also kinda hacky 🤷, or we could just rely on husky to run both backend & frontend linting which is what it currently doesThere 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.
removed
uv run pre-commit installin 4ce0d50 now that.husky/pre-commitis responsible for running linting for both backend and frontend where it would runuv run pre-commit runandnpx lint-staged