# eslint-plugin-unused-imports

> Report and remove unused es6 modules

Latest version **4.4.1** (published 2026-02-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install eslint-plugin-unused-imports
pnpm add eslint-plugin-unused-imports
yarn add eslint-plugin-unused-imports
bun add eslint-plugin-unused-imports
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.4.1 |
| Published | 2026-02-09 |
| First published | 2019-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 623 |
| Author | Mikkel Holmer Pedersen |
| Maintainers | antfu, sweepline |
| Keywords | eslint, eslintplugin, eslint-plugin, import, unused, modules, autofix |

## Links

- npm: https://www.npmjs.com/package/eslint-plugin-unused-imports
- Repository: https://github.com/sweepline/eslint-plugin-unused-imports
- Issues: https://github.com/sweepline/eslint-plugin-unused-imports/issues
- npm.io page: https://npm.io/package/eslint-plugin-unused-imports

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 4.4.1 (latest) — 2026-02-09
- 4.3.0 — 2025-10-19
- 4.2.0 — 2025-08-18
- 4.1.4 — 2024-09-13
- 4.1.3 — 2024-08-10
- 4.1.2 — 2024-08-08
- 4.1.1 — 2024-08-08
- 4.1.0 — 2024-08-08
- 4.0.1 — 2024-07-22
- 4.0.0 — 2024-05-24
- 3.2.0 — 2024-04-30
- 3.1.0 — 2024-02-13
- 3.0.0 — 2023-07-11
- 2.0.0 — 2021-11-10
- 1.1.5 — 2021-09-24
- … 15 more at https://npm.io/package/eslint-plugin-unused-imports/versions

## README

# eslint-plugin-unused-imports

Find and remove unused es6 module imports. 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 needs to be installed and reporting correctly for this to do so.

## _Versions_

-   Version 4.1.x is for eslint 9 with @typescript-eslint/eslint-plugin 5 - 8
-   Version 4.0.x is for eslint 9 with @typescript-eslint/eslint-plugin 8
-   Version 3.x.x is for eslint 8 with @typescript-eslint/eslint-plugin 6 - 7
-   Version 2.x.x is for eslint 8 with @typescript-eslint/eslint-plugin 5
-   Version 1.x.x is for eslint 6 and 7.

## Typescript

If running typescript with [@typescript-eslint](https://github.com/typescript-eslint/typescript-eslint) make sure to use both `@typescript-eslint/eslint-plugin` and `@typescript-eslint/parser`.

## React

If writing react code you need to install `eslint-plugin-react` and enable the two rules `react/jsx-uses-react` and `react/jsx-uses-vars`. Otherwise all imports for components will be reported unused.

## Installation

You'll first need to install [ESLint](http://eslint.org) (and [@typescript-eslint](https://github.com/typescript-eslint/typescript-eslint) if using typescript):

```bash
npm i eslint --save-dev
```

Next, install `eslint-plugin-unused-imports`:

```bash
npm install eslint-plugin-unused-imports --save-dev
```

**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-unused-imports` globally.

## Usage

Add `unused-imports` to the plugins section of your `eslint.config.js` configuration file.

```js
import unusedImports from "eslint-plugin-unused-imports";

export default [{
    plugins: {
        "unused-imports": unusedImports,
    },
    rules: {
        "no-unused-vars": "off", // or "@typescript-eslint/no-unused-vars": "off",
        "unused-imports/no-unused-imports": "error",
        "unused-imports/no-unused-vars": [
            "warn",
            {
                "vars": "all",
                "varsIgnorePattern": "^_",
                "args": "after-used",
                "argsIgnorePattern": "^_",
            },
        ]
    }
}];
```

## Supported Rules

-   `no-unused-imports`
-   `no-unused-vars`

---
_Source: https://npm.io/package/eslint-plugin-unused-imports · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
