-
Notifications
You must be signed in to change notification settings - Fork 242
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
New rule request: no-hooks #72
Labels
Comments
Yeah, this sounds like a reasonable rule! PR most welcome 🙂 |
I think @thejameskyle will like it 😅 |
I will look to contribute a PR for this today. 🌴 |
macklinu
added a commit
to macklinu/eslint-plugin-jest
that referenced
this issue
Feb 12, 2018
macklinu
added a commit
to macklinu/eslint-plugin-jest
that referenced
this issue
Feb 12, 2018
SimenB
pushed a commit
that referenced
this issue
Feb 12, 2018
This was referenced Feb 12, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
eslint-plugin-mocha has a rule called
no-hooks
that I think could be a good addition to this ESLint plugin. I think themocha/no-hooks
docs as well as this tweet help explain how using nesteddescribe()
andbeforeEach()
hook functions can result in harder to follow code / shared state between tests.I think when combined with
jest/consistent-test-it
, you could enforce tests that look more like:instead of looking like this:
I think there are times when using setup and teardown hooks are necessary, but I find that they can often be avoided. I could see this rule providing an option that would whitelist allowed hook function names, or the user could disable with
// eslint-disable-next-line jest/no-hooks
.Thoughts on this rule? Would you accept a PR for this feature?
The text was updated successfully, but these errors were encountered: