-
Notifications
You must be signed in to change notification settings - Fork 236
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: create require-hook
rule
#929
Conversation
175f0a4
to
bbb173c
Compare
I'm wondering if this rule should have a
For the above you could argue that But I wouldn't be surprised if some folks found it too noisy, due to having builder functions that are returning static values? 🤔 |
require-hook
rule
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.
I like it!
🎉 This PR is included in version 24.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [25.0.0-next.6](v25.0.0-next.5...v25.0.0-next.6) (2021-10-10) ### Bug Fixes * **lowercase-name:** consider skip and only prefixes for ignores ([#923](#923)) ([8716c24](8716c24)) * **prefer-to-be:** don't consider RegExp literals as `toBe`-able ([#922](#922)) ([99b6d42](99b6d42)) ### Features * create `require-hook` rule ([#929](#929)) ([6204b31](6204b31)) * deprecate `prefer-to-be-null` rule ([4db9161](4db9161)) * deprecate `prefer-to-be-undefined` rule ([fa08f09](fa08f09)) * **valid-expect-in-promise:** re-implement rule ([#916](#916)) ([7a49c58](7a49c58))
🎉 This PR is included in version 25.0.0-next.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
tbh this was a bit of a no-brainer to have as a rule - the more I think about it and check my existing tests, the more I think "yeah there's no reason that can't/shouldn't be wrapped in a before hook" 😅
The docs should explain the important stuff - namely, that this rule flags pretty much all common "action" statements like re-assignments and function calls that are not within a hook.
I have excluded function calls on the
jest
global, likejest.mock
but suspect some of those should actually also always be within a hook function?I also think we should probably make this a recommended rule, but understand if you don't want to delay the new major any further.
Closes #752