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(rules): no-try-expect #331
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.
This is a great rule! 🙂
## Rule Details | ||
|
||
Expectations inside a `catch` block can be silently skipped. While Jest provides | ||
an `expect.assertions(number)` helper, it might be cumbersome to add this to |
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.
Wondering if the rule should check for these and pass if the test uses it, for the cases where one might actually need complicated logic in a catch
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.
in that case I think an eslint-disable-next-line
comments is better rather than try to make the rule too clever.
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.
Not if you eslint-disable
without adding expect.assertions
- the lint error could suggest adding expect.assertions
to get rid of the warning and save someone from mindlessly disabling it
Co-Authored-By: Simen Bekkhus <sbekkhus91@gmail.com>
🎉 This PR is included in version 22.13.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This rule prevents the use of
expect
insidecatch
blocks.The following patterns are warnings:
The following patterns are not warnings:
Related #295