-
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
feat(type-checking): Add type-checking pre-commit hooks #32261
feat(type-checking): Add type-checking pre-commit hooks #32261
Conversation
Added the script as a pre-commit hook to ensure type-checking before commits.
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 |
---|---|---|
Blocking File System Operations ▹ view | ✅ | |
Incorrect Log Levels for stdout/stderr ▹ view | ✅ | |
Missing Error Context In Catch Block ▹ view | ✅ |
Files scanned
File Path | Reviewed |
---|---|
scripts/check-type.js | ✅ |
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
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.
… add error context - Updated log levels for stdout and stderr to reflect appropriate severity. - Refactored fs operations to use asynchronous method. - Enhanced error handling by adding context information.
@mistercrunch don't we already have some sort of type checking? Adding you since you did a lot of work to clean up our pre-commits |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #32261 +/- ##
===========================================
+ 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. |
@sadpandajoe yes we do in CI, but this add the checks to Wondering if it would make sense to only do it on superset-frontend/**/js-and-ts-files to keep pre-commit.yml a bit simpler. @alveifbklsiu259 is it all super fast? |
- Removed type-checking-websocket hook - Removed type-checking-embedded-sdk hook - Removed type-checking-cypress hook
…n CI pipeline Disable it as it requires npm ci, plus type-check is handled by other job.
/korbit-review |
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 TSConfig Existence Check ▹ view | ✅ | |
Missing Dependency Check ▹ view | ✅ | |
Incomplete Process Output Handling ▹ view | ✅ |
Files scanned
File Path | Reviewed |
---|---|
scripts/check-type.js | ✅ |
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
- Add check for module installation and provide clear error message if missing - Ensure both stdout and stderr are logged if they contain content - Add check for existence of tsconfig.json and provide clear error message if missing
/korbit-review |
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 |
---|---|---|
Command Injection Vulnerability in TypeScript Compiler Command ▹ view | ||
Inefficient Array Concatenation ▹ view | ✅ | |
Sequential Directory Traversal ▹ view | ✅ | |
Missing Directory Read Error Handling ▹ view | ✅ |
Files scanned
File Path | Reviewed |
---|---|
scripts/check-type.js | ✅ |
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
- getFilesRecursively: use `promise.all`, handle error. - getPackage: handle error.
/korbit-review |
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 |
---|---|---|
Incorrect Directory Exclusion Logic ▹ view | ✅ |
Suppressed issues based on your team's Korbit activity
This issue | Is similar to | Because |
---|---|---|
Command string is constructed using direct string interpolation with unsanitized user inputs (argsStr and declarationFilesStr), which could lead to command injection. |
Command Injection Vulnerability in TypeScript Compiler Command |
Ignored |
When you react to issues (for example, an upvote or downvote) or you fix them, Korbit will tune future reviews based on these signals.
Files scanned
File Path | Reviewed |
---|---|
scripts/check-type.js | ✅ |
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
/korbit-review |
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 |
---|---|---|
Unbounded concurrent directory traversal ▹ view | ||
Directory exclusion logic false positives ▹ view | ✅ |
Files scanned
File Path | Reviewed |
---|---|
scripts/check-type.js | ✅ |
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
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.
Thanks for doing this! This will certainly save extra CI cycles by catching type errors at commit time.
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.
Looks safe from a repo secrets perspective. Thanks for the hard work here, and looking forward to the performance bump!
feat(type-checking): Add type-checking pre-commit hooks
SUMMARY
This PR introduces some pre-commit hooks to check TypeScript files using
tscw-config
. This enhancement aims to streamline the development process by running type checks only on changed files.NOTES
superset-frontend
,superset-websocket
...) use their owntsconfig.json
and may require different declaration files,multiple type-checking hooks are used. (edit: after discussion, only one hook (type-check-frontend
) is used, if future requirement changes, one can always reference commits).checkJs
is not enabled by default. To enable type-checking for JS/JSX files, either include//@ts-check
at the top of each JS/JSX file or enable it in the package'stsconfig.json
.superset-frontend
,superset-websocket
... will include all files ending with.d.ts
in their respective directories (recursively). However, if one needs to include third-party declaration files, one can either import them directly in the files that need them or declare them in thetype
field of the package'stsconfig.json
. For exampleimport "@testing-library/jest-dom"
tsconfig.json
from the current package (superset-frontend/tsconfig.json
forsuperset-frontend
), remove theinclude
filed, and include all the files passed to this hook (and some declaration files) in thefiles
field. This means that ANY files passed to the hook will be type-cheked even if they are not included in the originaltsconfig.json
'sinclude
field. For example, at the time of writing,superset-frontend/tsconfig.json
does not include files from./*/storybook/**/*
, but if one modifiessuperset-frontend/packages/superset-ui-demo/storybook/stories/superset-ui-color/RenderPalettes.tsx
, this file will still be type-checked. IMHO type-checking the files even though they will not be compiled to javascript is not a bad idea, but if one really wants to disable this behavior, one can:// @ts-nocheck
.exclude: ^(superset-frontend/cypress-base/|superset-frontend/.*/storybook/)
inpre-commit-config.yaml
.DISCLOSURE
I am the author of
tscw-config
. I genuinely believe that this library offers an effective solution to the issue discussed in Issue #27379.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION