Skip to content

Instantly share code, notes, and snippets.

@cocodrino
Created August 5, 2022 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cocodrino/f6298e5e593c7615f74687a5823ac1d6 to your computer and use it in GitHub Desktop.
Save cocodrino/f6298e5e593c7615f74687a5823ac1d6 to your computer and use it in GitHub Desktop.
remove unused imports automatically from typescript files
1) install eslint-plugin-unused-imports
`yarn add -D eslint-plugin-unused-imports`
2) add "unused-imports" to your "plugins"section under .eslitrc.json file
```
"plugins": [
"react",
"@typescript-eslint",
"jest",
"unused-imports"
],
```
3) add the rule
` "unused-imports/no-unused-imports-ts": 2`
4) in package json add the --fix param
` "lint:scripts": "eslint --ext .ts,.tsx src --fix",`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment