@putout/printer 1.52.0 → 1.52.2
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
|
+
2023.04.17, v1.52.2
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- ef0ef15 @putout/printer: maybe
|
|
5
|
+
- beb210c @putout/printer: ExpressionStatement: apply satisfy
|
|
6
|
+
|
|
7
|
+
2023.04.17, v1.52.1
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- cf83bcb @putout/printer: move out satisfy
|
|
11
|
+
|
|
1
12
|
2023.04.17, v1.52.0
|
|
2
13
|
|
|
3
14
|
feature:
|
package/lib/tokenize/is.js
CHANGED
|
@@ -76,3 +76,12 @@ module.exports.isNewlineBetweenStatements = (path) => {
|
|
|
76
76
|
|
|
77
77
|
return startNext - endCurrent > 1;
|
|
78
78
|
};
|
|
79
|
+
|
|
80
|
+
module.exports.satisfy = (conditions) => (path) => {
|
|
81
|
+
for (const condition of conditions) {
|
|
82
|
+
if (condition(path))
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return false;
|
|
87
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const {satisfy} = require('../is');
|
|
4
|
+
|
|
3
5
|
module.exports = (plugin) => {
|
|
4
6
|
if (!plugin.afterSatisfy && !plugin.beforeSatisfy)
|
|
5
7
|
return plugin;
|
|
@@ -11,13 +13,7 @@ module.exports = (plugin) => {
|
|
|
11
13
|
};
|
|
12
14
|
};
|
|
13
15
|
|
|
14
|
-
const createIf = (getConditions) =>
|
|
16
|
+
const createIf = (getConditions) => {
|
|
15
17
|
const conditions = getConditions?.() || [];
|
|
16
|
-
|
|
17
|
-
for (const condition of conditions) {
|
|
18
|
-
if (condition(path))
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return false;
|
|
18
|
+
return satisfy(conditions);
|
|
23
19
|
};
|
|
@@ -6,8 +6,16 @@ const {
|
|
|
6
6
|
isParentBlock,
|
|
7
7
|
isParentLast,
|
|
8
8
|
isNewlineBetweenStatements,
|
|
9
|
+
satisfy,
|
|
10
|
+
|
|
9
11
|
} = require('../is');
|
|
10
12
|
|
|
13
|
+
const shouldBreakline = satisfy([
|
|
14
|
+
isNewlineBetweenStatements,
|
|
15
|
+
isNotLastBody,
|
|
16
|
+
isStrictMode,
|
|
17
|
+
]);
|
|
18
|
+
|
|
11
19
|
module.exports.ExpressionStatement = {
|
|
12
20
|
print(path, {indent, print, maybe, store}) {
|
|
13
21
|
indent();
|
|
@@ -32,23 +40,14 @@ module.exports.ExpressionStatement = {
|
|
|
32
40
|
},
|
|
33
41
|
};
|
|
34
42
|
|
|
35
|
-
function
|
|
36
|
-
if (isNewlineBetweenStatements(path))
|
|
37
|
-
return true;
|
|
38
|
-
|
|
39
|
-
if (isLast(path) || isParentLast(path))
|
|
40
|
-
return false;
|
|
41
|
-
|
|
43
|
+
function isNotLastBody(path) {
|
|
42
44
|
if (!isNext(path) && isParentBlock(path))
|
|
43
45
|
return false;
|
|
44
46
|
|
|
45
|
-
if (path
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
if (isStrictMode(path))
|
|
49
|
-
return true;
|
|
47
|
+
if (isLast(path) || isParentLast(path))
|
|
48
|
+
return false;
|
|
50
49
|
|
|
51
|
-
return
|
|
50
|
+
return path.parentPath.get('body') === path;
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
function isParentOrNotLastORParentLast(path) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.52.
|
|
3
|
+
"version": "1.52.2",
|
|
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",
|