@putout/printer 14.0.1 → 14.1.1

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
+ 2025.03.23, v14.1.1
2
+
3
+ feature:
4
+ - 7f68d52 @putout/printer: ObjectPattern: maxPropertiesLengthInOneLine: NumericLiteral
5
+
6
+ 2025.03.22, v14.1.0
7
+
8
+ feature:
9
+ - 10da896 @putout/printer: ExportNamedDeclaration inside BlockStatement
10
+
1
11
  2025.03.22, v14.0.1
2
12
 
3
13
  feature:
@@ -6,6 +6,16 @@ const {
6
6
  isIdentifier,
7
7
  } = types;
8
8
 
9
+ function getLength(left, right) {
10
+ if (isIdentifier(left) && isIdentifier(right))
11
+ return left.name.length + right.name.length;
12
+
13
+ if (isIdentifier(left))
14
+ return left.name.length;
15
+
16
+ return 0;
17
+ }
18
+
9
19
  module.exports.moreThenMaxPropertiesLengthInOneLine = (path, {maxPropertiesLengthInOneLine}) => {
10
20
  const {properties} = path.node;
11
21
 
@@ -13,10 +23,7 @@ module.exports.moreThenMaxPropertiesLengthInOneLine = (path, {maxPropertiesLengt
13
23
  if (isAssignmentPattern(value)) {
14
24
  const {left, right} = value;
15
25
 
16
- if (!isIdentifier(left) || !isIdentifier(right))
17
- continue;
18
-
19
- const length = left.name.length + right.name.length;
26
+ const length = getLength(left, right);
20
27
 
21
28
  if (length >= maxPropertiesLengthInOneLine)
22
29
  return true;
@@ -2,6 +2,7 @@
2
2
 
3
3
  const {types} = require('@putout/babel');
4
4
 
5
+ const {isParentBlock} = require('#is');
5
6
  const {markAfter, isMarkedAfter} = require('../../mark');
6
7
 
7
8
  const {
@@ -115,7 +116,10 @@ module.exports.ExportNamedDeclaration = {
115
116
  if (isDeclarationNewline(path))
116
117
  return false;
117
118
 
118
- return isNewlineBetweenSiblings(path);
119
+ if (isNewlineBetweenSiblings(path))
120
+ return true;
121
+
122
+ return isParentBlock(path);
119
123
  },
120
124
  after(path, {print}) {
121
125
  print.newline();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "14.0.1",
3
+ "version": "14.1.1",
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",