@putout/printer 5.31.0 → 5.33.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,13 @@
1
+ 2023.10.24, v5.33.0
2
+
3
+ feature:
4
+ - 8bd4d6c @putout/printer: JSXText: raw
5
+
6
+ 2023.10.24, v5.32.0
7
+
8
+ feature:
9
+ - 2888e77 ExportNamedDeclaration: couple specifiers + source
10
+
1
11
  2023.10.20, v5.31.0
2
12
 
3
13
  feature:
@@ -21,6 +21,7 @@ module.exports.JSXElement = {
21
21
  path
22
22
  .get('children')
23
23
  .map(traverse);
24
+
24
25
  print('__closingElement');
25
26
 
26
27
  if (insideFn && insideCall) {
@@ -40,5 +41,8 @@ function condition(path) {
40
41
  if (path.parentPath.isReturnStatement())
41
42
  return true;
42
43
 
44
+ if (path.node.extra?.parenthesized)
45
+ return true;
46
+
43
47
  return path.parentPath.isVariableDeclarator();
44
48
  }
@@ -3,10 +3,14 @@
3
3
  const {isNext} = require('../is');
4
4
 
5
5
  module.exports.JSXText = (path, {write, indent}) => {
6
- const {value} = path.node;
6
+ const {node} = path;
7
+ const {value, extra} = node;
7
8
  const isSpacesOnly = /^\s+$/.test(value);
8
9
  const hasNext = isNext(path);
9
10
 
11
+ if (extra?.raw.startsWith('&'))
12
+ return write(extra.raw);
13
+
10
14
  if (isSpacesOnly && hasNext) {
11
15
  indent.inc();
12
16
  write.breakline();
@@ -17,7 +21,6 @@ module.exports.JSXText = (path, {write, indent}) => {
17
21
 
18
22
  if (isSpacesOnly) {
19
23
  write.breakline();
20
-
21
24
  return;
22
25
  }
23
26
 
@@ -44,15 +44,8 @@ module.exports.ExportNamedDeclaration = {
44
44
  indent();
45
45
  write('export');
46
46
 
47
- if (exportKind === 'type' && specifiers.length) {
48
- print(' type ');
49
- print(specifiers[0]);
50
- print(' from ');
51
- traverse(source);
52
- print(';');
53
-
54
- return;
55
- }
47
+ if (exportKind === 'type' && specifiers.length)
48
+ print(' type');
56
49
 
57
50
  if (isExportNamespaceSpecifier(specifiers[0])) {
58
51
  print(' ');
@@ -60,7 +53,7 @@ module.exports.ExportNamedDeclaration = {
60
53
  print(' from ');
61
54
  print('__source');
62
55
  print(';');
63
- print.newline();
56
+ maybe.print.newline(!isLast(path));
64
57
 
65
58
  return;
66
59
  }
@@ -74,11 +67,18 @@ module.exports.ExportNamedDeclaration = {
74
67
  indent.inc();
75
68
  maybe.write.newline(isNewline);
76
69
 
77
- for (const spec of specifiers) {
70
+ const lastIndex = n - 1;
71
+
72
+ for (const [i, spec] of specifiers.entries()) {
78
73
  const isType = spec.node.exportKind === 'type';
79
74
  maybe.indent(isNewline);
80
75
  maybe.write(isType, 'type ');
81
76
  traverse(spec);
77
+
78
+ if (i < lastIndex && !isNewline) {
79
+ write(', ');
80
+ }
81
+
82
82
  maybe.write(isNewline, ',');
83
83
  maybe.write.newline(isNewline);
84
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "5.31.0",
3
+ "version": "5.33.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",