Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a linting role for detecting duplicated imports? #1754

Closed
jon9090 opened this issue Mar 30, 2024 · 4 comments · Fixed by #1779
Closed

Is there a linting role for detecting duplicated imports? #1754

jon9090 opened this issue Mar 30, 2024 · 4 comments · Fixed by #1779
Labels
package: eslint-plugin Angular-specific TypeScript rules PRs Welcome If a high-quality PR is created for this it will be accepted

Comments

@jon9090
Copy link

jon9090 commented Mar 30, 2024

for example:

@Compoennt({
   imports: [CommonModule, SomeOtherModule, CommonModule.....]
})
@jon9090 jon9090 added package: eslint-plugin Angular-specific TypeScript rules triage This issue needs to be looked at and categorized by a maintainer labels Mar 30, 2024
@abaran30
Copy link
Contributor

abaran30 commented Apr 2, 2024

There currently is not. Should one be created, perhaps it should also check declarations, exports, providers, etc.

I did not see any prior proposals in the issues. @JamesHenry has this idea been discussed before?

@JamesHenry
Copy link
Member

I don't believe so, I think it would make sense to add

@JamesHenry JamesHenry added PRs Welcome If a high-quality PR is created for this it will be accepted and removed triage This issue needs to be looked at and categorized by a maintainer labels Apr 14, 2024
@abaran30
Copy link
Contributor

I created a draft PR #1779, which currently handles the simplest case of a single duplicate in NgModule imports. I left TODO comments with questions around how we might want to configure the rule to handle different cases (maybe we want multiple rules).

Feel free to refer to and/or contribute to the PR. I'll contribute more when I can.

@air2
Copy link

air2 commented Apr 22, 2024

Is it also possible to detect if the import is used in the HTML of the component? It currently pretty hard to find out if every import is actually used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: eslint-plugin Angular-specific TypeScript rules PRs Welcome If a high-quality PR is created for this it will be accepted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants