-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
fix(eslint-hook): ensure eslint hook receives arguments #32333
base: master
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.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
Category | Issue | Fix Detected |
---|---|---|
Missing error context for critical operations ▹ view | ✅ | |
Missing directory existence check ▹ view | ✅ |
Files scanned
File Path | Reviewed |
---|---|
scripts/eslint.sh | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Need a new review? Comment
/korbit-review
on this PR and I'll review your latest changes.Korbit Guide: Usage and Customization
Interacting with Korbit
- You can manually ask Korbit to review your PR using the
/korbit-review
command in a comment at the root of your PR.- You can ask Korbit to generate a new PR description using the
/korbit-generate-pr-description
command in any comment on your PR.- Too many Korbit comments? I can resolve all my comment threads if you use the
/korbit-resolve
command in any comment on your PR.- Chat with Korbit on issues we post by tagging @korbit-ai in your reply.
- Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.
Customizing Korbit
- Check out our docs on how you can make Korbit work best for you and your team.
- Customize Korbit for your organization through the Korbit Console.
Feedback and Support
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #32333 +/- ##
===========================================
+ Coverage 60.48% 83.45% +22.96%
===========================================
Files 1931 546 -1385
Lines 76236 39097 -37139
Branches 8568 0 -8568
===========================================
- Hits 46114 32629 -13485
+ Misses 28017 6468 -21549
+ Partials 2105 0 -2105
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Do we need the extra script file here, or does simply removing the Also, regarding the type checking from the prior PR, I noticed that running Appreciating the help here, by the way! :) |
Oh weird, I'm pretty sure the $@ trick work on my machine, is this an OS-specific issue (like it doesn't work as expected on Windows/Linux)? In my experience eslint runs only on the files touched by the current commit (?) |
I created a separate file because
I'm not sure if this is a OS-specific issue, I'm running on WSL2 with Ubuntu 22.04.5. After a thorough test, I found that when
- repo: local
hooks:
- id: eslint
name: eslint
entry: bash -c 'echo "$@"; exit 1'
language: system
pass_filenames: true
files: \.(js|jsx|ts|tsx)$
When more files are added to the index,
But if we use
#!/usr/bin/env bash
echo "$@"; exit 1
- repo: local
hooks:
- id: eslint
name: eslint
entry: ./scripts/eslint.sh
language: script
pass_filenames: true
files: \.(js|jsx|ts|tsx)$ All touched files are included. |
The resource-intensive issue of running Simply put, by default each pre-commit hook runs in parallel with a different set of files. This means that when you run As for the execution time compared to A more detailed explanation can be found in 32323. |
fix(eslint-hook): ensure eslint hook receives arguments
SUMMARY
Issue
For some reason, the
$@
variable is not correctly received by the eslint hook inpre-commit-config.yaml
.Solution
Moving the code to a separate file solves this issue.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
pre-commit-config.yaml
superset-frontend/src/components/Alert/index.tsx
is modified, but the hook receives nothing.This causes the eslint hook to always pass because
no files are being passed to it(The actual issue is that$@
does not output all modified files, see comment).Now, set
entry
back tobash -c 'cd superset-frontend && npm run eslint -- $(echo "$@" | sed "s|superset-frontend/||g")'
, and add this to the index:Running eslint correctly catches the error.
But running eslint hook does not.
Moving the code to a separate file does solve the issue, it correctly receives the variable
$@
.scripts/eslint.sh
pre-commit-config.yaml
ADDITIONAL INFORMATION