-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
no-unresolved error when linting using eslint-import-resolver-webpack #1050
Comments
Are your files using .jsx extension? |
I got same issue, then I fond I put some env-sensitive code in the webpack.config.js that make it exported an empty config object. so the eslint couldn't get any info about alias. |
@JoeHetfield Can you give an example here, please? there are many people looking for this solution on the web |
@nicolascbarbosa At first, I exported my config like this : module.exports = (env) => {
switch (env) {
case 'production':
return merge(commonConfig, productionConfig);
case 'staging':
return merge(commonConfig, stagingConfig);
case 'development':
return merge(commonConfig, developmentConfig);
default:
return {}; // <- this is the problem
}
}; since eslint won't provide any "env" to the webpack.config.js, so the exported config is {},the “alias” key was not exists, so eslint don't have any knowledge of your custom path resolve plan. so, I changed my code to : module.exports = (env) => {
switch (env) {
case 'production':
return merge(commonConfig, productionConfig);
case 'staging':
return merge(commonConfig, stagingConfig);
default:
return merge(commonConfig, developmentConfig);
}
}; then, everything gose fine. |
@JoeHetfield sensational, thank you very much. I had resolved with https://github.com/martinpetlus/eslint-import-resolver-configurable |
So I feel really silly but in my case I was pointing to the correct webpack.config I just didn't account for es6 modules in |
@nicolascbarbosa not work, could u please list the config of detail bro |
I installed eslint-plugin-import/resolver-webpack so I could correctly resolve webpack aliases using eslint.
Before setting up
eslint-plugin-import
andeslint-import-resolver-webpack
I would just get this error due to eslint not being able to resolve an alias I set up in webpack.Unable to resolve path to module 'src/picture.jpg
Now I get a ton of errors am I doing something wrong? I've googled and looked through issues for the last couple hours but can't figure out what I'm missing.
package.json:
.eslintrc:
webpack.config.js:
The text was updated successfully, but these errors were encountered: