Rule proposal: warn against import declarations with no value specifiers and only inline type specifiers #6382
Closed
6 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
enhancement: new plugin rule
New rule request for eslint-plugin
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Description
Spinning off of import-js/eslint-plugin-import#2676
The new
verbatimModuleSyntax
flag will not elide an import declaration if the only specifiers are inline type specifiers:This is obviously a problem - code that looks like it is pure type-only code can have runtime side-effects!
After some discussion, we've come to a decision that there needs to exist a rule that warns against this code. The behaviour doesn't really fit into any existing lint rule, even as an option. Additionaly as it's so hyper-targeted on TS behaviour, it doesn't make sense to add this rule to
eslint-plugin-import
.Thus we should add the rule to our plugin.
At the same time I think we should add documentation about how to use the lint rules together. Copying from the other issue:
import/consistent-type-specifier-style
together withimport/no-duplicates
with the{"prefer-inline": true}
config.import/no-duplicates
with the{"prefer-inline": true}
config in conjunction with the new rule from (1)import/consistent-type-specifier-style
together withimport/no-duplicates
with the{"prefer-inline": false}
config.Fail Cases
Pass Cases
Additional Info
#6380
The text was updated successfully, but these errors were encountered: