-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(eslint-plugin): [use-unknown-in-catch-callback-variable] flag second argument of .then
#9059
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-plugin): [use-unknown-in-catch-callback-variable] flag second argument of .then
#9059
Conversation
Thanks for the PR, @abrahamguo! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 4173f58. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 2 targetsSent with 💌 from NxCloud. |
👋 @abrahamguo did you mean to un-draft this? |
Not it's not finished yet, I'll try to finish it up in the next few days! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9059 +/- ##
==========================================
- Coverage 87.93% 87.92% -0.01%
==========================================
Files 403 403
Lines 13795 13784 -11
Branches 4022 4017 -5
==========================================
- Hits 12130 12119 -11
Misses 1358 1358
Partials 307 307
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Work done:
Ready for 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.
Logic is correct, and I agree with all the test cases. Left a comment on some style requests, but otherwise in great shape!
packages/eslint-plugin/src/rules/use-unknown-in-catch-callback-variable.ts
Show resolved
Hide resolved
packages/eslint-plugin/src/rules/use-unknown-in-catch-callback-variable.ts
Show resolved
Hide resolved
return; | ||
} | ||
|
||
const promiseMethodInfo = [ |
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.
make a type for this array - the trouble with inferring it is that one can omit method
or append
, or add extraneous properties, and the type checker won't complain.
maybe like so?
type PromiseMethodInfo = { reportMessageData: { method: string, append: string }, argIndexToCheck: string }
const firstArgument = node.arguments[0]; | ||
const staticMemberAccessKey = getStaticMemberAccessKey( | ||
callee, | ||
context.sourceCode.getScope(callee), |
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.
scope
was always missing, meaning that const mk = 'catch'; promise[mk]
was never being detected properly all along (playground)
method: string; | ||
append: string; | ||
argIndexToCheck: number; | ||
}[] |
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.
make a type for this array - the trouble with inferring it is that one can omit method or append, or add extraneous properties, and the type checker won't complain.
satisfies
is the only way to get the type checker to complain about extraneous properties — any type annotation or type parameter anywhere else and the type checker will still be OK with extraneous properties 👍
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 going through this! Glad to see this changeset progress 🙂
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.
🚀
75a09a8
into
typescript-eslint:main
PR Checklist
.then
#9056Overview