Biome
biomejs.dev › linter › rules › no-unused-imports
noUnusedImports | Biome
code-block.js:1:8 lint/correct... > 1 │ import A from ‘mod’; │ ^ 2 │ ℹ Unused imports might be the result of an incomplete refactoring. ℹ Unsafe fix: Remove the unused imports....
npm
npmjs.com › package › eslint-plugin-unused-imports
eslint-plugin-unused-imports - npm
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.
» npm install eslint-plugin-unused-imports
Published Feb 09, 2026
Version 4.4.1
Author Mikkel Holmer Pedersen
GitHub
github.com › import-js › eslint-plugin-import › issues › 1608
Definition for rule 'import/no-unused-modules' was not found · Issue #1608 · import-js/eslint-plugin-import
October 16, 2019 - using "eslint-plugin-import": "^2.13.0", Added this rule in my .eslintrc "import/no-unused-modules": [1, {"unusedExports": true}], I got this error on all files 1:1 warning Definition for rule 'import/no-unused-modules' was not found imp...
Author fr-irene
Astral
docs.astral.sh › ruff › rules › unused-import
unused-import (F401) | Ruff
This can result in both different and more import statements being marked as unused. ... then both statements are marked as unused under preview, whereas only the second is marked as unused under stable behavior. ... then a diagnostic will be emitted for the second line under preview, whereas no diagnostic is emitted under stable behavior.
GitHub
github.com › typescript-eslint › typescript-eslint › issues › 379
1:1 error Definition for rule '@typescript-eslint/no-unused-vars' was not found @typescript-eslint/no-unused-vars · Issue #379 · typescript-eslint/typescript-eslint
March 27, 2019 - I have the following eslintrc.json: { "parser": "@typescript-eslint/parser", "extends": [ "prettier", "plugin:prettier/recommended", "react-app" ], "rules": { "no-unused-vars": "off", "@typescript-eslint/no-unused-vars": "error" }, "pars...
Author jordyvandomselaar
Pylint
pylint.readthedocs.io › en › latest › user_guide › messages › warning › unused-import.html
unused-import / W0611 - Pylint 4.1.0-dev0 documentation
Used when an imported module or variable is not used · By default, this check is skipped for __init__.py files, as they often contain imports from submodules for the convenience of end users. While these imports are not used within __init__.py, they serve the purpose of providing intuitive ...
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.
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": "^_", }, ] } }];
Starred by 615 users
Forked by 27 users
Languages TypeScript 98.2% | JavaScript 1.8% | TypeScript 98.2% | JavaScript 1.8%
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
Symfony
cs.symfony.com › doc › rules › import › no_unused_imports.html
Rule no_unused_imports - PHP Coding Standards Fixer
Unused use statements must be removed.
GitHub
github.com › eslint › eslint › discussions › 18494
Add optional feature to remove unused imports · eslint/eslint · Discussion #18494
The reason i have ended up monkey patching is because I actually use the built-in no-unused-vars rule and then split it up into two rules. One rule that has an autofixer for removing said variable and one that is just the built-in rule. This is split up based on the AST type being "ImportSpecifier", "ImportDefaultSpecifier" or "ImportNamespaceSpecifier".
Author eslint
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
individual exports not being statically imported or requireed from other modules in the same project · dynamic imports are supported if argument is a literal string · In order for this plugin to work, at least one of the options missingExports ...
Author import-js
Palantir
palantir.github.io › tslint › rules › no-unused-variable
Rule: no-unused-variable
Disallows unused imports, variables, functions and private class members. Similar to tsc’s –noUnusedParameters and –noUnusedLocals options, but does not interrupt code compilation. In addition to avoiding compilation errors, this rule may still be useful if you wish to have tslint ...
GitHub
github.com › oxc-project › oxc › issues › 13706
Add no-unused-imports rule · Issue #13706 · oxc-project/oxc
May 28, 2025 - In contrast, a dedicated no-unused-imports rule would focus solely on imports that are never referenced in the code. Because unused imports are always unnecessary, they can be safely removed.
Author cjnoname
GitHub
github.com › pinterest › ktlint › issues › 3038
Do not run `no-unused-imports` rule by default · Issue #3038 · pinterest/ktlint
July 5, 2025 - The no-unused-imports rules tries to detect imports that are not used. Over the years, it has been proven difficult for KtLint to prevent false positive detections of unused imports.
Author paul-dingemans
Scalacenter
scalacenter.github.io › scalafix › docs › rules › RemoveUnused.html
RemoveUnused · Scalafix
$ scala3 -W ... -Wunused Enable or disable specific `unused` warnings Choices : - nowarn, - all, - imports : Warn if an import selector is not referenced., - privates : Warn if a private member is unused, - locals : Warn if a local definition is unused, - explicits : Warn if an explicit parameter is unused, - implicits : Warn if an implicit parameter is unused, - params : Enable -Wunused:explicits,implicits, - patvars : Warn if a variable bound in a pattern is unused, - linted : Enable -Wunused:imports,privates,locals,implicits, - strict-no-implicit-warn : Same as -Wunused:import, only for imports of explicit named members.
ESLint
eslint.org › docs › latest › rules › no-unused-vars
no-unused-vars - ESLint - Pluggable JavaScript Linter
You can use the /* exported variableName */ comment block to indicate that this variable is being exported and therefore should not be considered unused. Note that /* exported */ has no effect for any of the following: when languageOptions.sourceType is module (default) or commonjs · when languageOptions.parserOptions.ecmaFeatures.globalReturn is true · The line comment // exported variableName will not work as exported is not line-specific. ... This rule takes one argument which can be a string or an object.