Registry / testing / prettier-plugin-sort-imports-desc

prettier-plugin-sort-imports-desc

JSON →
library1.0.0jsnpmunverified

A Prettier plugin that automatically sorts import statements by line length or alphabetically. V1.7.0 active, released for Prettier 2.x+ (Node.js 12+). Differentiators: supports sorting by import line length (unique feature), flexible import type ordering (NPM packages vs local values vs local types), newline stripping between groups, and ignore comments. Competitors like @trivago/prettier-plugin-sort-imports focus on alphabetical/group-based sorting and do not offer length-based sorting.

npm install prettier-plugin-sort-imports-desc
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-SO
P
prettier-plugin-sort-imports-desc
testingjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

none (plugin autoloads)
// Add to .prettierrc: { "plugins": ["prettier-plugin-sort-imports"] }
N/A
No import needed in code; just install and configure via Prettier config.

Install plugin and configure Prettier to sort imports by length, strip newlines, and group NPM packages before local imports with a blank line between groups.

npm install --save-dev prettier-plugin-sort-imports # Create .prettierrc with: { "plugins": ["prettier-plugin-sort-imports"], "sortingMethod": "lineLength", "stripNewlines": true, "importTypeOrder": ["NPMPackages", "localImports"], "newlineBetweenTypes": true }
Debug
Known issues
gotchaAlphabetical sorting sorts by the entire import path, so `../` imports may rank lower than expected.
fix
Use `'lineLength'` sorting method if you want a different order.
affects: >=1.0.0
deprecatedThe option `localImports` in `importTypeOrder` is deprecated in favor of using both `localImportsValue` and `localImportsType`.
fix
Use `['NPMPackages', 'localImportsValue', 'localImportsType']` instead of `['NPMPackages', 'localImports']`.
affects: >=1.7.0
breakingPlugin no longer works with Prettier <2.0.0.
fix
Upgrade Prettier to 2.0.0 or later.
affects: >=1.0.0
gotchaThe `packageJSONFiles` option is only used when `importTypeOrder` includes `'NPMPackages'`. Setting it with `['all']` has no effect.
fix
Only define `packageJSONFiles` if you are using `NPMPackages` in `importTypeOrder`.
affects: >=1.0.0
gotchaComments between imports may be moved if `stripNewlines` is true. The comment sticks to the import above it initially.
fix
Use `// sort-imports-begin-ignore` and `// sort-imports-end-ignore` to preserve comments in a block.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-sort-imports'
Plugin not installed or not in node_modules.
fix
Run `npm install --save-dev prettier-plugin-sort-imports` to install the plugin.
Unknown option: sortingMethod
Prettier version <2.0.0 does not support plugin options properly.
fix
Upgrade Prettier to 2.0.0+ or use a .prettierrc.js file with `plugins: [require.resolve('prettier-plugin-sort-imports')]`.
Invalid sorting method: 'alphabetical' is not a valid option
Typo in option value (e.g., 'alphabetical' instead of 'alphabetical').
fix
Check the spelling: use `"sortingMethod": "alphabetical"` (correct spelling: alphabetical).
Error: importTypeOrder must contain either 'all' or a combination of 'NPMPackages', 'localImportsValue', 'localImportsType'.
Invalid combination of import types in `importTypeOrder`.
fix
Use one of: `['all']`, `['NPMPackages', 'localImports']`, or `['NPMPackages', 'localImportsValue', 'localImportsType']`.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
prettierrequiredruntime peer dependency for plugin loading and formatting
Agent activity
6 hits · last 30 days
node
6
Resources
prettier-plugin-sort-imports-desc — npm install prettier-plugin-sort-imports-desc · libregistry