@snelx/prettier-plugin-import-sort

1.0.0 • Public • Published

@snelx/prettier-plugin-import-sort

Prettier plugin to pass javascript and typescript through import-sort for Commonjs and ESM using import-sort.

Installation

$ pnpm i -D prettier @snelx/prettier-plugin-import-sort

You will also want to install an import sort style module of your choice, such as:

pnpm i -D import-sort-style-module
#or
pnpm i -D import-sort-style-eslint

You will then need the configuration for import-sorts available, e.g.

// In package.json
"importSort": {
    ".js, .jsx, .ts, .tsx": {
      "style": "module",
    }
  }

If you are using typescript, you may also need to specify the typescript parser. e.g.

// In package.json
"importSort": {
    ".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.

Credits:

A large part of this code was copied from import-sort-cli.

Dependents (0)

Package Sidebar

Install

npm i @snelx/prettier-plugin-import-sort

Weekly Downloads

9

Version

1.0.0

License

MIT

Unpacked Size

6.69 MB

Total Files

11

Last publish

Collaborators

  • herberthobregon