@dt-frames/prettier-config 4.0.3 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +72 -0
- package/package.json +36 -36
package/index.mjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'
|
|
2
|
+
|
|
3
|
+
const require = createRequire(import.meta.url)
|
|
4
|
+
const plugins = []
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
plugins.push(require.resolve('prettier-plugin-tailwindcss'))
|
|
8
|
+
} catch {
|
|
9
|
+
// 插件不存在时降级,不阻塞 Prettier 基础格式化
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** @type {import('prettier').Config} */
|
|
13
|
+
const config = {
|
|
14
|
+
// 代码结尾是否加分号
|
|
15
|
+
semi: false,
|
|
16
|
+
|
|
17
|
+
// 缩进宽度(配合 useTabs=true 表示一个制表符等价宽度)
|
|
18
|
+
tabWidth: 4,
|
|
19
|
+
|
|
20
|
+
overrides: [
|
|
21
|
+
{
|
|
22
|
+
files: ['*.json5'],
|
|
23
|
+
options: {
|
|
24
|
+
quoteProps: 'preserve',
|
|
25
|
+
singleQuote: false
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
|
|
30
|
+
// 代码末尾不需要逗号
|
|
31
|
+
trailingComma: 'none',
|
|
32
|
+
|
|
33
|
+
// 文件换行格式
|
|
34
|
+
endOfLine: 'auto',
|
|
35
|
+
|
|
36
|
+
// 超过多少字符强制换行
|
|
37
|
+
printWidth: 100,
|
|
38
|
+
|
|
39
|
+
// 是否使用单引号
|
|
40
|
+
singleQuote: true,
|
|
41
|
+
|
|
42
|
+
// 单个参数的箭头函数不加括号 x => x
|
|
43
|
+
arrowParens: 'avoid',
|
|
44
|
+
|
|
45
|
+
// 对象大括号内两边是否加空格
|
|
46
|
+
bracketSpacing: true,
|
|
47
|
+
|
|
48
|
+
// 使用制表符缩进
|
|
49
|
+
useTabs: true,
|
|
50
|
+
|
|
51
|
+
// 对象的key仅在必要时用引号
|
|
52
|
+
quoteProps: 'as-needed',
|
|
53
|
+
|
|
54
|
+
// JSX 属性使用单引号
|
|
55
|
+
jsxSingleQuote: true,
|
|
56
|
+
|
|
57
|
+
// 不需要写文件开头的 @prettier
|
|
58
|
+
requirePragma: false,
|
|
59
|
+
|
|
60
|
+
// // 不需要自动在文件开头插入 @prettier
|
|
61
|
+
insertPragma: false,
|
|
62
|
+
|
|
63
|
+
// 使用默认的折行标准
|
|
64
|
+
proseWrap: 'never',
|
|
65
|
+
|
|
66
|
+
// 解决尖括号自动占一行
|
|
67
|
+
htmlWhitespaceSensitivity: 'ignore',
|
|
68
|
+
vueIndentScriptAndStyle: true,
|
|
69
|
+
plugins
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default config
|
package/package.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
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
|
-
}
|
|
2
|
+
"name": "@dt-frames/prettier-config",
|
|
3
|
+
"version": "4.0.4",
|
|
4
|
+
"description": "关于代码美化的配置封装",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dt-frames",
|
|
7
|
+
"prettier-config"
|
|
8
|
+
],
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"author": "jhon",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"index.mjs"
|
|
14
|
+
],
|
|
15
|
+
"main": "./index.mjs",
|
|
16
|
+
"module": "./index.mjs",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./index.mjs",
|
|
20
|
+
"default": "./index.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public",
|
|
25
|
+
"registry": "https://registry.npmjs.org/"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"prettier": "^3.5.3",
|
|
29
|
+
"prettier-plugin-tailwindcss": "^0.6.14"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"unbuild": "^3.5.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "pnpm unbuild"
|
|
36
|
+
}
|
|
37
|
+
}
|