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
no-restricted-imports
: disable comments do not work for individual named imports
#12282
Comments
I can reproduce this bug at our ESLint Demo. I think the rule should only report the restricted items. For the example from @OliverJAsh , the rule should report |
Just so that I understand this rule more clearly: If we didn't have the eslint-disable-line comment, should "pickBy" still be allowed to be imported even as "zip" is disallowed, or should "import { zip, pickBy, } from 'lodash';" be disallowed entirely because of the presence of "zip" in the import statement? |
The former |
It seems that reporting zip identifier node instead of the whole import statement would fix this issue. Would be probably nice to have a different error message in this case. This change also means that the rule can now report multiple errors for the same import statement. |
I'm gonna check it and send a PR till New Year. |
#12711) * Process importNames * Update test cases * Fix rebase issue * Update importNames logic * Remove useless funcs, update tests * Fix naming, fix everything imported w/o importNames * Fix typo, fix specifier clause, fix rebase issue * Process importNames with the same name * Clean code in receiving specifier data, remove debug * Fix type def, add empty name check, replace concat with push
…#12282) (eslint#12711) * Process importNames * Update test cases * Fix rebase issue * Update importNames logic * Remove useless funcs, update tests * Fix naming, fix everything imported w/o importNames * Fix typo, fix specifier clause, fix rebase issue * Process importNames with the same name * Clean code in receiving specifier data, remove debug * Fix type def, add empty name check, replace concat with push
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
What did you expect to happen?
No error
What actually happened? Please include the actual, raw output from ESLint.
Error
To workaround this you must disable the rule for the whole import statement. However this is not ideal because this could accidentally silence errors that we want to hear about, for other named imports:
Are you willing to submit a pull request to fix this bug?
The text was updated successfully, but these errors were encountered: