@putout/printer 1.48.0 → 1.49.1
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
|
+
2023.04.14, v1.49.1
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- 378734f @putout/printer: newline inside in ObjectPattern inside ForOfStatement
|
|
5
|
+
|
|
6
|
+
2023.04.14, v1.49.0
|
|
7
|
+
|
|
8
|
+
fix:
|
|
9
|
+
- b056bb5 @putout/printer: newline in ObjectExpression inside IfStatement
|
|
10
|
+
|
|
1
11
|
2023.04.14, v1.48.0
|
|
2
12
|
|
|
3
13
|
feature:
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
isCoupleLines,
|
|
5
|
+
isForOf,
|
|
6
|
+
isIf,
|
|
7
|
+
} = require('../is');
|
|
8
|
+
|
|
4
9
|
const {isFunction} = require('@babel/types');
|
|
10
|
+
|
|
5
11
|
const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
|
|
6
12
|
const isLogical = (path) => path.get('argument').isLogicalExpression();
|
|
7
13
|
const isValue = (path) => path.get('properties.0.value').node;
|
|
8
|
-
const isIf = (path) => path.parentPath.parentPath.isIfStatement();
|
|
9
14
|
const isParentExpression = (path) => path.parentPath.isExpressionStatement();
|
|
10
15
|
|
|
11
|
-
const isForOf = (path) => {
|
|
12
|
-
if (path.parentPath.isForOfStatement())
|
|
13
|
-
return true;
|
|
14
|
-
|
|
15
|
-
return path.parentPath?.parentPath?.isForOfStatement();
|
|
16
|
-
};
|
|
17
|
-
|
|
18
16
|
module.exports.ObjectExpression = (path, {print, maybe, indent}) => {
|
|
19
17
|
indent.inc();
|
|
20
18
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {isIdentifier} = require('@babel/types');
|
|
4
|
-
const isForOf = (
|
|
4
|
+
const {isForOf} = require('../is');
|
|
5
5
|
|
|
6
6
|
module.exports.ObjectPattern = (path, {indent, print, maybe}) => {
|
|
7
7
|
indent.inc();
|
package/lib/tokenize/is.js
CHANGED
|
@@ -5,6 +5,10 @@ const {isMarkedAfter} = require('./mark');
|
|
|
5
5
|
const {
|
|
6
6
|
isStringLiteral,
|
|
7
7
|
isIdentifier,
|
|
8
|
+
isIfStatement,
|
|
9
|
+
isStatement,
|
|
10
|
+
isForOfStatement,
|
|
11
|
+
isVariableDeclaration,
|
|
8
12
|
} = require('@babel/types');
|
|
9
13
|
|
|
10
14
|
const isParentProgram = (path) => path.parentPath?.isProgram();
|
|
@@ -48,3 +52,22 @@ function isNextCoupleLines(path) {
|
|
|
48
52
|
return isCoupleLines(path.getNextSibling());
|
|
49
53
|
}
|
|
50
54
|
module.exports.isStringAndIdentifier = ([a, b]) => isStringLiteral(a) && isIdentifier(b);
|
|
55
|
+
|
|
56
|
+
const isIfOrStatement = (a) => isIfStatement(a) || isStatement(a);
|
|
57
|
+
const isForOfOrStatement = (a) => isForOfStatement(a) || isStatement(a);
|
|
58
|
+
|
|
59
|
+
module.exports.isIf = (path) => isIfStatement(path.find(
|
|
60
|
+
isIfOrStatement,
|
|
61
|
+
));
|
|
62
|
+
|
|
63
|
+
module.exports.isForOf = (path) => {
|
|
64
|
+
const current = path.find(isForOfOrStatement);
|
|
65
|
+
|
|
66
|
+
if (isForOfStatement(current))
|
|
67
|
+
return true;
|
|
68
|
+
|
|
69
|
+
if (isVariableDeclaration(current))
|
|
70
|
+
return isForOfStatement(current.parentPath);
|
|
71
|
+
|
|
72
|
+
return false;
|
|
73
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.49.1",
|
|
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",
|