eslint-import-resolver-jest

3.0.2Β β€’Β PublicΒ β€’Β Published

eslint-import-resolver-jest

"I like my testutils where I can see 'em" πŸ•΅πŸ½β€β™€οΈ

If you're using jest and you have installed custom name mappings in your config via the moduleNameMapper config and you're using the wonderful eslint-plugin-import you might get yelled at by eslint:

grafik

(I oftentimes create an alias for the helpers I use for testing)

Let's fix this!

yarn add eslint-import-resolver-jest -D

or

npm i eslint-import-resolver-jest -D

If you are using the package.json config option from jest everything should _just work_β„’.

If you are using a separate config file for jest using the --config option you have to point this plugin to it, too (in your .eslintrc):

"settings": {
  "import/resolver": {
    "jest": {
      "jestConfigFile": "./jest.conf.json"
    }
  }
}

That's it!

If you want to ensure that this resolver only applies to your test files, you can use ESLint's overrides configuration option:

"overrides": [
  {
    "files": ["**/__tests__/**/*.js"],
    "settings": {
      "import/resolver": {
        "jest": {
          "jestConfigFile": "./jest.conf.json"
        }
      }
    }
  }
]

Note

It will only resolve the modules in your test files that you specified via testRegex or testMatch in your jest config.

Contributing

Create issues in this repo or get active yourself:

yarn test # npm test works, too

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.0.2127,690latest

Version History

VersionDownloads (Last 7 Days)Published
3.0.2127,690
3.0.129
3.0.01,276
2.1.2190
2.1.1331
2.1.01
2.0.11
2.0.01
1.1.01
1.0.12
1.0.011

Package Sidebar

Install

npm i eslint-import-resolver-jest

Weekly Downloads

129,533

Version

3.0.2

License

MIT

Unpacked Size

19.4 kB

Total Files

7

Last publish

Collaborators

  • jakubcolony
  • kronovet
  • rdig
  • chmanie
  • area