Gathering detailed insights and metrics for prettier-plugin-astro-organize-imports
Gathering detailed insights and metrics for prettier-plugin-astro-organize-imports
Gathering detailed insights and metrics for prettier-plugin-astro-organize-imports
Gathering detailed insights and metrics for prettier-plugin-astro-organize-imports
A Prettier plugin for formatting imports in Astro files
npm install prettier-plugin-astro-organize-imports
Typescript
Module System
Node Version
NPM Version
TypeScript (89.85%)
JavaScript (10.15%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
46 Stars
323 Commits
1 Forks
1 Watchers
4 Branches
2 Contributors
Updated on Jul 10, 2025
Latest Version
0.4.11
Package Id
prettier-plugin-astro-organize-imports@0.4.11
Unpacked Size
3.34 MB
Size
0.96 MB
File Count
4
NPM Version
10.8.2
Node Version
20.18.0
Published on
Nov 04, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
3
A plugin that makes Prettier organize your imports (i. e. sorts, combines and removes unused ones) in Astro files using the organizeImports
feature of the TypeScript language service API.
1npm install -D prettier prettier-plugin-astro-organize-imports
1// .prettierrc 2{ 3 "plugins": ["prettier-plugin-astro-organize-imports"], 4 "overrides": [ 5 { 6 "files": "*.astro", 7 "options": { 8 "parser": "astro" 9 } 10 } 11 ] 12}
After following the steps in the 'Installation' section, the plugin will function when you run the Prettier formatting command.
Files containing the substring // organize-imports-ignore
or // tslint:disable:ordered-imports
will be skipped and won't be processed by this plugin.
The plugin provides an option named astroOrganizeImportsMode
that lets you choose the mode of formatting. The available options are:
All
: This is the default option. It removes unused imports, coalesces imports from the same module, and sorts imports.SortAndCombine
: This option coalesces imports from the same module and sorts imports.RemoveUnused
: This option removes the unused imports.You can specify the mode in your Prettier configuration file as follows:
1// .prettierrc 2{ 3 // .. 4 "astroOrganizeImportsMode": "All" // or "SortAndCombine" or "RemoveUnused" 5}
Remember to replace "All" with "SortAndCombine" or "RemoveUnused" depending on your preferences.
This plugin uses Prettier APIs that can only be used by one plugin at a time, making it incompatible with other Prettier plugins implemented the same way. To solve this we've added explicit per-plugin workarounds that enable compatibility with the following Prettier plugins:
prettier-plugin-astro
prettier-plugin-tailwindcss
One limitation with this approach is that prettier-plugin-astro-organize-imports
must be loaded last. You can do this by listing each of your Prettier plugins in the plugins
array:
1// .prettierrc 2{ 3 // .. 4 "plugins": [ 5 "prettier-plugin-astro", 6 "prettier-plugin-tailwindcss", 7 "prettier-plugin-astro-organize-imports" // MUST come last 8 ], 9 "overrides": [ 10 { 11 "files": "*.astro", 12 "options": { 13 "parser": "astro" 14 } 15 } 16 ] 17}
This plugin is heavily inspired by following plugins:
And, for implementation reference, the following plugins:
No vulnerabilities found.
No security vulnerabilities found.