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

ESLint error: Cannot read property 'externals' of undefined #1219

Closed
idudinov opened this issue Oct 22, 2018 · 1 comment · Fixed by #1220
Closed

ESLint error: Cannot read property 'externals' of undefined #1219

idudinov opened this issue Oct 22, 2018 · 1 comment · Fixed by #1220

Comments

@idudinov
Copy link
Contributor

idudinov commented Oct 22, 2018

I've come across an issue with ESLint when using eslint-import-resolver-webpack and webpack config is an array of functions.
ESLint starts to fail almost on all rules, saying:
[eslint] Resolve error: Cannot read property 'externals' of undefined
I've managed to found the part of sources which responsible for that. The cause is that it first checks whether config is a function (and then executes it) and after that check whether it's an array.

https://github.com/benmosher/eslint-plugin-import/blob/b4a2f11fcacc6b2f048da4b29cfc896e682f17d1/resolvers/webpack/index.js#L88-L109
When it tries to find proper config with resolve field in the array, it finds nothing, because all elements are functions.
And, in my case, it turns that config is undefined which leads to the error I see.

My proposition is to check if config is an array, try to convert every element from function to object.

In case I understood everything correctly and didn't miss anything, I can make a PR for that, just going to add some tests as Contribution Guide claims

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

Successfully merging a pull request may close this issue.

1 participant