@putout/printer 12.1.1 → 12.3.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,14 @@
|
|
|
1
|
+
2025.01.14, v12.3.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- a8074a5 @putout/printer: ExpressionStatement: inside ReturnStatement
|
|
5
|
+
- ecf7d0e @putout/printer: move out ExpressionStatement
|
|
6
|
+
|
|
7
|
+
2025.01.13, v12.2.0
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- a07e92a @putout/printer: JSXOpeningElement: indent
|
|
11
|
+
|
|
1
12
|
2025.01.12, v12.1.1
|
|
2
13
|
|
|
3
14
|
feature:
|
|
@@ -3,19 +3,24 @@
|
|
|
3
3
|
const {isCoupleLines} = require('../is');
|
|
4
4
|
|
|
5
5
|
const isNotJSX = ({parentPath}) => {
|
|
6
|
-
|
|
6
|
+
const grandPath = parentPath.parentPath;
|
|
7
|
+
|
|
8
|
+
if (grandPath.isObjectProperty())
|
|
9
|
+
return false;
|
|
10
|
+
|
|
11
|
+
if (grandPath.isCallExpression())
|
|
7
12
|
return false;
|
|
8
13
|
|
|
9
|
-
if (
|
|
14
|
+
if (grandPath.isJSXElement())
|
|
10
15
|
return false;
|
|
11
16
|
|
|
12
|
-
if (
|
|
17
|
+
if (grandPath.isJSXExpressionContainer())
|
|
13
18
|
return false;
|
|
14
19
|
|
|
15
|
-
if (
|
|
20
|
+
if (grandPath.isJSXFragment())
|
|
16
21
|
return false;
|
|
17
22
|
|
|
18
|
-
return !
|
|
23
|
+
return !grandPath.isLogicalExpression();
|
|
19
24
|
};
|
|
20
25
|
|
|
21
26
|
module.exports.JSXOpeningElement = {
|
|
@@ -11,8 +11,9 @@ const {
|
|
|
11
11
|
hasTrailingComment,
|
|
12
12
|
isCoupleLines,
|
|
13
13
|
isInsideLabel,
|
|
14
|
-
} = require('
|
|
14
|
+
} = require('../../is');
|
|
15
15
|
|
|
16
|
+
const not = (fn) => (...a) => !fn(...a);
|
|
16
17
|
const isBeforeElse = (path) => {
|
|
17
18
|
if (!path.parentPath.isIfStatement())
|
|
18
19
|
return false;
|
|
@@ -23,6 +24,9 @@ const isBeforeElse = (path) => {
|
|
|
23
24
|
return Boolean(path.parentPath.node.alternate);
|
|
24
25
|
};
|
|
25
26
|
|
|
27
|
+
const isInsideReturn = ({parentPath}) => parentPath.isReturnStatement();
|
|
28
|
+
const notInsideReturn = not(isInsideReturn);
|
|
29
|
+
|
|
26
30
|
const satisfyAfter = satisfy([
|
|
27
31
|
isNotLastOrParentLast,
|
|
28
32
|
isParentBlock,
|
|
@@ -37,16 +41,25 @@ const shouldBreakline = satisfy([
|
|
|
37
41
|
]);
|
|
38
42
|
|
|
39
43
|
module.exports.ExpressionStatement = {
|
|
44
|
+
beforeIf(path) {
|
|
45
|
+
if (isInsideReturn(path))
|
|
46
|
+
return false;
|
|
47
|
+
|
|
48
|
+
return !isInsideLabel(path);
|
|
49
|
+
},
|
|
50
|
+
before(path, {indent}) {
|
|
51
|
+
indent();
|
|
52
|
+
},
|
|
40
53
|
print(path, {print, maybe, store}) {
|
|
41
|
-
|
|
54
|
+
const insideReturn = isInsideReturn(path);
|
|
42
55
|
|
|
43
56
|
print('__expression');
|
|
44
|
-
print(';');
|
|
57
|
+
maybe.print(!insideReturn, ';');
|
|
45
58
|
|
|
46
59
|
if (!isNext(path))
|
|
47
60
|
return;
|
|
48
61
|
|
|
49
|
-
if (shouldBreakline(path)) {
|
|
62
|
+
if (!insideReturn && shouldBreakline(path)) {
|
|
50
63
|
print.newline();
|
|
51
64
|
maybe.indent(isNext(path) && noTrailingComment(path));
|
|
52
65
|
store(true);
|
|
@@ -71,8 +84,10 @@ module.exports.ExpressionStatement = {
|
|
|
71
84
|
if (isTopParentLast(path))
|
|
72
85
|
return;
|
|
73
86
|
|
|
74
|
-
|
|
75
|
-
|
|
87
|
+
if (notInsideReturn(path)) {
|
|
88
|
+
print.newline();
|
|
89
|
+
maybe.markAfter(store(), path);
|
|
90
|
+
}
|
|
76
91
|
},
|
|
77
92
|
};
|
|
78
93
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {ExpressionStatement} = require('./expression-statement');
|
|
3
|
+
const {ExpressionStatement} = require('./expression-statement/expression-statement');
|
|
4
4
|
const {VariableDeclaration} = require('./variable-declaration/variable-declaration');
|
|
5
5
|
const {IfStatement} = require('./if-statement/if-statement');
|
|
6
6
|
const {ForOfStatement} = require('./for-of-statement/for-of-statement');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.3.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",
|
|
@@ -50,6 +50,14 @@
|
|
|
50
50
|
"traverse",
|
|
51
51
|
"generate"
|
|
52
52
|
],
|
|
53
|
+
"imports": {
|
|
54
|
+
"#test/printer": {
|
|
55
|
+
"default": "./test/printer.js"
|
|
56
|
+
},
|
|
57
|
+
"#test/fixture": {
|
|
58
|
+
"default": "./test/fixture.js"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
53
61
|
"devDependencies": {
|
|
54
62
|
"@putout/eslint": "^3.5.0",
|
|
55
63
|
"@putout/plugin-minify": "^9.0.0",
|