A Prettier plugin that organizes imports in Astro files by removing unused imports, coalescing duplicate imports, and sorting them using the TypeScript language service API's organizeImports feature. The current stable version is 0.4.12. It is actively maintained with frequent releases. Differentiators: specifically for Astro files, provides explicit compatibility with prettier-plugin-astro and prettier-plugin-tailwindcss through per-plugin workarounds, and supports configurable modes (All, SortAndCombine, RemoveUnused).
npm install prettier-plugin-astro-organize-importsVerified import paths — ran on the pinned version, not inferred.
Configuration to enable the plugin for Astro files, with recommended order and mode set to All.
List prettier-plugin-astro-organize-imports as the final entry in the plugins array in .prettierrc.
Ensure you use TypeScript >=6 or apply a workaround; see release notes.
Remove those comments from files you intend to format.
Use astroOrganizeImportsMode instead if available.
Install prettier-plugin-astro: npm install -D prettier-plugin-astro
Install the plugin: npm install -D prettier-plugin-astro-organize-imports. Ensure spelling matches in .prettierrc.
Update Prettier to v3 or later: npm install -D prettier@^3