webstorm can fix it. Like standalone import of NgIf, if you dont have it in the template, it gets removed. Answer from drdrero on reddit.com
npm
npmjs.com › package › eslint-plugin-unused-imports
eslint-plugin-unused-imports - npm
1 month ago - It works by splitting up the no-unused-vars rule depending on it being an import statement in the AST and providing an autofix rule to remove the nodes if they are imports. This plugin composes the rule no-unused-vars of either the typescript ...
» npm install eslint-plugin-unused-imports
Published Feb 09, 2026
Version 4.4.1
Author Mikkel Holmer Pedersen
GitHub
github.com › sweepline › eslint-plugin-unused-imports › blob › master › docs › rules › no-unused-imports.md
eslint-plugin-unused-imports/docs/rules/no-unused-imports.md at master · sweepline/eslint-plugin-unused-imports
Package to separate no-unused-vars and no-unused-imports for eslint as well as providing an autofixer for the latter. - sweepline/eslint-plugin-unused-imports
Author sweepline
Reddit
reddit.com › r/angular2 › how to automatically remove unused angular imports?
r/Angular2 on Reddit: How To Automatically Remove Unused Angular Imports?
December 8, 2024 -
Angular 19 warns about unused imports. Is there a way to remove unused imports specific to Angular templates using ESLint? Note that I’m not referring to TypeScript imports but Angular-specific imports.
Top answer 1 of 13
12
webstorm can fix it. Like standalone import of NgIf, if you dont have it in the template, it gets removed.
2 of 13
6
Asked the same question last week https://www.reddit.com/r/Angular2/s/vwcl1zszxu Didn't get any good answers. Only a bunch of people misunderstanding the question.
Top answer 1 of 7
97
Using unused-imports plugin and unused-imports/no-unused-imports-ts rule, eslint --fix will remove the imports.
Here is an example repo which --fix removes the unused imports.
https://github.com/moshfeu/eslint-ts-unused-imports
Setup
yarn add -D eslint-plugin-unused-imports
// eslint.config.js
import tseslint from "typescript-eslint";
import unusedImports from "eslint-plugin-unused-imports";
export default tseslint.config(
{
plugins: {
"unused-imports": unusedImports,
},
rules: {
"unused-imports/no-unused-imports": "warn",
},
}
);
Old answer
eslint has a built-in fix option.
eslint ... --fix
If rules contains no-unused-vars, eslint will "fix" the unused import by removing them (along with other auto fixes).
2 of 7
71
You can also use shortcuts in VSCode, if it needs to be done quickly and without extra effort:
- Option + Shift + O for Mac
- Alt + Shift + O for Windows
Simon Dosda
simondosda.github.io › posts › 2021-05-10-eslint-imports.html
Automatically Remove Unused Imports From Your JS Projects | Simon Dosda
July 6, 2021 - To automatically remove unused imports, we will need to add the eslint-plugin-unused-imports plugin.
npm
npmjs.com › package › eslint-plugin-unused-vars-and-imports
eslint-plugin-unused-vars-and-imports - npm
remove unused vars and imports for typescript. Latest version: 1.0.7, last published: 3 years ago. Start using eslint-plugin-unused-vars-and-imports in your project by running `npm i eslint-plugin-unused-vars-and-imports`. There are 2 other projects in the npm registry using eslint-plugin-unused-vars-and-imports.
» npm install eslint-plugin-unused-vars-and-imports
Published Apr 26, 2023
Version 1.0.7
GitHub
github.com › eslint › eslint › discussions › 18494
Add optional feature to remove unused imports · eslint/eslint · Discussion #18494
Hi, im the maintainer of eslint-plugin-unused-imports. I have started switching projects over to biome because they have a nice optional fixer for removing unused imports. They dont guarantee that ...
Author eslint
npm Trends
npmtrends.com › eslint-plugin-import-vs-eslint-plugin-simple-import-sort-vs-eslint-plugin-unused-imports
eslint-plugin-import vs eslint-plugin-simple-import-sort vs eslint-plugin-unused-imports | npm trends
Comparing trends for eslint-plugin-import 2.32.0 which has 31,810,749 weekly downloads and 5,867 GitHub stars vs. eslint-plugin-simple-import-sort 12.1.1 which has 3,317,349 weekly downloads and 2,402 GitHub stars vs. eslint-plugin-unused-imports 4.3.0 which has 5,069,522 weekly downloads and 606 GitHub stars.
UNPKG
app.unpkg.com › eslint-plugin-unused-imports@4.3.0
eslint-plugin-unused-imports
Report and remove unused es6 modules · github.com/sweepline/eslint-plugin-unused-imports
npms
npms.io › search
npms
npms was built to empower the javascript community by providing a better and open sourced search for node modules.
GitHub
github.com › import-js › eslint-plugin-import › blob › main › docs › rules › no-unused-modules.md
eslint-plugin-import/docs/rules/no-unused-modules.md at main · import-js/eslint-plugin-import
ignoreExports: an array with files/paths for which unused exports will not be reported (e.g module entry points in a published package) const class MyClass { /*...*/ } function makeClass() { return new MyClass(...arguments) } ... import { e } from 'file-a' import { f } from 'file-b' import * as fileC from 'file-c' export { default, i0 } from 'file-d' // both will be reported export const j = 99 // will be reported
Author import-js
npm
npmjs.com › package › @antfu › eslint-plugin-unused-imports
@antfu/eslint-plugin-unused-imports - npm
Report and remove unused es6 modules. Latest version: 4.0.0, last published: 2 years ago. Start using @antfu/eslint-plugin-unused-imports in your project by running `npm i @antfu/eslint-plugin-unused-imports`. There are no other projects in the npm registry using @antfu/eslint-plugin-unused-imports.
» npm install @antfu/eslint-plugin-unused-imports
Published Jul 17, 2024
Version 4.0.0
Author Mikkel Holmer Pedersen
Npm
npm.io › package › eslint-plugin-unused-imports
Eslint-plugin-unused-imports NPM | npm.io
It works by splitting up the no-unused-vars rule depending on it being an import statement in the AST and providing an autofix rule to remove the nodes if they are imports. This plugin composes the rule no-unused-vars of either the typescript or js plugin so be aware that the other plugins ...