`no-restricted-imports` should support `importNames` on `patterns` exclusions
See original GitHub issueWhat rule do you want to change?
no-restricted-imports
Does this change cause the rule to produce more or fewer warnings?
Neither, it makes configuration more powerful
How will the change be implemented? (New option, new default behavior, etc.)?
New options to the rule schema
Please provide some example code that this change will affect:
import { Foo, Bar } from '../../my/relative-module'
import { Foo } from '../../../my/relative-module'
What does the rule currently do for this code?
It’s not currently possible to ban importing only a named import from a pattern
ban. Nor is it possible to include a message for those bans.
What will the rule do after it’s changed?
Could be configured as follows:
'no-restricted-imports: [
'error',
{
patterns: [ '**/my/relative-module'],
importNames: ['Foo'], // currently not supported for patterns
message: 'Don't import Foo from my/relative-module. Instead import from @repo/foo', // currently not supported for patterns
}
]
Are you willing to submit a pull request to implement this change?
Potentially, but I’d like some guidance and my time is limited due to having young kids.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:18 (11 by maintainers)
Top GitHub Comments
I took a stab at this over the weekend - will throw up a PR for feedback later today!
So, the above config will result in the following behaviour:
It makes sense to me as well. I am also 👍🏻 on this. I can submit a PR for this if accepted.