@putout/printer 1.15.2 → 1.15.4

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.03.31, v1.15.4
2
+
3
+ feature:
4
+ - b4076e9 @putout/printer: add support of TSAnyKeyword
5
+
6
+ 2023.03.31, v1.15.3
7
+
8
+ feature:
9
+ - d80165e @putout/printer: newline inside ArrayExpression inside ForOfStatement
10
+ - 8b7737b @putout/printer: ImportDeclaration: add support of no specifiers
11
+
1
12
  2023.03.31, v1.15.2
2
13
 
3
14
  feature:
@@ -8,6 +8,7 @@ const isForOf = ({parentPath}) => parentPath.isForOfStatement();
8
8
  const SECOND = 1;
9
9
 
10
10
  const isStringAndArray = ([a, b]) => a?.isStringLiteral() && b?.isArrayExpression();
11
+ const isArrayParent = (path) => path.parentPath.isArrayExpression();
11
12
  const isTwoLongStrings = ([a, b]) => {
12
13
  const LONG_STRING = 20;
13
14
 
@@ -46,7 +47,9 @@ module.exports.ArrayExpression = (path, {print, maybe, indent}) => {
46
47
  if (!isTwoLongStrings(elements))
47
48
  maybe.indent.dec(!shouldIncreaseIndent);
48
49
 
49
- if (path.parentPath.isArrayExpression() && isStringAndArray(path.parentPath.get('elements'))) {
50
+ const parentElements = path.parentPath.get('elements');
51
+
52
+ if (isArrayParent(path) && isStringAndArray(parentElements)) {
50
53
  indent.dec();
51
54
  maybe.indent(elements.length && isNewLine);
52
55
  indent.inc();
@@ -115,10 +118,13 @@ function tooLong(path) {
115
118
  }
116
119
 
117
120
  function isNewlineBetweenElements(path, {elements}) {
121
+ if (isIncreaseIndent(path))
122
+ return false;
123
+
118
124
  if (isInsideCallLoop(path))
119
125
  return false;
120
126
 
121
- if (isIncreaseIndent(path))
127
+ if (isInsideLoop(path))
122
128
  return false;
123
129
 
124
130
  if (isTwoStringsDifferentLength(elements))
@@ -152,3 +158,11 @@ function isInsideCallLoop(path) {
152
158
 
153
159
  return true;
154
160
  }
161
+
162
+ function isInsideLoop(path) {
163
+ if (!path.parentPath.isForOfStatement())
164
+ return false;
165
+
166
+ return true;
167
+ }
168
+
@@ -22,9 +22,12 @@ module.exports.ImportDeclaration = (path, {print, maybe}) => {
22
22
  }
23
23
  }
24
24
 
25
- print(' ');
26
- print('from');
27
- print(' ');
25
+ if (specifiers.length) {
26
+ print.space();
27
+ print('from');
28
+ print.space();
29
+ }
30
+
28
31
  print('__source');
29
32
  print(';');
30
33
  print.newline();
@@ -20,6 +20,9 @@ module.exports = {
20
20
  TSNumberKeyword(path, {write}) {
21
21
  write('number');
22
22
  },
23
+ TSAnyKeyword(path, {write}) {
24
+ write('any');
25
+ },
23
26
  TSTypeAnnotation(path, {print}) {
24
27
  print(':');
25
28
  print.space();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.15.2",
3
+ "version": "1.15.4",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",