`no-restricted-imports`: disable comments do not work for individual named imports
See original GitHub issueTell us about your environment
- ESLint Version: 5.16.0
- Node Version: 10.16.3
- npm Version: 6.11.3
What parser (default, Babel-ESLint, etc.) are you using?
Please show your full configuration:
Configuration
{
rules: {
'no-restricted-imports': [
'error',
{
name: 'lodash',
importNames: ['zip'],
},
],
},
};
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
import {
zip, // eslint-disable-line no-restricted-imports
pickBy,
} from 'lodash';
eslint
What did you expect to happen? No error
What actually happened? Please include the actual, raw output from ESLint. Error
'lodash' import is restricted from being used.
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:
// eslint-disable-next-line no-restricted-imports
import {
zip,
pickBy,
} from 'lodash';
Are you willing to submit a pull request to fix this bug?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
no-restricted-imports - ESLint - Pluggable JavaScript Linter
This rule allows you to specify imports that you don't want to use in your application. It applies to static imports only, not...
Read more >Disallow specific imports (no-restricted-imports) - ESLint
This rule allows you to specify imports that you don't want to use in your application. It applies to static imports only, not...
Read more >eslint no-restricted-imports - prevent an import from from path ...
What I'm trying to do is restrict imports from parent index files - as this is causing issues with cyclical dependencies (I am...
Read more >Importing into the United States A Guide for Commercial ...
Imported goods are not legally entered until after the shipment has arrived ... Customs brokers are private individuals or firms licensed by CBP...
Read more >no-restricted-imports | typescript-eslint
How to Use ·.exports = { · "rules": { · // Note: you must disable the base rule as it can report incorrect...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m gonna check it and send a PR till New Year.
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.