@putout/printer 1.54.4 → 1.54.5

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.04.18, v1.54.5
2
+
3
+ feature:
4
+ - 06bf3c0 @putout/printer: improve one element ArrayExpression newline support
5
+
1
6
  2023.04.18, v1.54.4
2
7
 
3
8
  fix:
@@ -186,7 +186,21 @@ function isCallInsideArrow(path) {
186
186
  return path.node.elements.length < 4;
187
187
  }
188
188
 
189
+ function isOneSimple(path) {
190
+ const elements = path.get('elements');
191
+
192
+ if (elements.length !== 1)
193
+ return false;
194
+
195
+ const [first] = elements;
196
+
197
+ return first.isIdentifier() && first.node.name.length < 5;
198
+ }
199
+
189
200
  function isNewlineBetweenElements(path, {elements}) {
201
+ if (isOneSimple(path))
202
+ return false;
203
+
190
204
  if (isCallInsideArrow(path))
191
205
  return false;
192
206
 
@@ -33,4 +33,3 @@ module.exports.FunctionDeclaration = {
33
33
  print('__body');
34
34
  },
35
35
  };
36
-
@@ -79,8 +79,5 @@ module.exports.isNewlineBetweenStatements = (path) => {
79
79
 
80
80
  module.exports.satisfy = (conditions) => (path) => {
81
81
  for (const condition of conditions)
82
- if (condition(path))
83
- return true;
84
-
85
- return false;
82
+ return false;
86
83
  };
@@ -1,8 +1,19 @@
1
1
  'use strict';
2
2
 
3
- const {isNewlineBetweenStatements} = require('../is');
3
+ const {
4
+ isNewlineBetweenStatements,
5
+ isNext,
6
+ } = require('../is');
7
+
4
8
  const {isMarkedAfter} = require('../mark');
5
9
 
10
+ const notClass = (path) => {
11
+ if (!isNext(path))
12
+ return false;
13
+
14
+ return !path.get('declaration').isClass();
15
+ };
16
+
6
17
  module.exports.ExportDefaultDeclaration = {
7
18
  beforeIf(path) {
8
19
  const prev = path.getPrevSibling();
@@ -21,4 +32,11 @@ module.exports.ExportDefaultDeclaration = {
21
32
  traverse(declaration);
22
33
  maybe.print(!declaration.isClassDeclaration(), ';');
23
34
  },
35
+ afterSatisfy: () => [
36
+ notClass,
37
+ ],
38
+ after(path, {print}) {
39
+ print.newline();
40
+ print.newline();
41
+ },
24
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.54.4",
3
+ "version": "1.54.5",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",