@putout/printer 12.16.0 → 12.18.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
+ 2025.01.27, v12.18.0
2
+
3
+ feature:
4
+ - 7fae490 @putout/printer: ExpressionStatement: before IfStatement
5
+
6
+ 2025.01.24, v12.17.0
7
+
8
+ feature:
9
+ - 9f5b1af @putout/printer: ExpressionStatement: inside AssignemntExpression: after FunctionDeclaration: indent
10
+
1
11
  2025.01.24, v12.16.0
2
12
 
3
13
  feature:
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const {types} = require('@putout/babel');
4
3
  const {
5
4
  isNext,
6
5
  isLast,
@@ -14,11 +13,7 @@ const {
14
13
  isInsideLabel,
15
14
  } = require('../../is');
16
15
 
17
- const {
18
- isExpressionStatement,
19
- isAssignmentExpression,
20
- isFunction,
21
- } = types;
16
+ const {isInsideAssignNextAssignFunction} = require('./is-inside-assign-next-assign-function');
22
17
 
23
18
  const not = (fn) => (...a) => !fn(...a);
24
19
 
@@ -42,10 +37,15 @@ const satisfyAfter = satisfy([
42
37
  isNextUp,
43
38
  ]);
44
39
 
40
+ const isNextIf = (path) => path
41
+ .getNextSibling()
42
+ .isIfStatement();
43
+
45
44
  const shouldBreakline = satisfy([
46
45
  isNewlineBetweenSiblings,
47
46
  isNotLastBody,
48
47
  isStrictMode,
48
+ isNextIf,
49
49
  ]);
50
50
 
51
51
  module.exports.ExpressionStatement = {
@@ -102,28 +102,6 @@ module.exports.ExpressionStatement = {
102
102
  },
103
103
  };
104
104
 
105
- const isInsideAssignNextAssignFunction = (path) => {
106
- const {expression} = path.node;
107
-
108
- if (!isAssignmentExpression(expression))
109
- return false;
110
-
111
- const next = path.getNextSibling();
112
-
113
- if (!isExpressionStatement(next))
114
- return false;
115
-
116
- const {leadingComments} = next.node;
117
-
118
- if (!leadingComments)
119
- return false;
120
-
121
- if (!isAssignmentExpression(next.node.expression))
122
- return false;
123
-
124
- return isFunction(next.node.expression.right);
125
- };
126
-
127
105
  function isTopParentLast({parentPath}) {
128
106
  if (!parentPath.isIfStatement())
129
107
  return false;
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ const {types} = require('@putout/babel');
4
+ const {
5
+ isExpressionStatement,
6
+ isFunction,
7
+ isAssignmentExpression,
8
+ } = types;
9
+
10
+ module.exports.isInsideAssignNextAssignFunction = (path) => {
11
+ const {expression} = path.node;
12
+
13
+ if (!isAssignmentExpression(expression))
14
+ return false;
15
+
16
+ const next = path.getNextSibling();
17
+
18
+ if (isFunction(next) && next.node.leadingComments)
19
+ return true;
20
+
21
+ if (!isExpressionStatement(next))
22
+ return false;
23
+
24
+ const {leadingComments} = next.node;
25
+
26
+ if (!leadingComments)
27
+ return false;
28
+
29
+ if (!isAssignmentExpression(next.node.expression))
30
+ return false;
31
+
32
+ return isFunction(next.node.expression.right);
33
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "12.16.0",
3
+ "version": "12.18.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",