Don't respect config setting if in a node_module#994
Don't respect config setting if in a node_module#994Billy- wants to merge 8 commits intoimport-js:mainfrom
Conversation
Only respect the config (and configIndex) settings if not in a node_module
|
|
||
| log('Config path from settings:', configPath) | ||
| // Only respect webpackConfig settings if not in a node_module | ||
| if (!~file.indexOf('/node_modules/')) { |
There was a problem hiding this comment.
please never use !~, that's far too clever for its own good - explicitly compare to a number instead, since that's what indexOf returns.
There was a problem hiding this comment.
that is a pretty neat combo operator, but I agree with @ljharb 😁
| , packageDir | ||
|
|
||
| log('Config path from settings:', configPath) | ||
| // Only respect webpackConfig settings if not in a node_module |
There was a problem hiding this comment.
i'm not sure why this is something we'd want to do. webpack config applies to every single JS file, potentially, including everything inside a node_modules directory.
There was a problem hiding this comment.
That’s true, for rules, etc., but I wonder if it applies to aliases or other resolve configs, too? I would be surpsied since I can’t think why anyone would want to affect the module resolution within node_modules... and if webpack did do that then surely there would be tonnes of problems as a result..?
I’d also argue that since this is an eslint plugin, the user is never interested in node_modules, thus this change does not have an adverse affect?
There was a problem hiding this comment.
It applies to everything. Webpack is used all the time to modify the resolution of things within node_modules - Airbnb does it at times.
This eslint plugin checks across files - so it's interested in every JS file that's required/imported, full stop.
There was a problem hiding this comment.
Okay, so is the only solution to resolve the path relative to the user’s project? I can’t see any obvious way to do that..
Fixes #666.
This has made the
resolve.moduleDirectories finds a node moduletest to fail - it was the creation of thepackage.jsonin the fake node_module that prompted it. I have spent quite some time looking at this test alone already, and it appears that resolveSync is not finding it, and I cannot for the life of me work out why this happens...All I can say is that I have verified that it's not my code that caused it (
checkout master, createpackage.jsoninsome-module, then run tests), just the creation of the package.json (which, of course, is expected of an npm module..)It is 3:20AM now for me, think I'm going to call it a night. 😴