@putout/printer 6.4.1 → 6.5.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,8 @@
1
+ 2023.11.28, v6.5.0
2
+
3
+ feature:
4
+ - afa7f81 @putout/printer: ArrayExpression: array inside array
5
+
1
6
  2023.11.16, v6.4.1
2
7
 
3
8
  fix:
@@ -14,12 +14,14 @@ const {
14
14
  isCurrentNewLine,
15
15
  } = require('./new-line');
16
16
 
17
+ const {types} = require('@putout/babel');
17
18
  const {
18
19
  isObjectExpression,
19
20
  isStringLiteral,
20
- } = require('@putout/babel').types;
21
+ } = types;
21
22
 
22
23
  const isNextObject = (a) => a.getNextSibling().isObjectExpression();
24
+ const isArrayInsideArray = (path) => path.isArrayExpression() && path.parentPath.isArrayExpression();
23
25
 
24
26
  const isInsideOneElementArray = ({parentPath}) => parentPath.node.elements.length === 1;
25
27
  const isInsideArray = (path) => path.parentPath.isArrayExpression();
@@ -63,7 +65,7 @@ module.exports.ArrayExpression = {
63
65
 
64
66
  print('[');
65
67
 
66
- const indented = !isTwoLongStrings(elements) || !isInsideArray(path) && isIndented(elements[0]);
68
+ const indented = !isArrayInsideArray(path) && (!isTwoLongStrings(elements) || !isInsideArray(path) && isIndented(elements[0]));
67
69
 
68
70
  if (indented)
69
71
  maybe.indent.inc(shouldIncreaseIndent);
@@ -103,7 +105,7 @@ module.exports.ArrayExpression = {
103
105
  indent.dec();
104
106
  maybe.indent(elements.length && isNewLine);
105
107
  indent.inc();
106
- } else if (!isObjectExpression(elements.at(-1))) {
108
+ } else if (!isArrayInsideArray(path) && !isObjectExpression(elements.at(-1))) {
107
109
  maybe.indent(elements.length && isNewLine);
108
110
  }
109
111
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "6.4.1",
3
+ "version": "6.5.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",