-
-
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
Webpack resolver looks for custom webpack config in packages with jsnext:main #666
Comments
Did you tried |
@k15a Prefixing the path with |
I'm using |
Can corroborate. Our workaround was to create a symlink with the default name that targets the desired custom config, e.g.,
|
I found a workaround for this problem by converting my ".eslintrc" into a ".eslintrc.js" and use path.resolve as follow:
|
@gwleclerc Tried your suggestion and didn't work for me |
Same issue here when using |
Perhaps this can be solved by mutating the configuration when the plugin first gets it, converting relative paths to absolute paths. Ideally, it would do the conversion using the absolute path of the configuration file. |
I tried putting the following line at https://github.com/benmosher/eslint-plugin-import/blob/master/resolvers/webpack/index.js#L65: if (configPath !== settings.config) settings.config = configPath however, while that fixes CLI usage, it doesn't fix it in the editor. The problem is that there are many invocations, each having to do fix-up on first invacation, and somehow in my editor the node_module is the first invocation. |
when a relative `configPath` is passed, it should be resolved relative to the source file, not the imported file.
I may have jumped the gun a bit with the PR above (variable names are confusing!)... So my next question becomes, why is eslint trying to resolve those files anyway when (by default) it should ignore any files in By logging out the // Just showing the last two logs before the error
{ file: 'my-project/src/store/modules/index.js',
source: 'react-router-redux' }
{ file: '/my-project/node_modules/react-router-redux/es/index.js',
source: './reducer' } |
eslint-plugin-import most definitely does not ignore files in node_modules, because it's trying to verify the exports that you're importing from there. Separately, webpack may alias some of those out, so the resolver needs to run on them. |
Ah, I see. So would a valid fix for this issue be to simply check if we're in a node_module, and if so, ignore the I think it's fair to say that when setting a configPath, you only want it to apply to your code, not any dependencies, right? |
Although I guess that would lead to inconsistent behaviour between absolute paths and relative, where absolute paths would always resolve a webpack config, relative ones would not in this case... If you agree with my previous comment, would you also agree that it should apply to all cases (that is, if we're in a dependency; ignore configPath)? |
If it helps I'm also seeing this issue - there's a simple repository here showing the error: https://github.com/cjpete/redux-saga-import-issue |
@Billy-
|
I've successfully narrowed down the problem (at least for export { foo } from './internal'; It seems that this plugin follows them, tries to resolve On the other hand 'manual' reexports are treated as safe: import { foo } from './internal';
export { foo } and it doesn't try to dive into I'd still advocate for the simplest solution - just resolve config path once to an absolute path and be done with it, WDYT @ljharb ? |
I’m not sure i know enough about it to decide - i prefer to avoid webpack aliasing, personally. It’s certainly worth a PR if tests can be made to pass. |
@Andarist I suppose yes it works, although as mentioned there is a caveat in that if the first file to be resolved is a node_module it doesn't work. I also think that mutating in this way is a bit of an antipattern..
|
per discussion in #995: need to enhance resolver spec to include the linting file in order to properly load webpack config relative to the linting file and not deep imports |
@gwleclerc your workaround works for me :) Had a |
With a
.eslintrc
likewhen I import
I get the error
When I remove the
jsnext:main
entry from thepackage.json
insidenode_modules/redux-saga
, the error goes away. So I guess the plugin is somehow trying to find a Webpack config insideredux-saga
to loadresolve
configuration for ES6 files? This might be fine, looking for my custom Webpack config does not make sense, though.The text was updated successfully, but these errors were encountered: