@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 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
@@ -3,7 +3,7 @@
3
3
  const {
4
4
  isCallExpression,
5
5
  isIdentifier,
6
- } = require('@babel/types');
6
+ } = require('@putout/babel').types;
7
7
 
8
8
  const {isJSON} = require('@putout/processor-json/is-json');
9
9
  const {assign} = Object;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const {hasTrailingComment} = require('../is');
4
- const {isVariableDeclarator} = require('@babel/types');
4
+ const {isVariableDeclarator} = require('@putout/babel').types;
5
5
 
6
6
  const {markBefore} = require('../mark');
7
7
  const {maybeInsideFn} = require('./maybe-inside-fn');
@@ -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;
@@ -17,7 +17,7 @@ const {
17
17
  const {
18
18
  isObjectExpression,
19
19
  isStringLiteral,
20
- } = require('@babel/types');
20
+ } = require('@putout/babel').types;
21
21
 
22
22
  const isNextObject = (a) => a.getNextSibling().isObjectExpression();
23
23
 
@@ -12,7 +12,7 @@ const {
12
12
  isNullLiteral,
13
13
  isStringLiteral,
14
14
  isSpreadElement,
15
- } = require('@babel/types');
15
+ } = require('@putout/babel').types;
16
16
 
17
17
  const {
18
18
  isStringAndMember,
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const {isObjectPattern} = require('@babel/types');
3
+ const {isObjectPattern} = require('@putout/babel').types;
4
4
  const {isParens} = require('./unary-expression/parens');
5
5
 
6
6
  module.exports.AssignmentExpression = {
@@ -4,7 +4,7 @@ const {
4
4
  isStringLiteral,
5
5
  isTemplateLiteral,
6
6
  isBinaryExpression,
7
- } = require('@babel/types');
7
+ } = require('@putout/babel').types;
8
8
 
9
9
  const isStringLike = (a) => {
10
10
  if (isStringLiteral(a))
@@ -5,7 +5,7 @@ const {
5
5
  isArrowFunctionExpression,
6
6
  isLogicalExpression,
7
7
  isIfStatement,
8
- } = require('@babel/types');
8
+ } = require('@putout/babel').types;
9
9
 
10
10
  const {chain} = require('./chain');
11
11
  const {satisfy} = require('../../is');
@@ -4,7 +4,7 @@ const {
4
4
  isIdentifier,
5
5
  isObjectPattern,
6
6
  isAssignmentPattern,
7
- } = require('@babel/types');
7
+ } = require('@putout/babel').types;
8
8
 
9
9
  const {wrongShorthand} = require('./wrong-shortand');
10
10
 
@@ -9,7 +9,7 @@ const {
9
9
  isVariableDeclaration,
10
10
  isMemberExpression,
11
11
  isArrayExpression,
12
- } = require('@babel/types');
12
+ } = require('@putout/babel').types;
13
13
 
14
14
  const isParentProgram = (path) => path.parentPath?.isProgram();
15
15
  const isParentBlock = (path) => path.parentPath.isBlockStatement();
@@ -10,7 +10,7 @@ const {
10
10
  ExpressionStatement,
11
11
  Program,
12
12
  isStatement,
13
- } = require('@babel/types');
13
+ } = require('@putout/babel').types;
14
14
 
15
15
  const isFn = (a) => typeof a === 'function';
16
16
 
@@ -10,7 +10,7 @@ const {
10
10
  const {
11
11
  isArrowFunctionExpression,
12
12
  isObjectMethod,
13
- } = require('@babel/types');
13
+ } = require('@putout/babel').types;
14
14
 
15
15
  const {markAfter} = require('../../mark');
16
16
  const {parseComments} = require('../../comment/comment');
@@ -8,7 +8,7 @@ const {
8
8
  } = require('../../is');
9
9
 
10
10
  const {markAfter, isMarkedAfter} = require('../../mark');
11
- const {isExportNamespaceSpecifier} = require('@babel/types');
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/types');
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');
@@ -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/traverse').default;
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');
@@ -4,7 +4,7 @@ const {isNext, isNextParent} = require('../../is');
4
4
  const {
5
5
  isTSTypeAliasDeclaration,
6
6
  isExportDeclaration,
7
- } = require('@babel/types');
7
+ } = require('@putout/babel').types;
8
8
 
9
9
  module.exports.TSInterfaceDeclaration = {
10
10
  print(path, {print}) {
@@ -1,33 +1,47 @@
1
1
  'use strict';
2
2
 
3
- module.exports.TSMappedType = (path, {print, write, indent, maybe}) => {
4
- const {readonly, optional} = path.node;
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
- write('{');
7
- write.newline();
13
+ print('{');
14
+ print.newline();
8
15
  indent.inc();
9
16
  indent();
10
17
 
11
18
  if (readonly) {
12
- maybe.write(readonly === '-', '-');
13
- write('readonly ');
19
+ maybe.print(readonly === '-', '-');
20
+ print('readonly ');
14
21
  }
15
22
 
16
- write('[');
23
+ print('[');
17
24
  print('__typeParameter');
18
- write(']');
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.write(optional === '+', '+');
22
- maybe.write(optional === '-', '-');
23
- write('?');
35
+ maybe.print(optional === '+', '+');
36
+ maybe.print(optional === '-', '-');
37
+ print('?');
24
38
  }
25
39
 
26
- write(':');
27
- write.space();
40
+ print(':');
41
+ print.space();
28
42
  print('__typeAnnotation');
29
- write(';');
43
+ print(';');
30
44
  indent.dec();
31
- write.newline();
32
- write('}');
45
+ print.breakline();
46
+ print('}');
33
47
  };
@@ -23,8 +23,8 @@ module.exports.TSTypeLiteral = (path, {indent, traverse, write, maybe}) => {
23
23
  }
24
24
 
25
25
  if (is) {
26
- write.newline();
27
26
  indent.dec();
27
+ write.breakline();
28
28
  }
29
29
 
30
30
  write('}');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "4.1.0",
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/code-frame": "^7.18.6",
30
- "@babel/parser": "^7.19.0",
31
- "@babel/traverse": "^7.21.2",
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": "^12.0.0",
55
- "@putout/plugin-react-hook-form": "^3.4.1",
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": "^6.0.0",
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": "^31.0.3",
66
+ "putout": "^32.0.4",
70
67
  "supertape": "^8.0.0",
71
68
  "try-catch": "^3.0.0"
72
69
  },