@putout/printer 8.14.0 → 8.16.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
+ 2024.04.16, v8.16.0
2
+
3
+ feature:
4
+ - 95b0c77 @putout/printer: ImprotDeclaration: maxSpecifiersInOneLine: align to eslint-plugin-putout
5
+
6
+ 2024.04.16, v8.15.0
7
+
8
+ feature:
9
+ - e17158f @putout/printer: ObjectPattern: improve indentation
10
+
1
11
  2024.04.15, v8.14.0
2
12
 
3
13
  feature:
@@ -26,10 +26,10 @@ function isIndent(path) {
26
26
  }
27
27
 
28
28
  module.exports.ObjectPattern = {
29
- print: maybeTypeAnnotation((path, {indent, print, maybe}, semantics) => {
29
+ print: maybeTypeAnnotation((path, {print, maybe}, semantics) => {
30
30
  const {maxPropertiesInOneLine} = semantics;
31
-
32
31
  const shouldIndent = isIndent(path);
32
+
33
33
  maybe.indent.inc(shouldIndent);
34
34
  print('{');
35
35
 
@@ -93,7 +93,10 @@ module.exports.ObjectPattern = {
93
93
  }
94
94
 
95
95
  maybe.indent.dec(shouldIndent);
96
- maybe.indent(is && shouldIndent);
96
+
97
+ maybe.indent.dec(!shouldIndent);
98
+ maybe.indent(is);
99
+ maybe.indent.inc(!shouldIndent);
97
100
  print('}');
98
101
  }),
99
102
  afterIf(path) {
@@ -163,4 +166,3 @@ function shouldAddNewline(path, {maxPropertiesInOneLine}) {
163
166
 
164
167
  return parentPath.isObjectProperty();
165
168
  }
166
-
@@ -56,7 +56,7 @@ module.exports.ImportDeclaration = {
56
56
  indent.inc();
57
57
 
58
58
  maybe.write(!wasSpecifier, '{');
59
- maybe.write.breakline(importsCount > maxSpecifiersInOneLine);
59
+ maybe.write.breakline(importsCount >= maxSpecifiersInOneLine);
60
60
 
61
61
  wasSpecifier = true;
62
62
  write(imported.name);
@@ -66,12 +66,12 @@ module.exports.ImportDeclaration = {
66
66
  write(spec.node.local.name);
67
67
  }
68
68
 
69
- if (importsCount <= maxSpecifiersInOneLine && notLast) {
69
+ if (importsCount < maxSpecifiersInOneLine && notLast) {
70
70
  maybe.write(n, ',');
71
71
  maybe.write.space(n);
72
72
  }
73
73
 
74
- if (importsCount > maxSpecifiersInOneLine) {
74
+ if (importsCount >= maxSpecifiersInOneLine) {
75
75
  maybe.write(n, ',');
76
76
 
77
77
  const last = index === n;
@@ -115,7 +115,7 @@ function parseMaxSpecifiers(imports, options) {
115
115
 
116
116
  for (const {node} of imports) {
117
117
  if (node.imported.name !== node.local.name)
118
- return 0;
118
+ return 1;
119
119
  }
120
120
 
121
121
  return maxSpecifiersInOneLine;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "8.14.0",
3
+ "version": "8.16.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",