`require-hook` rule checks non-test files
See original GitHub issueHello, first of all: thanks for your work!
I’m currently facing an issue upgrading to v25.0.1
due to the require-hook
rule.
This rule is applied outside of test files.
Here’s an example with .tsx
and ts
files:
Versions:
eslint
:7.32.0
eslint-plugin-jest
:25.0.1
node
:14.17.0
Thank’s for your help!
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
eslint doesn't recognize rule violations in test files and built-in ...
Now a warning should not appear. Next, is to set up a smoke test. All I saw in your example was a file...
Read more >eslint-plugin-jest - npm
Running rules only on test-related files. The rules provided by this plugin assume that the files they are checking are test-related. This means ......
Read more >The compiler for next generation JavaScript - Babel
Babel built-ins. CLIRequire hook. Build systems ... Test frameworks. AVAJasmineJestKarmaLabMocha. Utilities. ConnectNodemon. Language APIs. C# / .
Read more >Testing in ES6 with Mocha and Babel 6 - James K Nelson
Naturally, your tests import the lib code which you're actually publishing, not the original src files. And while this may go without saying, ......
Read more >eslint-plugin-jest | Yarn - Package Manager
Rules ; prefer-to-have-length, Suggest using toHaveLength(), ; prefer-todo, Suggest using test.todo ; require-hook, Require setup and teardown code to be within ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@thibaultdelor unfortunately not as config Jest’s config loading is async while ESLint’s config loading is sync. See https://github.com/jest-community/eslint-plugin-jest/pull/754#issuecomment-780396777 for details
@G-Rath we should probably add an example to the docs as this rule is quite aggressive and seemingly the only one we have that causes issues in this way (at least in recommended config) - this is the third issue about it in as many days.
fwiw, this rule isn’t in the recommended config, but 💯 agree on having this in our docs.
tbh I actually thought we did mention it in the readme but we don’t so I think that should definitely change - I think our general configuration example should be using
overrides
with Jest’s default file matcher as the glob (or as close to as possible).Then for
require-hook
I think we should be good to just have an extra warning sayingthis rule is very noisy, make sure you're using overrides to only apply it to your test files as shown [in the readme](link)