Prettier
coderljw 2024-10-13 小于 1 分钟
# 1. .prettierrc.js
/**
* @link https://prettier.io
* @type {import('prettier').Config}
*/
module.exports = {
semi: false,
printWidth: 100,
singleQuote: true,
jsxSingleQuote: true,
endOfLine: 'lf',
proseWrap: 'never',
arrowParens: 'always',
trailingComma: 'all',
overrides: [
{
files: ['*.json5'],
options: {
singleQuote: false,
quoteProps: 'preserve',
},
},
{
files: ['*.yml'],
options: {
singleQuote: false,
},
},
{
files: ['*.(css|less|scss|sass|styl|stylus)'],
options: {
singleQuote: false,
},
},
],
plugins: [
require.resolve('prettier-plugin-packagejson'),
require.resolve('@trivago/prettier-plugin-sort-imports'),
],
importOrderSortSpecifiers: true,
importOrderCaseInsensitive: true,
importOrder: [
'^(react|vue)(.*)',
'^@?(ant|element)(.*)',
'<THIRD_PARTY_MODULES>',
'^@/(.*)',
'^[.]{1,2}/(.+(?<![.]css|less|scss|sass|styl|stylus)$)',
'^(.*).(css|less|scss|sass|styl|stylus)$',
],
}
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
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
# 2. .prettierignore
# https://prettier.io/docs/en/ignore.html
temp
dist
build
coverage
yarn.lock
pnpm-lock.yaml
package-lock.json
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9