@putout/printer 1.31.0 → 1.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.04.10, v1.33.0
2
+
3
+ feature:
4
+ - 2114f04 @putout/printer: improve support of ArrayExpression tuple: Identifier + Identifier
5
+
6
+ 2023.04.10, v1.32.0
7
+
8
+ feature:
9
+ - 71835f6 @putout/printer: add support of JSXExpressionContainer
10
+
1
11
  2023.04.10, v1.31.0
2
12
 
3
13
  feature:
@@ -6,6 +6,7 @@ const {
6
6
  isObjectProperty,
7
7
  isStringLiteral,
8
8
  isArrayExpression,
9
+ isIdentifier,
9
10
  } = require('@babel/types');
10
11
 
11
12
  const {
@@ -17,6 +18,7 @@ const isForOf = ({parentPath}) => parentPath.isForOfStatement();
17
18
  const SECOND = 1;
18
19
  const isStringAndArray = ([a, b]) => isStringLiteral(a) && isArrayExpression(b);
19
20
  const isStringAndString = ([a, b]) => isStringLiteral(a) && isStringLiteral(b);
21
+ const isIdentifierAndIdentifier = ([a, b]) => isIdentifier(a) && isIdentifier(b);
20
22
  const isArrayParent = (path) => path.parentPath.isArrayExpression();
21
23
 
22
24
  const isTwoLongStrings = ([a, b]) => {
@@ -42,7 +44,10 @@ module.exports.ArrayExpression = {
42
44
  if (isCoupleLines(parentPath))
43
45
  return false;
44
46
 
45
- return isStringAndIdentifier(elements);
47
+ if (isStringAndIdentifier(elements))
48
+ return true;
49
+
50
+ return isIdentifierAndIdentifier(elements);
46
51
  },
47
52
  before(path, {print}) {
48
53
  print.breakline();
@@ -97,7 +102,10 @@ module.exports.ArrayExpression = {
97
102
  if (isCoupleLines(parentPath))
98
103
  return false;
99
104
 
100
- return isStringAndIdentifier(elements);
105
+ if (isStringAndIdentifier(elements))
106
+ return true;
107
+
108
+ return isIdentifierAndIdentifier(elements);
101
109
  },
102
110
  after(path, {print, indent}) {
103
111
  indent.dec();
@@ -15,6 +15,11 @@ module.exports = {
15
15
 
16
16
  print('>');
17
17
  },
18
+ JSXExpressionContainer(path, {print}) {
19
+ print('{');
20
+ print('__expression');
21
+ print('}');
22
+ },
18
23
  JSXAttribute(path, {print}) {
19
24
  print('__name');
20
25
  print('=');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.31.0",
3
+ "version": "1.33.0",
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",