IanVS / prettier-plugin-sort-imports

An opinionated but flexible prettier plugin to sort import statements
Apache License 2.0
984 stars 25 forks source link

Discussions Tab #170

Closed babakfp closed 4 months ago

babakfp commented 4 months ago

Hi It may be a good idea to activate the discussions tab, so people can share their ordering configs. Thank you for this library. This is the result after using it: image https://github.com/babakfp/angle-berry-client/commit/82514fce990f1a71f5a73b6c1d940b6d037842cf My config:

{
    importOrder: ["^@(!/)", "<THIRD_PARTY_MODULES>", "^\\$", "^@/", "^[.]"],
    //            1          2                        3       4      5
}

Ignore the red background ^^^

  1. This matches import statements that start with @ but are not followed by a /.
  2. Everything else
  3. Matches import statements that start with $.
    • I use this for some SvelteKit specific (built-in) imports that are relative to source code that exists somewhere in the project.
  4. Matches import statements that start with @/.
    • Commonly used in projects where @/ is an alias for a directory, like the src folder.
  5. Matches import statements that start with ..

some results shot:

image

image