eslint-plugin-import: webpack resolver: config not used if config file requires transpilation
Hi everyone,
I get a lot of no-unresolved errors when using this with webpack 2.3.3.
Plugins:
"eslint-import-resolver-webpack": "^0.8.1",
"eslint-plugin-import": "^2.2.0",
Webpack resolve config:
resolve: {
modules: [
path.join(__dirname, 'src'),
path.join(__dirname, 'styles'),
'node_modules'
]
},,
Eslintrc:
"settings": {
"import/resolver": {
"webpack": {
"config": "webpack.config-base.js"
}
}
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 36
- Comments: 20 (7 by maintainers)
The problem right now is that the plugin is failing silently to parse the config. Solutions exist but it’s hard to find the cause in the first place : the only symptom is that eslint will not resolve imports.
The fix would be to document it properly or add a console warning when eslint is loading (don’t know if possible)
“+1s” aren’t helpful; please avoid cluttering up issues and instead, react with an emoji on the original post. I’ll now delete the +1s.
Some sort of warning or error seems reasonable; I’d be in favor of a hard failure when a config exists but fails to parse.
You can also transpile webpack config from es6 to es5 on the fly with babel-register
my package.json
.eslintrc.json
build/webpack.eslint.conf.js
Same as @zhenyulin, my webpack config was not used at all. I replaced all my import/export with require/module.exports in my webpack.config.js and it’s now working
Mine doesn’t work earlier either, and I found out the issue to be I used ES6 syntax
import
andexport
in the webpack config file, which isn’t loaded by .eslintrc correctly, thoughbabel-eslint
has been applied as the parser. I resolved the issue by falling back to userequire
andmodule.exports
.HTH.
@bradennapier the only workaround is to disable these rules in
eslint
config until the issue will be resolved.