Setup no-unused imports
1 October 2023 (Updated 1 October 2023)
On this page
Install plugin
Ensure ESLint is installed and configured first, and then run:
npm install eslint-plugin-unused-imports --save-dev
Add plugin to plugins
section of your ESLint config file:
{
"plugins": ["unused-imports"]
}
Merge the following rules
with any existing rules
:
{
"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": "^_" }
]
}
}
Links
Tagged:
JavaScript tooling
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment