putout 32.7.0 → 32.9.0

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/ChangeLog CHANGED
@@ -1,3 +1,14 @@
1
+ 2023.10.29, v32.9.0
2
+
3
+ feature:
4
+ - ac81b0d52 package: @putout/formatter-time v1.0.1
5
+
6
+ 2023.10.28, v32.8.0
7
+
8
+ feature:
9
+ - f23dbbe95 putout: printer: improve support of JSON
10
+ - 61e6bedef putout: printer: improve support of JSON and JSON in Markdown without ESLint
11
+
1
12
  2023.10.28, v32.7.0
2
13
 
3
14
  feature:
@@ -1,4 +1,3 @@
1
- const {assign} = Object;
2
1
  const {isArray} = Array;
3
2
  const maybeArray = (a) => isArray(a) ? a : [a];
4
3
 
@@ -8,18 +7,44 @@ const DefaultMarkdown = {
8
7
  },
9
8
  };
10
9
 
10
+ const JSON = {
11
+ format: {
12
+ quote: '"',
13
+ },
14
+ semantics: {
15
+ trailingComma: false,
16
+ },
17
+ };
18
+
11
19
  export const configurePrinter = (name, printerOptions) => {
12
20
  const [printer = 'putout', options = {}] = maybeArray(printerOptions);
21
+ const ext = name
22
+ .split('.')
23
+ .pop();
13
24
 
14
25
  if (printer !== 'putout')
15
26
  return printerOptions;
16
27
 
17
- if (name.endsWith('.md{json}'))
18
- assign(options, DefaultMarkdown);
19
- else if (name.endsWith('.md{js}'))
20
- assign(options, DefaultMarkdown);
21
- else if (name.endsWith('.md{ts}'))
22
- assign(options, DefaultMarkdown);
28
+ if (ext === 'json')
29
+ return [printer, JSON];
30
+
31
+ if (ext === 'md{json}')
32
+ return [printer, {
33
+ format: {
34
+ ...DefaultMarkdown.format,
35
+ ...JSON.format,
36
+ },
37
+ semantics: {
38
+ ...DefaultMarkdown.semantics,
39
+ ...JSON.semantics,
40
+ },
41
+ }];
42
+
43
+ if (ext === 'md{js}')
44
+ return [printer, DefaultMarkdown];
45
+
46
+ if (ext === 'md{ts}')
47
+ return [printer, DefaultMarkdown];
23
48
 
24
49
  return [printer, options];
25
50
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "32.7.0",
3
+ "version": "32.9.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json",
@@ -65,6 +65,7 @@
65
65
  "@putout/formatter-progress": "^4.0.0",
66
66
  "@putout/formatter-progress-bar": "^3.0.0",
67
67
  "@putout/formatter-stream": "^4.0.0",
68
+ "@putout/formatter-time": "^1.0.1",
68
69
  "@putout/operate": "^11.0.0",
69
70
  "@putout/operator-add-args": "^7.0.0",
70
71
  "@putout/operator-declare": "^8.0.0",