@putout/printer 6.3.0 → 6.4.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 +5 -0
- package/lib/json.js +3 -11
- package/lib/tokenize/debug.js +1 -2
- package/lib/tokenize/expressions/array-expression/array-expression.js +1 -2
- package/lib/tokenize/expressions/binary-expression/concatanate.js +1 -2
- package/lib/tokenize/expressions/call-expression.js +1 -2
- package/lib/tokenize/expressions/class/class.js +1 -2
- package/lib/tokenize/expressions/member-expression/chain.js +1 -2
- package/lib/tokenize/expressions/member-expression/member-expressions.js +1 -2
- package/lib/tokenize/maybe/index.js +2 -4
- package/lib/tokenize/maybe/maybe-decorators.js +1 -2
- package/lib/tokenize/statements/block-statement/block-statement.js +1 -2
- package/lib/tokenize/statements/export-declaration/export-declaration.js +1 -2
- package/lib/tokenize/statements/expression-statement.js +2 -4
- package/lib/tokenize/statements/if-statement/if-statement.js +1 -2
- package/lib/tokenize/tokenize.js +1 -2
- package/lib/tokenize/typescript/type/ts-type-parameter.js +2 -3
- package/package.json +2 -3
package/ChangeLog
CHANGED
package/lib/json.js
CHANGED
|
@@ -5,11 +5,10 @@ const {
|
|
|
5
5
|
isIdentifier,
|
|
6
6
|
} = require('@putout/babel').types;
|
|
7
7
|
|
|
8
|
-
const {isJSON} = require('@putout/
|
|
9
|
-
const {isFilesystem} = require('@putout/processor-filesystem/is-filesystem');
|
|
8
|
+
const {isJSON} = require('@putout/operator-json');
|
|
10
9
|
|
|
11
10
|
module.exports.maybeJSON = (ast, overrides) => {
|
|
12
|
-
if (isASTJSON(ast))
|
|
11
|
+
if (isASTJSON(ast))
|
|
13
12
|
return {
|
|
14
13
|
...overrides,
|
|
15
14
|
format: {
|
|
@@ -22,7 +21,6 @@ module.exports.maybeJSON = (ast, overrides) => {
|
|
|
22
21
|
encodeSingleQuote: false,
|
|
23
22
|
},
|
|
24
23
|
};
|
|
25
|
-
}
|
|
26
24
|
|
|
27
25
|
return overrides;
|
|
28
26
|
};
|
|
@@ -48,11 +46,5 @@ function isASTJSON(ast) {
|
|
|
48
46
|
if (!isIdentifier(callee))
|
|
49
47
|
return false;
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (isJSON(name))
|
|
54
|
-
return true;
|
|
55
|
-
|
|
56
|
-
if (isFilesystem(name))
|
|
57
|
-
return true;
|
|
49
|
+
return isJSON(callee.name);
|
|
58
50
|
}
|
package/lib/tokenize/debug.js
CHANGED
|
@@ -65,9 +65,8 @@ module.exports.ArrayExpression = {
|
|
|
65
65
|
|
|
66
66
|
const indented = !isTwoLongStrings(elements) || !isInsideArray(path) && isIndented(elements[0]);
|
|
67
67
|
|
|
68
|
-
if (indented)
|
|
68
|
+
if (indented)
|
|
69
69
|
maybe.indent.inc(shouldIncreaseIndent);
|
|
70
|
-
}
|
|
71
70
|
|
|
72
71
|
const isNewLine = isNewlineBetweenElements(path, {
|
|
73
72
|
elements,
|
|
@@ -36,9 +36,8 @@ function CallExpression(path, {indent, print, maybe, traverse}) {
|
|
|
36
36
|
for (const [i, arg] of args.entries()) {
|
|
37
37
|
const isObject = arg.isObjectExpression();
|
|
38
38
|
|
|
39
|
-
if (isParentCall && !isObject && n)
|
|
39
|
+
if (isParentCall && !isObject && n)
|
|
40
40
|
print.breakline();
|
|
41
|
-
}
|
|
42
41
|
|
|
43
42
|
print(arg);
|
|
44
43
|
|
|
@@ -64,12 +64,11 @@ function build(path) {
|
|
|
64
64
|
type: path.type,
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
if (path.isCallExpression())
|
|
67
|
+
if (path.isCallExpression())
|
|
68
68
|
assign(prop, {
|
|
69
69
|
args: path.node.arguments.length,
|
|
70
70
|
name: path.node.callee.property?.name || '',
|
|
71
71
|
});
|
|
72
|
-
}
|
|
73
72
|
|
|
74
73
|
return prop;
|
|
75
74
|
}
|
|
@@ -50,13 +50,11 @@ function objectPlugin(plugin, path, printer, options) {
|
|
|
50
50
|
afterIf = condition,
|
|
51
51
|
} = maybeSatisfy(plugin);
|
|
52
52
|
|
|
53
|
-
if (beforeIf?.(path, printer))
|
|
53
|
+
if (beforeIf?.(path, printer))
|
|
54
54
|
before(path, printer);
|
|
55
|
-
}
|
|
56
55
|
|
|
57
56
|
print(path, printer, options);
|
|
58
57
|
|
|
59
|
-
if (afterIf?.(path, printer))
|
|
58
|
+
if (afterIf?.(path, printer))
|
|
60
59
|
after(path, printer);
|
|
61
|
-
}
|
|
62
60
|
}
|
|
@@ -18,13 +18,12 @@ module.exports.maybeDecorators = (visitor) => (path, printer, semantics, options
|
|
|
18
18
|
|
|
19
19
|
const {decorators} = path.node;
|
|
20
20
|
|
|
21
|
-
if (decorators)
|
|
21
|
+
if (decorators)
|
|
22
22
|
for (const decorator of path.get('decorators')) {
|
|
23
23
|
maybe.write.breakline(isPrevClassProperty(path));
|
|
24
24
|
traverse(decorator);
|
|
25
25
|
write.breakline();
|
|
26
26
|
}
|
|
27
|
-
}
|
|
28
27
|
|
|
29
28
|
visitor(path, printer, semantics, options);
|
|
30
29
|
};
|
|
@@ -75,9 +75,8 @@ module.exports.ExportNamedDeclaration = {
|
|
|
75
75
|
maybe.write(isType, 'type ');
|
|
76
76
|
traverse(spec);
|
|
77
77
|
|
|
78
|
-
if (i < lastIndex && !isNewline)
|
|
78
|
+
if (i < lastIndex && !isNewline)
|
|
79
79
|
write(', ');
|
|
80
|
-
}
|
|
81
80
|
|
|
82
81
|
maybe.write(isNewline, ',');
|
|
83
82
|
maybe.write.newline(isNewline);
|
|
@@ -61,13 +61,11 @@ module.exports.ExpressionStatement = {
|
|
|
61
61
|
return isBeforeElse(path);
|
|
62
62
|
},
|
|
63
63
|
after(path, {print, maybe, store}) {
|
|
64
|
-
if (hasTrailingComment(path) && isLast(path) && isCoupleLines(path))
|
|
64
|
+
if (hasTrailingComment(path) && isLast(path) && isCoupleLines(path))
|
|
65
65
|
print.breakline();
|
|
66
|
-
}
|
|
67
66
|
|
|
68
|
-
if (hasTrailingComment(path) && !isCoupleLines(path))
|
|
67
|
+
if (hasTrailingComment(path) && !isCoupleLines(path))
|
|
69
68
|
return;
|
|
70
|
-
}
|
|
71
69
|
|
|
72
70
|
print.newline();
|
|
73
71
|
maybe.markAfter(store(), path);
|
|
@@ -38,9 +38,8 @@ module.exports.IfStatement = {
|
|
|
38
38
|
print.space();
|
|
39
39
|
print(consequent);
|
|
40
40
|
|
|
41
|
-
if (isInsideIf(path) || isInsideNestedBody(path))
|
|
41
|
+
if (isInsideIf(path) || isInsideNestedBody(path))
|
|
42
42
|
maybe.print.newline(isEmptyBody(consequent));
|
|
43
|
-
}
|
|
44
43
|
} else {
|
|
45
44
|
const is = !isEmptyConsequent(path);
|
|
46
45
|
maybe.print.newline(is);
|
package/lib/tokenize/tokenize.js
CHANGED
|
@@ -268,9 +268,8 @@ const createPrint = (path, {traverse, write}) => (maybeLine) => {
|
|
|
268
268
|
};
|
|
269
269
|
|
|
270
270
|
const computePath = (path, maybeLine) => {
|
|
271
|
-
if (isString(maybeLine) && maybeLine.startsWith(GET))
|
|
271
|
+
if (isString(maybeLine) && maybeLine.startsWith(GET))
|
|
272
272
|
return get(path, maybeLine);
|
|
273
|
-
}
|
|
274
273
|
|
|
275
274
|
if (isObject(maybeLine))
|
|
276
275
|
return maybeLine;
|
|
@@ -17,11 +17,10 @@ module.exports.TSTypeParameter = (path, {write, traverse}) => {
|
|
|
17
17
|
if (!exists(constraint))
|
|
18
18
|
return;
|
|
19
19
|
|
|
20
|
-
if (constraint.isTSTypeOperator() || path.parentPath.isTSMappedType())
|
|
20
|
+
if (constraint.isTSTypeOperator() || path.parentPath.isTSMappedType())
|
|
21
21
|
write(' in ');
|
|
22
|
-
|
|
22
|
+
else
|
|
23
23
|
write(' extends ');
|
|
24
|
-
}
|
|
25
24
|
|
|
26
25
|
traverse(constraint);
|
|
27
26
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.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",
|
|
@@ -30,8 +30,7 @@
|
|
|
30
30
|
"@putout/babel": "^1.1.1",
|
|
31
31
|
"@putout/compare": "^13.0.0",
|
|
32
32
|
"@putout/operate": "^11.0.0",
|
|
33
|
-
"@putout/
|
|
34
|
-
"@putout/processor-json": "^7.0.0",
|
|
33
|
+
"@putout/operator-json": "^1.2.0",
|
|
35
34
|
"fullstore": "^3.0.0",
|
|
36
35
|
"just-snake-case": "^3.2.0",
|
|
37
36
|
"parse-import-specifiers": "^1.0.1",
|