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-descVerified import paths — ran on the pinned version, not inferred.
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.
Use `'lineLength'` sorting method if you want a different order.
Use `['NPMPackages', 'localImportsValue', 'localImportsType']` instead of `['NPMPackages', 'localImports']`.
Upgrade Prettier to 2.0.0 or later.
Only define `packageJSONFiles` if you are using `NPMPackages` in `importTypeOrder`.
Use `// sort-imports-begin-ignore` and `// sort-imports-end-ignore` to preserve comments in a block.
Run `npm install --save-dev prettier-plugin-sort-imports` to install the plugin.
Upgrade Prettier to 2.0.0+ or use a .prettierrc.js file with `plugins: [require.resolve('prettier-plugin-sort-imports')]`.Check the spelling: use `"sortingMethod": "alphabetical"` (correct spelling: alphabetical).
Use one of: `['all']`, `['NPMPackages', 'localImports']`, or `['NPMPackages', 'localImportsValue', 'localImportsType']`.