Rule for unused imports
steverep opened this issue · comments
The no-missing-imports
rule is very helpful, but it would be nice to have a no-unused-imports
rule to remove imports of components that are not used anywhere in the module's templates. This can easily happen when a previous version of a template might have used the element, but was subsequently removed and the author forgot to removed the import. Since components are most often side effect only imports, I don't know any other way to catch these errors other than manually.
Perhaps oversimplifying, I'm thinking the rule could, for each side effect only import:
- Examine for custom elements in the same manner as
no-missing-imports
, except only 1 module deep - Fail the rule if all elements defined are unused. This would assume the module is not being imported for other side effects, but since I bet that is an edge case (and probably bad practice anyway), the user could simply
@ts-ignore
those false positives or only use the rule for warnings.