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-import-resolver-webpack swallows errors in webpack.config.js #536

Closed
leoselig opened this issue Aug 30, 2016 · 5 comments
Closed

Comments

@leoselig
Copy link

I was seeing the following error for each of my checked files:
1:0 error Resolve error: Unexpected token import

I was trying to understand why (correct plugin configuration, babel and webpack setup correctly) for about 1h until I realized, that I forgot to start eslint with babel-node and my webpack.config.js was written in babel ES6+ code. Obviosly, it was starting with
import path from 'path';
which seems to have produced said errors.

I think instead eslint-import-resolver-webpack should error when trying to read the webpack configuration, similar to as it does, when settings.import/resolver.webpack cannot be resolved.

@benmosher
Copy link
Member

Ah, yeah, that makes sense. Could still re-emit the original message, but would be ideal to prefix with Error encountered when loading resolver config: or some such.

@leoselig
Copy link
Author

That would decrease the setup pain even more! 👍
If I find some time I'll try to put together a PR, but no guarantees 😅

@leoselig
Copy link
Author

Btw, it's working fine now and it's an absolutely awesome plugin! Thanks for your work :)

sompylasar added a commit to sompylasar/eslint-plugin-import that referenced this issue Oct 2, 2016
Resolve errors are most likely caused by invalid configuration, and the reason is easier to determine with the full details rather than just `err.message`.

See import-js#536

With this change, it reports something like:
```
import/no-unresolved: Resolve error: SyntaxError: Unexpected token import
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at module.exports (/__censored__/webpack/configFactory.js:216:3)
    at configProdClient (/__censored__/webpack/configProdClient.js:5:36)
    at Object.<anonymous> (/__censored__/webpack/configForEslintImportResolver.js:1:126)
```
@sompylasar
Copy link
Contributor

PR: #599

I've hit the same error, but I use Atom which starts eslint by itself, so instead of "starting eslint with babel-node", I've required 'babel-register' from the file I've configured eslint-import-resolver-webpack with, the same way I do where the ES6+ webpack configs are used to build the app.

sompylasar added a commit to sompylasar/eslint-plugin-import that referenced this issue Oct 29, 2018
Resolve errors are most likely caused by invalid configuration,
and the reason is easier to determine with the full details
rather than just `err.message`.

See import-js#536

With this change, it reports something like:
```
import/no-unresolved: Resolve error: SyntaxError: Unexpected token import
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at module.exports (/__censored__/webpack/configFactory.js:216:3)
    at configProdClient (/__censored__/webpack/configProdClient.js:5:36)
    at Object.<anonymous> (/__censored__/webpack/configForEslintImportResolver.js:1:126)
```
@soryy708
Copy link
Contributor

More generally: #819

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

No branches or pull requests

5 participants