4.1.4 • Published 2 months ago

eslint-plugin-unused-imports v4.1.4

Weekly downloads
125,742
License
MIT
Repository
github
Last release
2 months ago

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 v8 to v5
  • 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 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 (and @typescript-eslint if using typescript):

npm i eslint --save-dev

Next, install eslint-plugin-unused-imports:

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.

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
@anjun-brasil/eslint-configwiseweb-eslint-config@codewithhong/eslint-config@kaivanwong/eslint-config-base@violetx/eslint-config@denverzh/eslint-config@denverzh/eslint-config-base@wildberries/boilerplate-eslint-configeslint-config-vicasaconfig@ephesus/ephesus-core@boostedp/tslinteslint-config-sunrocketzeslint-config-sunrocketz-nodeeslint-config-jklasd2001eslint-config-redaxmedia@salient-sys/cloud-dtos@typhoon41/eslint-vue-config@jarisinc/eslint-config-jaris@mafalda/eslint-config@yomarsanchez/eslint-config-seek@thequack/shared@etchteam/eslint@trpl/eslint-config-commoneslint-config-tyler-zeyeslint-tyler-zey@angusmiguel/es-configseslint-config-iridiumeslint-config-angusmigueleslint-config-paygron@everything-registry/sub-chunk-1615eslint-config-wishketeslint-config-slay-react@ifshizuku/eslint-config-basic@inelo/eslint-config-angular@ventsislavnikolov/eslint-configreact-phone-input-beatify@finale-lua/eslint-config@daopk/eslint-config-javascriptflare-dispatch@codelzn/confighcanvaser@rednightgames/eslint-config-rednight@trpl/eslint-config-javascript@starbuck3992/eslint-prettier-configeslint-config-ethang-testeslint-config-bayathyai-eslintstake-shottcfw-eslint-configtalljack-eslint-configsysgears-linter-configstemporibusdolorweb-ui-depssedullamsequiliberovitaeeligendivisyn_scriptsvicente015-eslint-config@hyperspaceinc/style-guide@hyperspaceinc/style-guide-core@iz7n/eslint-config@zzejing/eslint-config-basic@amatias/eslint-config-basic@future.ai/eslint-config-nestjs@kuru93/eslint-config-reacttunstall-ui-library@jterrazz/eslint-config-common@adpro/gkd_inspect@jakubserwin/eslint-config-vue@dylanjs/eslint-config-basic@handsomewolf/eslint-config@hcywka/eslint-config-node@hcywka/eslint-config-react@merlinalexhjp/eslint-config@brucesong/eslint-config-astro@brucesong/eslint-config-basic@brucesong/eslint-config-docusaurus@brucesong/eslint-config-next@brucesong/eslint-config-react@brucesong/eslint-config-react-native@brucesong/eslint-config-ts@brucesong/eslint-config-vue@raipiot-infra/eslint-config-astro@raipiot-infra/eslint-config-next@raipiot-infra/eslint-config-react@raipiot-infra/eslint-config-react-native@raipiot-infra/eslint-config-ts@raipiot-infra/eslint-config-vue@bayathy/eslint-config@tutods/eslint-configmicro-eslint-confheets-corejohnsonav-eslint-configmohami-litjulian_hdlpkni-scssgkd-mrlcgkd-sub-5201314gkd-subscriptionnazna
4.1.4

2 months ago

4.1.3

3 months ago

4.1.0

3 months ago

4.1.2

3 months ago

4.1.1

3 months ago

4.0.1

4 months ago

4.0.0

6 months ago

3.2.0

6 months ago

3.1.0

9 months ago

3.0.0

1 year ago

2.0.0

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago