@putout/printer 18.4.6 → 18.5.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 +11 -0
- package/lib/tokenize/expressions/array-expression/comma.js +4 -9
- package/lib/tokenize/expressions/binary-expression/is-concatenation.js +1 -3
- package/lib/tokenize/expressions/class/class.js +1 -1
- package/lib/tokenize/expressions/function/params.js +1 -1
- package/lib/tokenize/expressions/object-expression/object-expression.js +1 -1
- package/lib/tokenize/jsx/index.js +1 -1
- package/lib/tokenize/printer/printer.js +4 -4
- package/lib/tokenize/statements/block-statement/block-statement.js +1 -1
- package/lib/tokenize/statements/program/program.js +1 -1
- package/lib/tokenize/statements/switch-statement/switch-statement.js +1 -1
- package/lib/tokenize/statements/variable-declaration/variable-declaration.js +1 -1
- package/lib/tokenize/type-checker/parsers.js +17 -29
- package/lib/tokenize/typescript/interface/ts-interface-body.js +1 -1
- package/package.json +3 -2
- /package/lib/tokenize/{comment → comments}/comments-printer/comments-printer.js +0 -0
- /package/lib/tokenize/{comment/comment.js → comments/comments.js} +0 -0
- /package/lib/tokenize/{comment → comments}/maybe-inside-fn.js +0 -0
- /package/lib/tokenize/{comment → comments}/parse-comments.js +0 -0
- /package/lib/tokenize/{comment → comments}/parse-leading-comments.js +0 -0
- /package/lib/tokenize/{comment → comments}/parse-trailing-comments.js +0 -0
package/ChangeLog
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
2026.03.13, v18.5.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- c797ef4 @putout/printer: type-checker: rm include/exclude
|
|
5
|
+
- 5147c03 @putout/printer: merge-tuples-of-type-checkers
|
|
6
|
+
|
|
7
|
+
2026.03.12, v18.4.7
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- de587ba @putout/printer: private imports: comments
|
|
11
|
+
|
|
1
12
|
2026.03.12, v18.4.6
|
|
2
13
|
|
|
3
14
|
feature:
|
|
@@ -9,12 +9,7 @@ import {
|
|
|
9
9
|
isTrailingCommaOption,
|
|
10
10
|
} from './is.js';
|
|
11
11
|
|
|
12
|
-
const {
|
|
13
|
-
isSpreadElement,
|
|
14
|
-
isCallExpression,
|
|
15
|
-
isObjectExpression,
|
|
16
|
-
isIdentifier,
|
|
17
|
-
} = types;
|
|
12
|
+
const {isObjectExpression} = types;
|
|
18
13
|
|
|
19
14
|
const isCommaAfterElementByOption = createTypeChecker([
|
|
20
15
|
['+: -> !', isLastOption],
|
|
@@ -35,9 +30,9 @@ export const isNewlineAfterComma = createTypeChecker([
|
|
|
35
30
|
|
|
36
31
|
const isSimpleBetweenObjects = createTypeChecker([
|
|
37
32
|
['+', callWithNext(isObjectExpression)],
|
|
38
|
-
['
|
|
39
|
-
['
|
|
40
|
-
['+: -> !'
|
|
33
|
+
['-: SpreadElement'],
|
|
34
|
+
['-: Identifier'],
|
|
35
|
+
['+: -> !CallExpression'],
|
|
41
36
|
]);
|
|
42
37
|
|
|
43
38
|
export const isSpaceAfterComa = createTypeChecker([
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {types} from '@putout/babel';
|
|
2
1
|
import {createTypeChecker} from '#type-checker';
|
|
3
2
|
|
|
4
|
-
const {isBinaryExpression} = types;
|
|
5
3
|
const isPlus = (a) => a === '+';
|
|
6
4
|
|
|
7
5
|
export const isConcatenation = createTypeChecker([
|
|
8
6
|
['-: node.operator -> !', isPlus],
|
|
9
7
|
['-: node.loc', isSameLine],
|
|
10
|
-
['
|
|
8
|
+
['+: BinaryExpression'],
|
|
11
9
|
]);
|
|
12
10
|
|
|
13
11
|
function isSameLine(loc) {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
isInsideExportDeclaration,
|
|
8
8
|
isNext,
|
|
9
9
|
} from '#is';
|
|
10
|
-
import {parseComments} from '
|
|
10
|
+
import {parseComments} from '#comments';
|
|
11
11
|
import {maybeDecorators} from '../../maybe/maybe-decorators.js';
|
|
12
12
|
|
|
13
13
|
const isFunctionLike = (path) => isFunction(path.parentPath.parentPath);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {types} from '@putout/babel';
|
|
2
2
|
import {createTypeChecker} from '#type-checker';
|
|
3
|
+
import {parseComments} from '#comments';
|
|
3
4
|
import {
|
|
4
5
|
isCoupleLines,
|
|
5
6
|
isForOf,
|
|
@@ -10,7 +11,6 @@ import {
|
|
|
10
11
|
isInsideExpression,
|
|
11
12
|
hasTrailingComment,
|
|
12
13
|
} from '#is';
|
|
13
|
-
import {parseComments} from '../../comment/comment.js';
|
|
14
14
|
import {isInsideTuple} from './is-inside-tuple.js';
|
|
15
15
|
import {isLooksLikeChain} from '../member-expression/is-looks-like-chain.js';
|
|
16
16
|
import {isCommaAfterSpread} from './comma.js';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {fullstore} from 'fullstore';
|
|
2
2
|
import {TYPES} from '#types';
|
|
3
3
|
import {maybeMarkAfter} from '#mark';
|
|
4
|
-
import {createDebug, createLog} from './debug.js';
|
|
5
|
-
import * as baseVisitors from '../visitors.js';
|
|
6
|
-
import {maybeVisitor, maybeThrow} from '../maybe/index.js';
|
|
7
4
|
import {
|
|
8
5
|
parseLeadingComments,
|
|
9
6
|
parseTrailingComments,
|
|
10
|
-
} from '
|
|
7
|
+
} from '#comments';
|
|
8
|
+
import {createDebug, createLog} from './debug.js';
|
|
9
|
+
import * as baseVisitors from '../visitors.js';
|
|
10
|
+
import {maybeVisitor, maybeThrow} from '../maybe/index.js';
|
|
11
11
|
import {parseOverrides} from '../overrides/overrides.js';
|
|
12
12
|
import {createIndent} from './indent.js';
|
|
13
13
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {markAfter} from '#mark';
|
|
2
2
|
import {createTypeChecker} from '#type-checker';
|
|
3
3
|
import {isInsideBlock} from '#is';
|
|
4
|
-
import {parseComments} from '
|
|
4
|
+
import {parseComments} from '#comments';
|
|
5
5
|
import {getDirectives} from './get-directives.js';
|
|
6
6
|
import {isCallInsideChain} from './is-call-inside-chain.js';
|
|
7
7
|
import {shouldAddNewlineAfter} from './block-statement-newline.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {hasCoupleTrailingComments} from '#is';
|
|
2
|
-
import {parseComments} from '
|
|
2
|
+
import {parseComments} from '#comments';
|
|
3
3
|
import {getDirectives} from '../block-statement/get-directives.js';
|
|
4
4
|
|
|
5
5
|
export const Program = (path, printer, semantics) => {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
exists,
|
|
4
4
|
isLast,
|
|
5
5
|
} from '#is';
|
|
6
|
-
import {parseLeadingComments} from '
|
|
6
|
+
import {parseLeadingComments} from '#comments';
|
|
7
7
|
import {maybeSpaceAfterKeyword} from '../return-statement/maybe-space-after-keyword.js';
|
|
8
8
|
|
|
9
9
|
export const SwitchStatement = {
|
|
@@ -3,6 +3,7 @@ import {hasPrevNewline} from '#mark';
|
|
|
3
3
|
import {createTypeChecker} from '#type-checker';
|
|
4
4
|
import {isConcatenation} from '#is-concatenation';
|
|
5
5
|
import {maybeDeclare} from '#maybe-declare';
|
|
6
|
+
import {parseLeadingComments} from '#comments';
|
|
6
7
|
import {
|
|
7
8
|
isNext,
|
|
8
9
|
isCoupleLines,
|
|
@@ -19,7 +20,6 @@ import {
|
|
|
19
20
|
callWithParent,
|
|
20
21
|
} from '#is';
|
|
21
22
|
import {maybeSpaceAfterKeyword} from './maybe-space-after-keyword.js';
|
|
22
|
-
import {parseLeadingComments} from '../../comment/comment.js';
|
|
23
23
|
|
|
24
24
|
const {isExportDeclaration} = types;
|
|
25
25
|
|
|
@@ -20,40 +20,28 @@ const parseResult = (a) => a === '+';
|
|
|
20
20
|
export function parseTypeNames(typeNames) {
|
|
21
21
|
const tuples = [];
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const tuple = createTuple(first);
|
|
28
|
-
|
|
29
|
-
tuples.push(tuple);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
23
|
+
for (const typeName of typeNames) {
|
|
24
|
+
if (isArray(typeName) && typeName.length === 1) {
|
|
25
|
+
const [first] = typeName;
|
|
26
|
+
const tuple = createTuple(first);
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
tuples.push(
|
|
28
|
+
tuples.push(tuple);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (isArray(typeName)) {
|
|
33
|
+
tuples.push(typeName);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (isString(typeName) && typeName.includes(' -> ')) {
|
|
38
|
+
const tuple = createTuple(typeName);
|
|
39
|
+
tuples.push(tuple);
|
|
40
|
+
continue;
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
return tuples;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
for (const typeName of typeNames.include) {
|
|
51
43
|
tuples.push(['+', typeName]);
|
|
52
44
|
}
|
|
53
45
|
|
|
54
|
-
for (const typeName of typeNames.exclude) {
|
|
55
|
-
tuples.push(['-', typeName]);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
46
|
return tuples;
|
|
59
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Simplest possible opinionated Babel AST printer for 🐊Putout",
|
|
@@ -70,7 +70,8 @@
|
|
|
70
70
|
"#type-checker": "./lib/tokenize/type-checker/type-checker.js",
|
|
71
71
|
"#type-checker/instrument": "./lib/tokenize/type-checker/instrument.js",
|
|
72
72
|
"#type-checker/report": "./lib/tokenize/type-checker/report.js",
|
|
73
|
-
"#is-concatenation": "./lib/tokenize/expressions/binary-expression/is-concatenation.js"
|
|
73
|
+
"#is-concatenation": "./lib/tokenize/expressions/binary-expression/is-concatenation.js",
|
|
74
|
+
"#comments": "./lib/tokenize/comments/comments.js"
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
77
|
"@babel/parser": "^7.28.5",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|