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).

Answer from Mosh Feu on Stack Overflow
🌐
npm
npmjs.com › package › eslint-plugin-unused-imports
eslint-plugin-unused-imports - npm
February 9, 2026 - 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
GitHub - 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.
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 ...
Starred by 615 users
Forked by 27 users
Languages   TypeScript 98.2% | JavaScript 1.8% | TypeScript 98.2% | JavaScript 1.8%
Discussions

reactjs - How can I remove unused imports/declarations from the entire project of React Typescript? - Stack Overflow
I'm trying to remove unused imports and declarations as answered in this SO thread for Angular. I'm trying to achieve the goal using eslint-plugin-react, but not found any option to remove the unused More on stackoverflow.com
🌐 stackoverflow.com
How To Automatically Remove Unused Angular Imports?
webstorm can fix it. Like standalone import of NgIf, if you dont have it in the template, it gets removed. More on reddit.com
🌐 r/Angular2
31
8
December 8, 2024
What is an eslint rule that you could not do without?

eslint-disable

More on reddit.com
🌐 r/javascript
26
73
June 9, 2015
Bulk remove unused standalone imports
I’m not sure about VsCode, but the latest IntelliJ release (or maybe it’s the EAP), does this for you when you optimize a folder’s imports or when you optimize imports within the file itself. More on reddit.com
🌐 r/Angular2
41
3
December 8, 2024
🌐
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 - You can easily install it and generate its configuration file with npm. ... You can then check the errors and warnings from ESLint by running it in your project. ... To automatically remove unused imports, we will need to add the eslint-plugin-unused-imports plugin.
🌐
npm
npmjs.com › package › @antfu › eslint-plugin-unused-imports
@antfu/eslint-plugin-unused-imports - npm
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
🌐
GitHub
github.com › eslint › eslint › discussions › 18494
Add optional feature to remove unused imports · eslint/eslint · Discussion #18494
May 29, 2024 - 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
🌐
Snyk
security.snyk.io › snyk vulnerability database › npm
eslint-plugin-unused-imports vulnerabilities | Snyk
We found that eslint-plugin-unused-imports demonstrates a positive version release cadence with at least one new version released in the past 3 months. As a healthy sign for on-going project maintenance, we found that the GitHub repository had at least 1 pull request or issue interacted with by the community. ... The npm ...
🌐
npm
npmjs.com › package › eslint-plugin-unused-vars-and-imports
eslint-plugin-unused-vars-and-imports - npm
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
    
Find elsewhere
🌐
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
🌐
Socket
socket.dev › npm › package › eslint-plugin-unused-imports
eslint-plugin-unused-imports - npm Package Security Analysis...
September 18, 2019 - 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 ...
🌐
Bundlephobia
bundlephobia.com › package › eslint-plugin-unused-imports
eslint-plugin-unused-imports ❘ Bundlephobia
Find the size of javascript package eslint-plugin-unused-imports. Bundlephobia helps you find the performance impact of npm packages.
🌐
Deno
deno.com › npm › package › eslint-plugin-unused-imports
Use the eslint-plugin-unused-imports npm package in Deno
Deno supports npm. You can install eslint-plugin-unused-imports with $ deno install npm:eslint-plugin-unused-imports
🌐
ReversingLabs
secure.software › npm › packages › eslint-plugin-unused-imports › 3.0.0
eslint-plugin-unused-imports@3.0.0 - npm | ReversingLabs Spectra Assure Community
The npm package eslint-plugin-unused-imports was scanned for malware, software tampering, risky behaviors, exposed secrets and known vulnerabilities.
🌐
Tessl
tessl.io › registry › tessl › npm-eslint-plugin-unused-imports
4.2.0 • npm-eslint-plugin-unused-imports • tessl • Registry • Tessl
January 29, 2026 - ESLint plugin that identifies and automatically removes unused ES6 module imports
🌐
ESLint
eslint.org › docs › latest › rules › no-unused-vars
no-unused-vars - ESLint - Pluggable JavaScript Linter
In environments outside of CommonJS or ECMAScript modules, you may use var to create a global variable that may be used by other scripts. You can use the /* exported variableName */ comment block to indicate that this variable is being exported and therefore should not be considered unused.
🌐
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
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 ...