-1

In Angular 19 we now get warnings about unused imports. (unused classes in the imports array).

The blog post says "auto remove"

Additionally, the Angular language service will highlight such unused imports and provide the functionality to auto remove them directly in your IDE or text editor.

At this stage I could never manually go through to remove every reported warning.

So how do we auto remove them?

3
  • 1
    They tell you in exactly what you've quoted: "the Angular Language Service". It's an extension for VS Code: Angular Language Service. I don't personally use VS Code, but my guess is you can hover over what it highlights and it will provide you with what you need to auto-remove.
    – maiorano84
    Commented yesterday
  • Yeah but one at a time dude. Commented 6 hours ago
  • Well "dude", if the tool that was outlined in the blog post isn't doing what you want it to do, then what are you expecting from us here? Have you considered reaching out to the tool's developers instead?
    – maiorano84
    Commented 4 hours ago

1 Answer 1

0

You can use Eslint and if you are working on older version then TsLint. In that you specify following rule in eslint config file.

no-unused-vars: "error"

You can decide if you want to set it as error or warning. Post that the IDE like VS Code itself will show you the unused imports and even variables. You can runng lint --fix which will remove all such imports. Find the complete documentation here: no-unused-vars

1
  • Thank you, but we already have warnings and errors for this. I'd like to remove the unused component class names. Not one-by-one but all at one time. Commented 6 hours ago

Not the answer you're looking for? Browse other questions tagged or ask your own question.