-
-
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
Don't respect config setting if in a node_module #994
base: main
Are you sure you want to change the base?
Conversation
Only respect the config (and configIndex) settings if not in a node_module
, packageDir | ||
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 module
test to fail - it was the creation of thepackage.json
in 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.json
insome-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. 😴