@putout/printer 4.1.0 → 5.0.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 +17 -0
- package/README.md +9 -2
- package/lib/json.js +1 -1
- package/lib/tokenize/comment/parse-leading-comments.js +1 -1
- package/lib/tokenize/debug.js +2 -2
- package/lib/tokenize/expressions/array-expression/array-expression.js +1 -1
- package/lib/tokenize/expressions/array-expression/new-line.js +1 -1
- package/lib/tokenize/expressions/assignment-expression.js +1 -1
- package/lib/tokenize/expressions/binary-expression/concatanate.js +1 -1
- package/lib/tokenize/expressions/member-expression/member-expressions.js +1 -1
- package/lib/tokenize/expressions/object-pattern/object-pattern.js +1 -1
- package/lib/tokenize/is.js +1 -1
- package/lib/tokenize/maybe/index.js +1 -1
- package/lib/tokenize/statements/block-statement/block-statement.js +1 -1
- package/lib/tokenize/statements/export-declaration/export-declaration.js +1 -1
- package/lib/tokenize/statements/variable-declaration/variable-declaration.js +1 -1
- package/lib/tokenize/tokenize.js +1 -1
- package/lib/tokenize/typescript/interface/ts-interface-declaration.js +1 -1
- package/lib/tokenize/typescript/ts-mapped-type.js +30 -16
- package/lib/tokenize/typescript/type/ts-type-literal.js +1 -1
- package/package.json +8 -11
package/ChangeLog
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
2023.09.18, v5.0.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 9ad0e3c package: putout v32.0.4
|
|
5
|
+
- b8e15fc package: estree-to-babel v7.0.0
|
|
6
|
+
- ebcf3aa package: @putout/plugin-react-hook-form v4.0.0
|
|
7
|
+
- efbf8e8 package: @putout/plugin-promises v13.0.0
|
|
8
|
+
- 7ebee8a package: @putout/operate v11.0.0
|
|
9
|
+
- a40cb80 package: @putout/compare v13.0.0
|
|
10
|
+
- 84c933d @putout/printer: TSMappedType: nameType
|
|
11
|
+
|
|
12
|
+
2023.09.13, v4.2.0
|
|
13
|
+
|
|
14
|
+
feature:
|
|
15
|
+
- d5b4479 @putout/printer: babel 7 -> babel 8
|
|
16
|
+
- dd1b24e @putout/printer: typescript: newline -> breakline
|
|
17
|
+
|
|
1
18
|
2023.09.04, v4.1.0
|
|
2
19
|
|
|
3
20
|
feature:
|
package/README.md
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
# Printer [![NPM version][NPMIMGURL]][NPMURL]
|
|
1
|
+
# Printer [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
|
|
2
2
|
|
|
3
|
-
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/printer.svg?style=flat&longCache=true
|
|
4
3
|
[NPMURL]: https://npmjs.org/package/@putout/printer "npm"
|
|
4
|
+
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/printer.svg?style=flat&longCache=true
|
|
5
|
+
[BuildStatusURL]: https://github.com/putoutjs/printer/actions/workflows/nodejs.yml "Build Status"
|
|
6
|
+
[BuildStatusIMGURL]: https://github.com/putoutjs/printer/actions/workflows/nodejs.yml/badge.svg
|
|
7
|
+
[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
|
|
8
|
+
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
|
|
9
|
+
[CoverageURL]: https://coveralls.io/github/putoutjs/printer?branch=master
|
|
10
|
+
[CoverageIMGURL]: https://coveralls.io/repos/putoutjs/printer/badge.svg?branch=master&service=github
|
|
5
11
|
|
|
6
12
|
Prints [**Babel AST**](https://github.com/coderaiser/estree-to-babel) to readable **JavaScript**. For Babel 7 use `@putout/printer` v2.
|
|
7
13
|
|
|
@@ -15,6 +21,7 @@ Supports:
|
|
|
15
21
|
- ✅ **ES2023**;
|
|
16
22
|
- ✅ **JSX**;
|
|
17
23
|
- ✅ **TypeScript**;
|
|
24
|
+
- ✅ [**JSON**](https://github.com/coderaiser/putout/tree/master/packages/processor-json#readme);
|
|
18
25
|
|
|
19
26
|
## Install
|
|
20
27
|
|
package/lib/json.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {hasTrailingComment} = require('../is');
|
|
4
|
-
const {isVariableDeclarator} = require('@babel
|
|
4
|
+
const {isVariableDeclarator} = require('@putout/babel').types;
|
|
5
5
|
|
|
6
6
|
const {markBefore} = require('../mark');
|
|
7
7
|
const {maybeInsideFn} = require('./maybe-inside-fn');
|
package/lib/tokenize/debug.js
CHANGED
|
@@ -4,6 +4,8 @@ const {stringify} = JSON;
|
|
|
4
4
|
const {TYPES} = require('../types');
|
|
5
5
|
const toSnakeCase = require('just-snake-case');
|
|
6
6
|
|
|
7
|
+
const {codeFrameColumns} = require('@putout/babel');
|
|
8
|
+
|
|
7
9
|
const {
|
|
8
10
|
LOG,
|
|
9
11
|
LOG_ALL,
|
|
@@ -12,8 +14,6 @@ const {
|
|
|
12
14
|
DEBUG,
|
|
13
15
|
} = process.env;
|
|
14
16
|
|
|
15
|
-
const {codeFrameColumns} = require('@babel/code-frame');
|
|
16
|
-
|
|
17
17
|
module.exports.createDebug = (tokens) => (a) => {
|
|
18
18
|
if (!DEBUG)
|
|
19
19
|
return;
|
package/lib/tokenize/is.js
CHANGED
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
isVariableDeclaration,
|
|
10
10
|
isMemberExpression,
|
|
11
11
|
isArrayExpression,
|
|
12
|
-
} = require('@babel
|
|
12
|
+
} = require('@putout/babel').types;
|
|
13
13
|
|
|
14
14
|
const isParentProgram = (path) => path.parentPath?.isProgram();
|
|
15
15
|
const isParentBlock = (path) => path.parentPath.isBlockStatement();
|
|
@@ -8,7 +8,7 @@ const {
|
|
|
8
8
|
} = require('../../is');
|
|
9
9
|
|
|
10
10
|
const {markAfter, isMarkedAfter} = require('../../mark');
|
|
11
|
-
const {isExportNamespaceSpecifier} = require('@babel
|
|
11
|
+
const {isExportNamespaceSpecifier} = require('@putout/babel').types;
|
|
12
12
|
const isDeclarationNewline = (path) => isMarkedAfter(path.get('declaration'));
|
|
13
13
|
const isInsideNamespace = (path) => path.parentPath.isTSModuleBlock();
|
|
14
14
|
|
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
} = require('../../is');
|
|
10
10
|
|
|
11
11
|
const {hasPrevNewline} = require('../../mark');
|
|
12
|
-
const {isExportDeclaration} = require('@babel
|
|
12
|
+
const {isExportDeclaration} = require('@putout/babel').types;
|
|
13
13
|
const {maybeSpaceAfterKeyword} = require('./maybe-space-after-keyword');
|
|
14
14
|
|
|
15
15
|
const {isConcatenation} = require('../../expressions/binary-expression/concatanate');
|
package/lib/tokenize/tokenize.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const {round} = Math;
|
|
4
4
|
const fullstore = require('fullstore');
|
|
5
5
|
const isObject = (a) => a && typeof a === 'object';
|
|
6
|
-
const babelTraverse = require('@babel
|
|
6
|
+
const babelTraverse = require('@putout/babel').traverse;
|
|
7
7
|
const expressions = require('./expressions');
|
|
8
8
|
const statements = require('./statements');
|
|
9
9
|
const literals = require('./literals');
|
|
@@ -1,33 +1,47 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const {types} = require('@putout/babel');
|
|
4
|
+
const {isTSConditionalType} = types;
|
|
5
|
+
|
|
6
|
+
module.exports.TSMappedType = (path, {print, indent, maybe}) => {
|
|
7
|
+
const {
|
|
8
|
+
readonly,
|
|
9
|
+
optional,
|
|
10
|
+
nameType,
|
|
11
|
+
} = path.node;
|
|
5
12
|
|
|
6
|
-
|
|
7
|
-
|
|
13
|
+
print('{');
|
|
14
|
+
print.newline();
|
|
8
15
|
indent.inc();
|
|
9
16
|
indent();
|
|
10
17
|
|
|
11
18
|
if (readonly) {
|
|
12
|
-
maybe.
|
|
13
|
-
|
|
19
|
+
maybe.print(readonly === '-', '-');
|
|
20
|
+
print('readonly ');
|
|
14
21
|
}
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
print('[');
|
|
17
24
|
print('__typeParameter');
|
|
18
|
-
|
|
25
|
+
|
|
26
|
+
if (nameType) {
|
|
27
|
+
print(' as');
|
|
28
|
+
maybe.space(!isTSConditionalType(nameType));
|
|
29
|
+
print('__nameType');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
print(']');
|
|
19
33
|
|
|
20
34
|
if (optional) {
|
|
21
|
-
maybe.
|
|
22
|
-
maybe.
|
|
23
|
-
|
|
35
|
+
maybe.print(optional === '+', '+');
|
|
36
|
+
maybe.print(optional === '-', '-');
|
|
37
|
+
print('?');
|
|
24
38
|
}
|
|
25
39
|
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
print(':');
|
|
41
|
+
print.space();
|
|
28
42
|
print('__typeAnnotation');
|
|
29
|
-
|
|
43
|
+
print(';');
|
|
30
44
|
indent.dec();
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
print.breakline();
|
|
46
|
+
print('}');
|
|
33
47
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.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",
|
|
@@ -26,12 +26,9 @@
|
|
|
26
26
|
"report": "madrun report"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@babel/types": "^7.21.3",
|
|
33
|
-
"@putout/compare": "^12.0.4",
|
|
34
|
-
"@putout/operate": "^10.0.2",
|
|
29
|
+
"@putout/babel": "^1.1.1",
|
|
30
|
+
"@putout/compare": "^13.0.0",
|
|
31
|
+
"@putout/operate": "^11.0.0",
|
|
35
32
|
"@putout/processor-json": "^7.0.0",
|
|
36
33
|
"fullstore": "^3.0.0",
|
|
37
34
|
"just-snake-case": "^3.2.0",
|
|
@@ -51,8 +48,8 @@
|
|
|
51
48
|
"@babel/plugin-codemod-object-assign-to-object-spread": "^7.10.4",
|
|
52
49
|
"@putout/plugin-minify": "^4.0.0",
|
|
53
50
|
"@putout/plugin-printer": "^2.0.0",
|
|
54
|
-
"@putout/plugin-promises": "^
|
|
55
|
-
"@putout/plugin-react-hook-form": "^
|
|
51
|
+
"@putout/plugin-promises": "^13.0.0",
|
|
52
|
+
"@putout/plugin-react-hook-form": "^4.0.0",
|
|
56
53
|
"@putout/plugin-react-hooks": "^5.0.0",
|
|
57
54
|
"acorn": "^8.8.2",
|
|
58
55
|
"c8": "^8.0.0",
|
|
@@ -60,13 +57,13 @@
|
|
|
60
57
|
"eslint": "^8.0.1",
|
|
61
58
|
"eslint-plugin-n": "^16.0.0",
|
|
62
59
|
"eslint-plugin-putout": "^19.0.2",
|
|
63
|
-
"estree-to-babel": "^
|
|
60
|
+
"estree-to-babel": "^7.0.0",
|
|
64
61
|
"just-kebab-case": "^4.2.0",
|
|
65
62
|
"madrun": "^9.0.0",
|
|
66
63
|
"mock-require": "^3.0.3",
|
|
67
64
|
"montag": "^1.0.0",
|
|
68
65
|
"nodemon": "^3.0.1",
|
|
69
|
-
"putout": "^
|
|
66
|
+
"putout": "^32.0.4",
|
|
70
67
|
"supertape": "^8.0.0",
|
|
71
68
|
"try-catch": "^3.0.0"
|
|
72
69
|
},
|