@adaskothebeast/prettier-import-sort
v1.0.9
Published
[Prettier] plugin for sort imports using [import-sort] for javascript and TypeScript files based on [prettier-plugin-import-sort] great work of @ggascoigne and @renke - adjustment for Prettier v3;
Downloads
14
Readme
@adaskothebeast/prettier-import-sort
Prettier plugin for sort imports using import-sort for javascript and TypeScript files based on prettier-plugin-import-sort great work of @ggascoigne and @renke - adjustment for Prettier v3;
Installation
Install Prettier and this plugin with:
npm i -D prettier @adaskothebeast/prettier-import-sort import-sort-config
or
yarn add -D prettier @adaskothebeast/prettier-import-sort import-sort-config
You will also want to install an import sort style module of your choice, such as:
npm i -D import-sort-style-module
or
yarn add -D import-sort-style-module
You will then need the configuration for import-sorts available for example in
importsortrc.js
module.exports = { '.js, .jsx, .ts, .tsx': { style: 'module', parser: 'babel', }, };
If you are using TypeScript, you may also need to specify the TypeScript parser. This is somewhat dependant upon the TypeScript features used (decorators for instance), e.g.
module.exports = { '.js, .jsx, .ts, .tsx': { style: 'module', parser: 'typescript', }, };
Note: importSort silently falls back to its default configuration if it finds a setup error. Make sure that the extension list is like the example above and not something like
"*.js"
which is an error.adjust your
.prettierrc
file to include the plugin:{ "plugins": ["@adaskothebeast/prettier-import-sort"] }
Credits:
A large part of this code was copied from prettier-plugin-import-sort.