@putout/plugin-printer 8.6.2 → 8.6.3
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.
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
1
2
|
import {operator, types} from 'putout';
|
|
3
|
+
import {createTypeChecker} from '@putout/printer/type-checker';
|
|
2
4
|
|
|
3
5
|
const {
|
|
4
|
-
isStringLiteral,
|
|
5
6
|
isArrayExpression,
|
|
6
7
|
isIdentifier,
|
|
7
8
|
isCallExpression,
|
|
@@ -10,6 +11,7 @@ const {
|
|
|
10
11
|
} = types;
|
|
11
12
|
|
|
12
13
|
const {replaceWith} = operator;
|
|
14
|
+
const instrument = process.env.PUTOUT_INSTRUMENT;
|
|
13
15
|
|
|
14
16
|
export const report = (path) => {
|
|
15
17
|
return `Add missing tuple around: ${path}`;
|
|
@@ -48,18 +50,36 @@ export const traverse = ({push}) => ({
|
|
|
48
50
|
},
|
|
49
51
|
});
|
|
50
52
|
|
|
53
|
+
const hasResult = (value) => /^[+-]/.test(value);
|
|
54
|
+
|
|
55
|
+
const isDsl = createTypeChecker([
|
|
56
|
+
['-: -> !StringLiteral'],
|
|
57
|
+
['+: node.value ->', hasResult],
|
|
58
|
+
], {
|
|
59
|
+
instrument,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const isSimple = createTypeChecker([
|
|
63
|
+
'Identifier',
|
|
64
|
+
'CallExpression',
|
|
65
|
+
['-: -> !StringLiteral'],
|
|
66
|
+
['+: node.value ->!', hasResult],
|
|
67
|
+
], {
|
|
68
|
+
instrument,
|
|
69
|
+
});
|
|
70
|
+
|
|
51
71
|
function isConsistent(elements) {
|
|
52
72
|
const arraysCount = elements.filter(isArrayExpression).length;
|
|
53
73
|
|
|
54
74
|
if (elements.length === arraysCount)
|
|
55
75
|
return true;
|
|
56
76
|
|
|
57
|
-
const
|
|
77
|
+
const simplesCount = elements.filter(isSimple).length;
|
|
58
78
|
|
|
59
|
-
if (elements.length ===
|
|
79
|
+
if (elements.length === simplesCount)
|
|
60
80
|
return true;
|
|
61
81
|
|
|
62
|
-
const
|
|
82
|
+
const dslCount = elements.filter(isDsl).length;
|
|
63
83
|
|
|
64
|
-
return elements.length ===
|
|
84
|
+
return elements.length === dslCount;
|
|
65
85
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-printer",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout plugin adds support of transformations for @putout/printer",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"superc8": "^12.0.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"putout": ">=42"
|
|
51
|
+
"putout": ">=42",
|
|
52
|
+
"@putout/printer": ">=18"
|
|
52
53
|
},
|
|
53
54
|
"license": "MIT",
|
|
54
55
|
"engines": {
|