I have an Expo React Native app that has a ton of unused imports in components.
I have Prettier setup for code formatting, is it possible to configure Prettier to also remove any unused imports across the project?
I can't see anything in the docs and I don't know if there is a way to add extra eslint plugins to Prettier.
I don't think this is supported by default.
But you can use this prettier-plugin https://www.npmjs.com/package/prettier-plugin-organize-imports
For a basic install of the library run:
npm install --save-dev prettier-plugin-organize-imports
Then add "prettier-plugin-organize-imports"
to the .prettierrc
config file for prettier in the "plugins"
list. For example:
{
"plugins": ["prettier-plugin-organize-imports"],
...
}