[no-restricted-imports] No way to forbid only regular imports from a package & allow type imports #2403
Closed
3 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
enhancement: new base rule extension
New base rule extension required to handle a TS specific case
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Repro
Expected Result
I expected to be able to apply different rules to type imports.
Actual Result
There's no way of allowing only type imports from a specific package. An ESLint core rule can't differentiate between them as pure JS doesn't have the
import type
concept.Additional Info
The issue is that a core ESLint rule cannot distinguish between type imports & regular imports since there is no type import concept in pure JavaScript. To fix this, we need a new
typescript-eslint
rule that doesn't exist yet (from what I could see).If such a rule existed, I'd also expect it to be mentioned in https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/ROADMAP.md as the replacement for TSLint's
import-blacklist
instead of the current core ESLintno-restricted-imports
rule.Versions
@typescript-eslint/eslint-plugin
3.9.1
@typescript-eslint/parser
3.9.1
TypeScript
3.9.7
ESLint
7.7.0
node
14.8.0
The text was updated successfully, but these errors were encountered: