@putout/printer 6.6.0 → 6.8.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.11.30, v6.8.0
2
+
3
+ feature:
4
+ - 82cd2e3 @putout/printer: leading comments in SpreadElement ObjectProperty
5
+
6
+ 2023.11.29, v6.7.0
7
+
8
+ feature:
9
+ - 0e3a3cc @putout/printer: nested arrays
10
+
1
11
  2023.11.28, v6.6.0
2
12
 
3
13
  fix:
@@ -17,6 +17,7 @@ const {
17
17
  isVariableDeclarator,
18
18
  isClassProperty,
19
19
  isTSPropertySignature,
20
+ isSpreadElement,
20
21
  } = types;
21
22
 
22
23
  const isProperty = satisfy([
@@ -24,6 +25,7 @@ const isProperty = satisfy([
24
25
  isVariableDeclarator,
25
26
  isClassProperty,
26
27
  isTSPropertySignature,
28
+ isSpreadElement,
27
29
  ]);
28
30
 
29
31
  module.exports.parseLeadingComments = (path, {print, maybe, indent}, semantics) => {
@@ -21,11 +21,12 @@ const {
21
21
  } = types;
22
22
 
23
23
  const isNextObject = (a) => a.getNextSibling().isObjectExpression();
24
+
24
25
  const isArrayInsideArray = (path) => {
25
26
  if (!path.isArrayExpression() || !path.parentPath.isArrayExpression())
26
27
  return false;
27
28
 
28
- return path === path.parentPath.get('elements').at(-1);
29
+ return path.parentPath.node.elements.length <= 3;
29
30
  };
30
31
 
31
32
  const isInsideOneElementArray = ({parentPath}) => parentPath.node.elements.length === 1;
@@ -59,7 +59,9 @@ module.exports.ObjectExpression = (path, printer, semantics) => {
59
59
  if (property.isSpreadElement()) {
60
60
  const logical = isLogical(property);
61
61
 
62
- maybe.indent(length > 1 || logical || manyLines);
62
+ if (noLeadingComment(property))
63
+ maybe.indent(length > 1 || logical || manyLines);
64
+
63
65
  print(property);
64
66
 
65
67
  if (length > 1 || manyLines) {
@@ -1,6 +1,10 @@
1
1
  'use strict';
2
2
 
3
- module.exports.SpreadElement = (path, {print}) => {
3
+ const {parseTrailingComments} = require('../comment/comment');
4
+
5
+ module.exports.SpreadElement = (path, printer, semantics) => {
6
+ const {print} = printer;
4
7
  print('...');
5
8
  print('__argument');
9
+ parseTrailingComments(path, printer, semantics);
6
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "6.6.0",
3
+ "version": "6.8.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",