@adaskothebeast/prettier-import-sort
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

@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

  1. 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
  2. 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
  3. 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',
      },
    };
  4. 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.

  5. 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.

Readme

Keywords

none

Package Sidebar

Install

npm i @adaskothebeast/prettier-import-sort

Weekly Downloads

1

Version

1.0.9

License

none

Unpacked Size

11.6 kB

Total Files

9

Last publish

Collaborators

  • adasko