Enhancement: [no-unused-vars] add a default-off option to autofix remove unused imports #11223
Open
4 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
enhancement: plugin rule option
New rule option for an existing eslint-plugin rule
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Link to the rule's documentation
https://typescript-eslint.io/rules/no-unused-vars/
Description
Currently all
no-unused-vars
errors are not fixable. This is for good reasons, eg:With that being said there is one subset of unused variables which are generally safe to autofix -- imported names. These are generally safe to fix because:
There's evidence that the community wants this -- for example
eslint-plugin-unused-imports
exists and is pretty widely used (they have ~8.4% of our weekly downloads). This plugin introduces two rules -- both are just monkey-patched extension rules on top of ourno-unused-vars
implementation where one rule only reports on variables and the other only reports on imports and provides a fixer.My proposal is the following:
enableAutofixRemoval: { imports: boolean }
with defaultenableAutofixRemoval: { imports: false }
(i.e. disable the autofixer by default).enableAutofixRemoval.imports === true
Additional Info
Namespace:
autofixes to:
Default:
autofixes to:
Named:
autofixes to:
The text was updated successfully, but these errors were encountered: