@putout/printer 2.15.0 → 2.17.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.06.15, v2.17.0
2
+
3
+ feature:
4
+ - 27c6292 @putout/printer: ImportDefault: newlines
5
+
6
+ 2023.06.14, v2.16.0
7
+
8
+ feature:
9
+ - 3540087 @putout/printer: ObjectExpression: newline
10
+
1
11
  2023.06.14, v2.15.0
2
12
 
3
13
  feature:
@@ -12,7 +12,6 @@ const {
12
12
  } = require('../../is');
13
13
 
14
14
  const {parseComments} = require('../../comments');
15
- const {isObjectExpression} = require('@babel/types');
16
15
 
17
16
  const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
18
17
  const isLogical = (path) => path.get('argument').isLogicalExpression();
@@ -84,12 +83,8 @@ const notLastArgInsideCall = (path) => {
84
83
  if (!parentPath.isCallExpression())
85
84
  return false;
86
85
 
87
- const {properties} = path.node;
88
-
89
- for (const property of properties) {
90
- if (isObjectExpression(property.value))
91
- return false;
92
- }
86
+ if (isCoupleLines(path))
87
+ return false;
93
88
 
94
89
  return path !== parentPath
95
90
  .get('arguments')
@@ -40,7 +40,7 @@ function isCoupleLines(path) {
40
40
  const start = path.node?.loc?.start?.line;
41
41
  const end = path.node?.loc?.end?.line;
42
42
 
43
- return end > start;
43
+ return end !== start;
44
44
  }
45
45
 
46
46
  module.exports.exists = (a) => a.node;
@@ -1,7 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  const {markAfter} = require('../../mark');
4
- const {isLast, isNext} = require('../../is');
4
+
5
+ const {
6
+ isLast,
7
+ isNext,
8
+ } = require('../../is');
9
+
5
10
  const {parseImportSpecifiers} = require('parse-import-specifiers');
6
11
 
7
12
  const {
@@ -73,7 +78,12 @@ module.exports.ImportDeclaration = {
73
78
 
74
79
  if (importsCount > maxSpecifiersInOneLine) {
75
80
  maybe.write(n, ',');
76
- maybe.write.newline(index === n);
81
+
82
+ const last = index === n;
83
+ const penult = index === n - 1;
84
+
85
+ maybe.write.newline(penult && defaults.length);
86
+ maybe.write.newline(last);
77
87
  }
78
88
 
79
89
  indent.dec();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.15.0",
3
+ "version": "2.17.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",