-
-
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
add external modules setting (pick by package name) #1524
base: main
Are you sure you want to change the base?
Conversation
3 similar comments
f3f9eca
to
4b06349
Compare
@@ -341,6 +341,24 @@ Contribution of more such shared configs for other platforms are welcome! | |||
|
|||
An array of folders. Resolved modules only from those folders will be considered as "external". By default - `["node_modules"]`. Makes sense if you have configured your path or webpack to handle your internal paths differently and want to considered modules from some folders, for example `bower_components` or `jspm_modules`, as "external". | |||
|
|||
#### `import/external-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.
https://github.com/benmosher/eslint-plugin-import#importexternal-module-folders already exists - how is this different?
const folders = (settings && settings['import/external-module-folders']) || ['node_modules'] | ||
|
||
// extract the part before the first / (redux-saga/effects => redux-saga) | ||
const packageName = name.match(/([^/]+)/)[0] | ||
|
||
return !path || folders.some(folder => -1 < path.indexOf(join(folder, packageName))) | ||
return !path | ||
|| folders.some(folder => -1 < path.indexOf(join(folder, packageName))) |
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.
no need for a yoda condition, and "includes" exists:
|| folders.some(folder => -1 < path.indexOf(join(folder, packageName))) | |
|| folders.some(folder => path.includes(join(folder, packageName))) |
fixes #1510