I'm using babel-plugin-rewire to inject mocks for some tests (mostly fetch API calls). I'm getting:
error __RewireAPI__ not found in '../metadata' import/named
And I'd like to be able to ignore just that error so I catch other unnamed constants in my test files.
Any way to do this or would I need to write some custom configuration logic? I couldn't find anything in the docs or other issues.
Are you running ESLint on the code that was Babelified? Sounds like you're doing that, and it does not make much sense to me as you should run ESLint on the original untranspiled files.
No, the test files that I'm linting are the original ES6 files; they only run through babel immediately before the test runner. babel-plugin-rewire adds the functionality of rewire through a babel plugin, which adds the __RewireAPI__ to each module to allow monkey-patching (don't try this on prod!).
This seems like an appropriate use for eslint-disable-line import/named. I'm hesitant to build a lot of blacklisting into the rules.
Ah, got it, you actually do have __RewireAPI__ in your code. I thought that was injected by Babel, and that's why it didn't make sense to me.
I agree with @benmosher on the use of eslint-disable here.
Closing this as wontfix with stock ESLint behavior as recommended course.
so in every single test file I need to add eslint-disable-line instead of being able to setup a single rule in my eslint config?
I also had this issue
for __RewireAPI__ was injected by babel-plugin-rewire, so it needn't any blacklisting
just find it out and make eslint pass