-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprettier.config.js
67 lines (63 loc) · 1.64 KB
/
prettier.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/** @typedef {import("@ianvs/prettier-plugin-sort-imports").PluginConfig} SortImportsConfig */
/** @typedef {import("prettier").Config} PrettierConfig */
const assets = [
"css",
"sass",
"scss",
"less",
"styl",
"svg",
"png",
"jpg",
"jpeg",
"gif",
"webp",
"eot",
"otf",
"ttf",
"woff",
"woff2",
"mp4",
"webm",
"wav",
"mp3",
"m4a",
"aac",
"oga",
];
const frameworks = ["encore", "prisma", "~encore"];
const importOrder = /** @satisfies {SortImportsConfig["importOrder"]} */ (
/** @type {const} */ ([
"^(?!@welldone-software).*?(wdyr|why-did-you-render|whyDidYouRender).*?$", // why-did-you-render is always first
`^.*\\.+(${assets.join("|")})$`, // assets should always be top-most (why-did-you-render excepted), as they may have side effects
" ",
"<BUILTIN_MODULES>", // node builtins
" ",
"^\\.", // relative imports
"^#", // aliased packages (e.g. workspaces)
" ",
`^@?(${frameworks.join("|")})(/.+)?$`,
" ",
`^(${frameworks.join("|")})[^/]+.*?$`, // framework ecosystem packages
" ",
"^@\\w", // other scoped packages
"<THIRD_PARTY_MODULES>", // other third party modules
// everything should be sorted by now, but just in case...
".*?",
])
);
export default /** @satisfies {PrettierConfig & SortImportsConfig} */ ({
experimentalTernaries: true,
plugins: ["@ianvs/prettier-plugin-sort-imports"],
importOrderParserPlugins: ["typescript", "jsx", "importAssertions"],
importOrder,
overrides: [
{
files: ["*.json", "*.jsonc", "*.json5", "encore.app"],
options: {
parser: "json",
trailingComma: "none",
},
},
],
});