-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprettier.config.js
67 lines (63 loc) · 2.34 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
export default {
singleQuote: true, // 使用单引号
quoteProps: 'consistent', // 对象属性名引号保持一致
trailingComma: 'all', // 多行对象或数组的最后一个元素后面加上逗号
semi: true, // 在语句末尾加上分号
printWidth: 120, // 每行最大字符数
proseWrap: 'never', // 不对 Markdown 文件中的文字进行换行处理
endOfLine: 'lf', // 使用 LF 作为换行符
// 针对特定文件类型的特殊配置
overrides: [
{
// 针对只被 JSON5 工具使用的 JSON 文件的特殊配置
files: ['*/tsconfig.json', '.vscode/*.json'],
options: {
parser: 'json5', // 使用 json5 解析器
tabWidth: 2, // 缩进级别使用 2 个空格
quoteProps: 'preserve', // 保留属性名的引号
singleQuote: false,
},
},
{
// 针对所有 JSON 文件的配置
files: '*.json',
options: {
tabWidth: 2, // 缩进级别使用 2 个空格
quoteProps: 'preserve', // 保留属性名的引号
singleQuote: false,
},
},
{
// 针对 YAML 文件的配置,使用 2 个空格缩进,不使用 tab
files: ['*.yaml', '*.yml'],
options: {
tabWidth: 2, // 缩进级别使用 2 个空格
useTabs: false, // 不使用 tab 缩进
quoteProps: 'preserve', // 保留属性名的引号
},
},
],
// 导入顺序配置
importOrder: [
'<BUILTIN_MODULES>', // Node.js 内置模块
'^react$', // react 库
'^react', // 其他 react 相关的库
'<THIRD_PARTY_MODULES>', // 其他第三方模块
// '^@fullstrack/(.*)$', // workspace 路径下的模块
'^@/(.*)$', // @ 路径下的模块
'^[./]', // 相对路径
'css$', // CSS 文件
],
importOrderParserPlugins: ['typescript', 'jsx', 'decorators-legacy'], // 导入顺序插件的解析器插件
importOrderTypeScriptVersion: '5.5.3',
//tailwind 配置
tailwindConfig: './apps/web/tailwind.config.js',
tailwindFunctions: ['cls'],
// 使用的 prettier 插件
plugins: [
'@ianvs/prettier-plugin-sort-imports', // 用于排序导入的插件
'prettier-plugin-packagejson', // 用于格式化 package.json 的插件
'prettier-plugin-css-order', // 用于排序 CSS 规则的插件
'prettier-plugin-tailwindcss', // 用于格式化 Tailwind CSS 的插件
],
};