@putout/printer 11.10.2 → 11.12.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.12.25, v11.12.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 516a7ae @putout/printer: IfStatement: newline when empty and last inside FunctionDeclaration
|
|
5
|
+
|
|
6
|
+
2024.12.22, v11.11.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- a9800ca @putout/printer: AssignmentExpression: inside BinaryExpression: parens
|
|
10
|
+
|
|
1
11
|
2024.12.20, v11.10.2
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const {types} = require('@putout/babel');
|
|
4
|
+
|
|
3
5
|
const {markAfter} = require('../../mark');
|
|
4
6
|
const {exists, isNext} = require('../../is');
|
|
5
|
-
|
|
7
|
+
const {
|
|
8
|
+
isBlockStatement,
|
|
9
|
+
isFunctionDeclaration,
|
|
10
|
+
} = types;
|
|
6
11
|
const isInside = ({parentPath}) => !parentPath.parentPath.isProgram();
|
|
7
12
|
const isEmptyConsequent = (path) => path.get('consequent').isEmptyStatement();
|
|
8
13
|
|
|
@@ -16,6 +21,21 @@ const isInsideNestedBody = ({parentPath}) => {
|
|
|
16
21
|
const isInsideIf = (path) => path.parentPath.parentPath?.isIfStatement();
|
|
17
22
|
const isEmptyBody = (path) => !path.node.body.length;
|
|
18
23
|
|
|
24
|
+
const isLastEmptyInsideBody = (path) => {
|
|
25
|
+
const {parentPath} = path;
|
|
26
|
+
|
|
27
|
+
if (!isBlockStatement(parentPath))
|
|
28
|
+
return false;
|
|
29
|
+
|
|
30
|
+
if (!isBlockStatement(path.node.consequent))
|
|
31
|
+
return false;
|
|
32
|
+
|
|
33
|
+
if (path.node.consequent.body.length)
|
|
34
|
+
return false;
|
|
35
|
+
|
|
36
|
+
return isFunctionDeclaration(path.parentPath.parentPath);
|
|
37
|
+
};
|
|
38
|
+
|
|
19
39
|
module.exports.IfStatement = {
|
|
20
40
|
print: (path, {indent, print, maybe, write, traverse}) => {
|
|
21
41
|
const partOfAlternate = path.parentPath.get('alternate');
|
|
@@ -79,6 +99,9 @@ module.exports.IfStatement = {
|
|
|
79
99
|
|
|
80
100
|
if (path === partOfAlternate && isInside(path))
|
|
81
101
|
print.newline();
|
|
102
|
+
|
|
103
|
+
if (isLastEmptyInsideBody(path))
|
|
104
|
+
print.newline();
|
|
82
105
|
},
|
|
83
106
|
afterSatisfy: () => [isNext],
|
|
84
107
|
after: (path, {print}) => {
|
package/package.json
CHANGED