Skip to content
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

Jest modifies require.extensions #2

Closed
wrumsby opened this issue Oct 1, 2018 · 1 comment · Fixed by #6
Closed

Jest modifies require.extensions #2

wrumsby opened this issue Oct 1, 2018 · 1 comment · Fixed by #6

Comments

@wrumsby
Copy link

wrumsby commented Oct 1, 2018

I'm writing a shareable ESLint config that uses eslint-plugin-unicorn which uses this module.

Inspired by Test Your ESLint config I'm testing my config with Jest.

I was seeing failures around being able to load the eslint-plugin-unicorn rules and after looking at the code here and looking across tools I was using the problem I'm experiencing seems to be caused by jestjs/jest#281.

While the problem is "caused by" Jest it seems like a difficult issue for Jest to resolve and I wondered if a solution might be possible in import-modules, e.g.

var extensions = Object.assign({}, {
    // Jest will redefine require.extensions to be {}
    // so add back default implementation(s) if not available
    '.js': require('default-require-extensions/js')
  }, require.extensions);

for (const ext of Object.keys(extensions)) {
  ...

A change like the above would mean that I get the default js implementation back and rules for eslint-plugin-unicorn load.

This is pretty similar to #1, but continues to use require.extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants