@bfra.me/prettier-config 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "name": "@bfra.me/prettier-config",
3
+ "version": "0.2.0",
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
- "type": "module",
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
- "keywords": [
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
- "devDependencies": {
41
- "prettier": "3.2.5",
42
- "@bfra.me/tsconfig": "0.2.5"
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.0",
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
  }
@@ -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
  */
@@ -54,6 +56,25 @@ const config = {
54
56
  },
55
57
  },
56
58
  ],
59
+ plugins: [
60
+ {
61
+ parsers: {
62
+ 'json-stringify': {
63
+ ...parsers['json-stringify'],
64
+ preprocess(text, options) {
65
+ if (/package.*json$/u.test(options.filepath)) {
66
+ return format(JSON.parse(text), {
67
+ tabWidth: options.tabWidth,
68
+ useTabs: options.useTabs === true,
69
+ ...(options['prettier-package-json'] ?? {}),
70
+ })
71
+ }
72
+ return text
73
+ },
74
+ },
75
+ },
76
+ },
77
+ ],
57
78
  }
58
79
  export default config
59
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJldHRpZXIuY29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsicHJldHRpZXIuY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBOztHQUVHO0FBQ0gsTUFBTSxNQUFNLEdBQVc7SUFDckIsV0FBVyxFQUFFLE9BQU87SUFDcEIsY0FBYyxFQUFFLEtBQUs7SUFDckIsU0FBUyxFQUFFLE1BQU07SUFDakIsVUFBVSxFQUFFLEdBQUc7SUFDZixJQUFJLEVBQUUsS0FBSztJQUNYLFdBQVcsRUFBRSxJQUFJO0lBRWpCLFNBQVMsRUFBRTtRQUNULCtCQUErQjtRQUMvQixzRUFBc0U7UUFDdEU7WUFDRSxLQUFLLEVBQUUsQ0FBQyxnQkFBZ0IsQ0FBQztZQUN6QixPQUFPLEVBQUU7Z0JBQ1AsUUFBUSxFQUFFLENBQUM7YUFDWjtTQUNGO1FBRUQsWUFBWTtRQUNaLDhDQUE4QztRQUM5QyxpREFBaUQ7UUFDakQ7WUFDRSxLQUFLLEVBQUUsQ0FBQyxNQUFNLENBQUM7WUFDZixPQUFPLEVBQUU7Z0JBQ1AsU0FBUyxFQUFFLE9BQU87Z0JBQ2xCLFdBQVcsRUFBRSxLQUFLO2FBQ25CO1NBQ0Y7UUFFRCwrR0FBK0c7UUFDL0csNEZBQTRGO1FBQzVGO1lBQ0UsS0FBSyxFQUFFO2dCQUNMLG9CQUFvQjtnQkFDcEIsWUFBWTtnQkFDWixXQUFXO2dCQUNYLGdCQUFnQjtnQkFDaEIsV0FBVztnQkFDWCxrQkFBa0I7Z0JBQ2xCLGFBQWE7Z0JBQ2IsYUFBYTtnQkFDYixlQUFlO2dCQUNmLHdCQUF3QjtnQkFDeEIscUJBQXFCO2dCQUNyQixxQkFBcUI7Z0JBRXJCLGtCQUFrQjtnQkFDbEIsa0JBQWtCO2dCQUNsQixhQUFhO2dCQUNiLGFBQWE7Z0JBQ2IsWUFBWTthQUNiO1lBQ0QsT0FBTyxFQUFFO2dCQUNQLGFBQWEsRUFBRSxJQUFJO2FBQ3BCO1NBQ0Y7S0FDRjtDQUNGLENBQUE7QUFFRCxlQUFlLE1BQU0sQ0FBQSJ9
80
+ //# sourceMappingURL=prettier.config.js.map
@@ -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.
@@ -60,6 +62,28 @@ const config: Config = {
60
62
  },
61
63
  },
62
64
  ],
65
+
66
+ plugins: [
67
+ {
68
+ parsers: {
69
+ 'json-stringify': {
70
+ ...parsers['json-stringify'],
71
+
72
+ preprocess(text: string, options: ParserOptions) {
73
+ if (/package.*json$/u.test(options.filepath)) {
74
+ return format(JSON.parse(text), {
75
+ tabWidth: options.tabWidth,
76
+ useTabs: options.useTabs === true,
77
+ ...((options['prettier-package-json'] ??
78
+ {}) as Partial<PrettierPackageJsonOptions>),
79
+ })
80
+ }
81
+ return text
82
+ },
83
+ },
84
+ },
85
+ },
86
+ ],
63
87
  }
64
88
 
65
89
  export default config