@putout/printer 18.3.2 → 18.3.4
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 +10 -0
- package/lib/tokenize/expressions/function/object-method.js +12 -1
- package/lib/tokenize/statements/block-statement/block-statement-newline.js +1 -0
- package/lib/tokenize/statements/block-statement/block-statement.js +1 -11
- package/lib/tokenize/type-checker/type-checker.js +5 -5
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
isNewlineBetweenSiblings,
|
|
3
|
+
isNext,
|
|
4
|
+
} from '#is';
|
|
2
5
|
import {printParams} from '#print-params';
|
|
6
|
+
import {markAfter} from '#mark';
|
|
3
7
|
import {printKey} from '../object-expression/print-key.js';
|
|
4
8
|
import {printKind} from './kind.js';
|
|
5
9
|
|
|
@@ -11,6 +15,7 @@ export const ObjectMethod = {
|
|
|
11
15
|
write('async ');
|
|
12
16
|
},
|
|
13
17
|
print(path, printer, semantics) {
|
|
18
|
+
const {trailingComma} = semantics;
|
|
14
19
|
const {print} = printer;
|
|
15
20
|
|
|
16
21
|
printKind(path, printer);
|
|
@@ -19,6 +24,12 @@ export const ObjectMethod = {
|
|
|
19
24
|
|
|
20
25
|
print.space();
|
|
21
26
|
print('__body');
|
|
27
|
+
|
|
28
|
+
if (isNext(path) || trailingComma)
|
|
29
|
+
print(',');
|
|
30
|
+
|
|
31
|
+
print.newline();
|
|
32
|
+
markAfter(path);
|
|
22
33
|
},
|
|
23
34
|
afterIf(path) {
|
|
24
35
|
return isNewlineBetweenSiblings(path);
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import {types} from '@putout/babel';
|
|
2
2
|
import {markAfter} from '#mark';
|
|
3
|
-
import {isNext} from '#is';
|
|
4
3
|
import {parseComments} from '../../comment/comment.js';
|
|
5
4
|
import {getDirectives} from './get-directives.js';
|
|
6
5
|
import {isCallInsideChain} from './is-call-inside-chain.js';
|
|
7
6
|
import {shouldAddNewlineAfter} from './block-statement-newline.js';
|
|
8
7
|
|
|
9
|
-
const {
|
|
10
|
-
isObjectMethod,
|
|
11
|
-
isArrayExpression,
|
|
12
|
-
} = types;
|
|
8
|
+
const {isArrayExpression} = types;
|
|
13
9
|
|
|
14
10
|
const isFirstStatement = (path) => path.node.body[0];
|
|
15
11
|
const isFirstDirective = (path) => path.node.directives?.[0];
|
|
@@ -27,7 +23,6 @@ const isInsideArrayTupleOfThree = (path) => {
|
|
|
27
23
|
|
|
28
24
|
export const BlockStatement = {
|
|
29
25
|
print(path, printer, semantics) {
|
|
30
|
-
const {trailingComma} = semantics;
|
|
31
26
|
const {
|
|
32
27
|
indent,
|
|
33
28
|
maybe,
|
|
@@ -70,11 +65,6 @@ export const BlockStatement = {
|
|
|
70
65
|
write('}');
|
|
71
66
|
|
|
72
67
|
maybe.indent.dec(callInsideChain);
|
|
73
|
-
|
|
74
|
-
const {parentPath} = path;
|
|
75
|
-
|
|
76
|
-
if (isObjectMethod(parentPath))
|
|
77
|
-
maybe.write(isNext(parentPath) || trailingComma, ',');
|
|
78
68
|
},
|
|
79
69
|
afterIf: shouldAddNewlineAfter,
|
|
80
70
|
after(path, {write}) {
|
|
@@ -16,13 +16,13 @@ export const createTypeChecker = (typeNames, overrides = {}) => {
|
|
|
16
16
|
} = overrides;
|
|
17
17
|
|
|
18
18
|
const tuples = parseTypeNames(typeNames);
|
|
19
|
-
const checkers =
|
|
20
|
-
const results =
|
|
19
|
+
const checkers = new Set();
|
|
20
|
+
const results = new Set();
|
|
21
21
|
|
|
22
22
|
for (const [operation, typeName] of tuples) {
|
|
23
23
|
const [result, selector, not] = parseOperation(operation);
|
|
24
|
-
results.
|
|
25
|
-
checkers.
|
|
24
|
+
results.add(result);
|
|
25
|
+
checkers.add({
|
|
26
26
|
result,
|
|
27
27
|
selector,
|
|
28
28
|
not,
|
|
@@ -56,6 +56,6 @@ export const createTypeChecker = (typeNames, overrides = {}) => {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
function validateResults(results) {
|
|
59
|
-
if (!results.
|
|
59
|
+
if (!results.has(true))
|
|
60
60
|
throw Error(`☝️Looks like type checker missing successful route ('+'), it will always fail`);
|
|
61
61
|
}
|
package/package.json
CHANGED