putnikproj
TTCTheo's Typesafe Cult
•Created by SHAKA PAKA on 7/24/2023 in #questions
Sorting imports
I use '@ianvs/prettier-plugin-sort-imports', and I'm pretty happy with it. It seems the best option to me among others. Here is my prettier config for Next.js to make this plugin work as I need:
module.exports = {
// ...
importOrder: [
"^(next/(.)$)|^(next$)",
"^(react/(.)$)|^(react$)",
"<THIRD_PARTY_MODULES>",
"",
"^types$",
"^@/env(.)$",
"^@/types/(.)$",
"",
"^@/lib/(.)$",
"^@/hooks/(.)$",
"",
"^@/components/ui/(.)$",
"^@/components/(.)$",
"^@/app/(.*)$",
"",
"^[./]",
],
importOrderTypeScriptVersion: "5.0.0",
plugins: ["@ianvs/prettier-plugin-sort-imports"],
};
4 replies