@bfra.me/prettier-config 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bfra.me/prettier-config",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Shared Prettier configuration for bfra.me",
5
5
  "license": "MIT",
6
6
  "author": "Marcus R. Brown <contact@bfra.me>",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "prettier": "3.2.5",
36
- "@bfra.me/prettier-config": "0.2.1",
36
+ "@bfra.me/prettier-config": "0.2.2",
37
37
  "@bfra.me/tsconfig": "0.3.1"
38
38
  },
39
39
  "keywords": [
@@ -1,5 +1,6 @@
1
1
  import {parsers} from 'prettier/plugins/babel'
2
2
  import {format} from 'prettier-package-json'
3
+ const jsonStringifyParser = parsers['json-stringify']
3
4
  /**
4
5
  * Shared Prettier configuration for bfra.me projects.
5
6
  */
@@ -63,10 +64,13 @@ const config = {
63
64
  {
64
65
  parsers: {
65
66
  'json-stringify': {
66
- ...parsers['json-stringify'],
67
+ ...jsonStringifyParser,
67
68
  preprocess(text, options) {
69
+ if (jsonStringifyParser.preprocess) {
70
+ text = jsonStringifyParser.preprocess(text, options)
71
+ }
68
72
  if (/package.*json$/u.test(options.filepath)) {
69
- return format(JSON.parse(text), {
73
+ text = format(JSON.parse(text), {
70
74
  tabWidth: options.tabWidth,
71
75
  useTabs: options.useTabs === true,
72
76
  ...(options['prettier-package-json'] ?? {}),
@@ -2,6 +2,8 @@ import type {Config, ParserOptions} from 'prettier'
2
2
  import {parsers} from 'prettier/plugins/babel'
3
3
  import {format, type Options as PrettierPackageJsonOptions} from 'prettier-package-json'
4
4
 
5
+ const jsonStringifyParser = parsers['json-stringify']
6
+
5
7
  /**
6
8
  * Shared Prettier configuration for bfra.me projects.
7
9
  */
@@ -71,11 +73,14 @@ const config: Config = {
71
73
  {
72
74
  parsers: {
73
75
  'json-stringify': {
74
- ...parsers['json-stringify'],
76
+ ...jsonStringifyParser,
75
77
 
76
78
  preprocess(text: string, options: ParserOptions) {
79
+ if (jsonStringifyParser.preprocess) {
80
+ text = jsonStringifyParser.preprocess(text, options)
81
+ }
77
82
  if (/package.*json$/u.test(options.filepath)) {
78
- return format(JSON.parse(text), {
83
+ text = format(JSON.parse(text), {
79
84
  tabWidth: options.tabWidth,
80
85
  useTabs: options.useTabs === true,
81
86
  ...((options['prettier-package-json'] ??