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
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%
🌐
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
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 ...
🌐
Socket
socket.dev › npm › package › eslint-plugin-unused-imports
eslint-plugin-unused-imports - npm Package Security Analysis...
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 ...
🌐
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
Find elsewhere
🌐
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
    
🌐
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
🌐
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 › eslint-plugin-known-imports
eslint-plugin-known-imports - npm
Latest version: 0.0.14, last published: 6 years ago. Start using eslint-plugin-known-imports in your project by running `npm i eslint-plugin-known-imports`. There are no other projects in the npm registry using ...
      » npm install eslint-plugin-known-imports
    
Published   Aug 05, 2019
Version   0.0.14
Author   Julian Rosse
🌐
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 ...