@bfra.me/prettier-config 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +29 -25
- package/prettier.config.js +26 -2
- package/prettier.config.ts +30 -2
package/package.json
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "@bfra.me/prettier-config",
|
3
|
+
"version": "0.2.1",
|
3
4
|
"description": "Shared Prettier configuration for bfra.me",
|
4
|
-
"version": "0.1.0",
|
5
|
-
"author": "Marcus R. Brown <contact@bfra.me>",
|
6
5
|
"license": "MIT",
|
7
|
-
"
|
8
|
-
"main": "prettier.config.js",
|
9
|
-
"types": "prettier.config.d.ts",
|
6
|
+
"author": "Marcus R. Brown <contact@bfra.me>",
|
10
7
|
"homepage": "https://github.com/bfra-me/works/tree/main/packages/prettier-config#readme",
|
11
8
|
"repository": {
|
12
9
|
"directory": "packages/prettier-config",
|
@@ -14,22 +11,7 @@
|
|
14
11
|
"url": "https://github.com/bfra-me/works.git"
|
15
12
|
},
|
16
13
|
"bugs": "https://github.com/bfra-me/works/issues",
|
17
|
-
"
|
18
|
-
"bfra.me",
|
19
|
-
"works",
|
20
|
-
"prettier",
|
21
|
-
"prettier-config",
|
22
|
-
"config",
|
23
|
-
"shared"
|
24
|
-
],
|
25
|
-
"publishConfig": {
|
26
|
-
"access": "public",
|
27
|
-
"provenance": true
|
28
|
-
},
|
29
|
-
"files": [
|
30
|
-
"prettier.config.*",
|
31
|
-
"!*.map"
|
32
|
-
],
|
14
|
+
"type": "module",
|
33
15
|
"exports": {
|
34
16
|
".": {
|
35
17
|
"import": "./prettier.config.js",
|
@@ -37,14 +19,36 @@
|
|
37
19
|
},
|
38
20
|
"./package.json": "./package.json"
|
39
21
|
},
|
40
|
-
"
|
41
|
-
|
42
|
-
"
|
22
|
+
"main": "prettier.config.js",
|
23
|
+
"files": [
|
24
|
+
"prettier.config.*",
|
25
|
+
"!*.map"
|
26
|
+
],
|
27
|
+
"types": "prettier.config.d.ts",
|
28
|
+
"dependencies": {
|
29
|
+
"prettier-package-json": "2.8.0"
|
43
30
|
},
|
44
31
|
"peerDependencies": {
|
45
32
|
"prettier": "^3.0.0"
|
46
33
|
},
|
34
|
+
"devDependencies": {
|
35
|
+
"prettier": "3.2.5",
|
36
|
+
"@bfra.me/prettier-config": "0.2.1",
|
37
|
+
"@bfra.me/tsconfig": "0.3.1"
|
38
|
+
},
|
39
|
+
"keywords": [
|
40
|
+
"bfra.me",
|
41
|
+
"config",
|
42
|
+
"prettier",
|
43
|
+
"prettier-config",
|
44
|
+
"shared",
|
45
|
+
"works"
|
46
|
+
],
|
47
|
+
"publishConfig": {
|
48
|
+
"access": "public",
|
49
|
+
"provenance": true
|
50
|
+
},
|
47
51
|
"scripts": {
|
48
|
-
"build": "tsc && prettier --log-level silent --write prettier.config.*"
|
52
|
+
"build": "tsc && prettier --log-level silent --ignore-unknown --write prettier.config.*"
|
49
53
|
}
|
50
54
|
}
|
package/prettier.config.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import {parsers} from 'prettier/plugins/babel'
|
2
|
+
import {format} from 'prettier-package-json'
|
1
3
|
/**
|
2
4
|
* Shared Prettier configuration for bfra.me projects.
|
3
5
|
*/
|
@@ -36,24 +38,46 @@ const config = {
|
|
36
38
|
'**/lib/**',
|
37
39
|
'**/coverage/**',
|
38
40
|
'**/out/**',
|
39
|
-
'**/.changeset/**',
|
40
41
|
'**/.idea/**',
|
41
42
|
'**/.nuxt/**',
|
42
43
|
'**/.vercel/**',
|
43
44
|
'**/.vitepress/cache/**',
|
44
45
|
'**/.vite-inspect/**',
|
45
46
|
'**/__snapshots__/**',
|
47
|
+
'**/.changeset/*.md',
|
46
48
|
'**/CHANGELOG*.md',
|
47
49
|
'**/changelog*.md',
|
48
50
|
'**/LICENSE*',
|
49
51
|
'**/license*',
|
50
52
|
'**/*.min.*',
|
53
|
+
'package-lock.json',
|
54
|
+
'pnpm-lock.yaml',
|
55
|
+
'yarn.lock',
|
51
56
|
],
|
52
57
|
options: {
|
53
58
|
requirePragma: true,
|
54
59
|
},
|
55
60
|
},
|
56
61
|
],
|
62
|
+
plugins: [
|
63
|
+
{
|
64
|
+
parsers: {
|
65
|
+
'json-stringify': {
|
66
|
+
...parsers['json-stringify'],
|
67
|
+
preprocess(text, options) {
|
68
|
+
if (/package.*json$/u.test(options.filepath)) {
|
69
|
+
return format(JSON.parse(text), {
|
70
|
+
tabWidth: options.tabWidth,
|
71
|
+
useTabs: options.useTabs === true,
|
72
|
+
...(options['prettier-package-json'] ?? {}),
|
73
|
+
})
|
74
|
+
}
|
75
|
+
return text
|
76
|
+
},
|
77
|
+
},
|
78
|
+
},
|
79
|
+
},
|
80
|
+
],
|
57
81
|
}
|
58
82
|
export default config
|
59
|
-
//# sourceMappingURL=
|
83
|
+
//# sourceMappingURL=prettier.config.js.map
|
package/prettier.config.ts
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
import type {Config} from 'prettier'
|
1
|
+
import type {Config, ParserOptions} from 'prettier'
|
2
|
+
import {parsers} from 'prettier/plugins/babel'
|
3
|
+
import {format, type Options as PrettierPackageJsonOptions} from 'prettier-package-json'
|
2
4
|
|
3
5
|
/**
|
4
6
|
* Shared Prettier configuration for bfra.me projects.
|
@@ -41,7 +43,6 @@ const config: Config = {
|
|
41
43
|
'**/lib/**',
|
42
44
|
'**/coverage/**',
|
43
45
|
'**/out/**',
|
44
|
-
'**/.changeset/**',
|
45
46
|
'**/.idea/**',
|
46
47
|
'**/.nuxt/**',
|
47
48
|
'**/.vercel/**',
|
@@ -49,17 +50,44 @@ const config: Config = {
|
|
49
50
|
'**/.vite-inspect/**',
|
50
51
|
'**/__snapshots__/**',
|
51
52
|
|
53
|
+
'**/.changeset/*.md',
|
52
54
|
'**/CHANGELOG*.md',
|
53
55
|
'**/changelog*.md',
|
54
56
|
'**/LICENSE*',
|
55
57
|
'**/license*',
|
56
58
|
'**/*.min.*',
|
59
|
+
|
60
|
+
'package-lock.json',
|
61
|
+
'pnpm-lock.yaml',
|
62
|
+
'yarn.lock',
|
57
63
|
],
|
58
64
|
options: {
|
59
65
|
requirePragma: true,
|
60
66
|
},
|
61
67
|
},
|
62
68
|
],
|
69
|
+
|
70
|
+
plugins: [
|
71
|
+
{
|
72
|
+
parsers: {
|
73
|
+
'json-stringify': {
|
74
|
+
...parsers['json-stringify'],
|
75
|
+
|
76
|
+
preprocess(text: string, options: ParserOptions) {
|
77
|
+
if (/package.*json$/u.test(options.filepath)) {
|
78
|
+
return format(JSON.parse(text), {
|
79
|
+
tabWidth: options.tabWidth,
|
80
|
+
useTabs: options.useTabs === true,
|
81
|
+
...((options['prettier-package-json'] ??
|
82
|
+
{}) as Partial<PrettierPackageJsonOptions>),
|
83
|
+
})
|
84
|
+
}
|
85
|
+
return text
|
86
|
+
},
|
87
|
+
},
|
88
|
+
},
|
89
|
+
},
|
90
|
+
],
|
63
91
|
}
|
64
92
|
|
65
93
|
export default config
|