17

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.

Jamesking56
  • 3,683
  • 5
  • 30
  • 61
  • Does this answer your question? [Is there a way to remove unused imports and declarations from Angular 2+?](https://stackoverflow.com/questions/46722701/is-there-a-way-to-remove-unused-imports-and-declarations-from-angular-2) – abolfazl shamsollahi Jun 26 '22 at 11:37
  • @abolfazlshamsollahi No it doesn't because I don't use VSCode – Jamesking56 Jun 26 '22 at 12:17

2 Answers2

13

You can use VS Code .vscode/settings.json to organize imports.

"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
  "source.organizeImports": true
}
Googlian
  • 6,077
  • 3
  • 38
  • 44
12

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

QuickSort
  • 494
  • 5
  • 14