Created
August 5, 2022 19:22
-
-
Save cocodrino/f6298e5e593c7615f74687a5823ac1d6 to your computer and use it in GitHub Desktop.
remove unused imports automatically from typescript files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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