@putout/plugin-printer 8.7.1 → 8.7.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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {types} from 'putout';
|
|
2
2
|
|
|
3
|
+
const addQuotes = (a) => `'${a}'`;
|
|
3
4
|
const {
|
|
4
5
|
isIdentifier,
|
|
5
6
|
isCallExpression,
|
|
@@ -11,12 +12,30 @@ const ARROW_LENGTH = ARROW.length;
|
|
|
11
12
|
const ARROW_NOT_LENGTH = ARROW_NOT.length;
|
|
12
13
|
const NOT = '!';
|
|
13
14
|
|
|
14
|
-
const
|
|
15
|
+
const TYPES_EXISTS = new Set([
|
|
15
16
|
'CommentBlock',
|
|
16
17
|
]);
|
|
17
18
|
|
|
19
|
+
const TYPES_NOT_EXISTS = new Set([
|
|
20
|
+
'ExportDeclaration',
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
const INSTEAD = new Map([
|
|
24
|
+
['ExportDeclaration', [
|
|
25
|
+
'ExportAllDeclaration',
|
|
26
|
+
'ExportDefaultDeclaration',
|
|
27
|
+
'ExportNamedDeclaration',
|
|
28
|
+
]],
|
|
29
|
+
]);
|
|
30
|
+
|
|
18
31
|
export const report = ({type}) => {
|
|
19
|
-
|
|
32
|
+
if (!INSTEAD.has(type))
|
|
33
|
+
return `Unknown type detected: '${type}'`;
|
|
34
|
+
|
|
35
|
+
const instead = INSTEAD.get(type).map(addQuotes)
|
|
36
|
+
.join(', ');
|
|
37
|
+
|
|
38
|
+
return `Unknown type detected: '${type}'. Use ${instead} instead`;
|
|
20
39
|
};
|
|
21
40
|
|
|
22
41
|
export const fix = () => {};
|
|
@@ -72,8 +91,11 @@ export const traverse = ({push}) => ({
|
|
|
72
91
|
});
|
|
73
92
|
|
|
74
93
|
function isExists(type) {
|
|
94
|
+
if (TYPES_NOT_EXISTS.has(type))
|
|
95
|
+
return false;
|
|
96
|
+
|
|
75
97
|
if (types[`is${type}`])
|
|
76
98
|
return true;
|
|
77
99
|
|
|
78
|
-
return
|
|
100
|
+
return TYPES_EXISTS.has(type);
|
|
79
101
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-printer",
|
|
3
|
-
"version": "8.7.
|
|
3
|
+
"version": "8.7.2",
|
|
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",
|