@putout/printer 11.9.0 → 11.10.1

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,13 @@
1
+ 2024.12.19, v11.10.1
2
+
3
+ feature:
4
+ - 6589deb @putout/printer: @putout/plugin-printer v4.0.0
5
+
6
+ 2024.12.18, v11.10.0
7
+
8
+ feature:
9
+ - 6c06c0c @putout/printer: ExportDeclaration: no specifiers
10
+
1
11
  2024.12.18, v11.9.0
2
12
 
3
13
  fix:
package/lib/json.js CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isCallExpression,
5
6
  isIdentifier,
6
- } = require('@putout/babel').types;
7
-
7
+ } = types;
8
8
  const {isJSON} = require('@putout/operator-json');
9
9
 
10
10
  module.exports.maybeJSON = (ast, overrides) => {
@@ -89,7 +89,11 @@ module.exports.parseLeadingComments = (path, {print, maybe, indent}, semantics)
89
89
  const insideFn = (path.parentPath.isFunction() || path.parentPath.isTSDeclareMethod()) && !path.isTSTypeParameterDeclaration();
90
90
 
91
91
  const propIs = isProperty(path);
92
- const isIndent = isFirst(path) || !looksLikeSwitchCase && !path.isClassMethod() && !insideFn && !propIs;
92
+ const isIndent = isFirst(path)
93
+ || !looksLikeSwitchCase
94
+ && !path.isClassMethod()
95
+ && !insideFn
96
+ && !propIs;
93
97
 
94
98
  for (const {type, value} of leadingComments) {
95
99
  maybe.indent(isIndent);
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isDecorator,
5
6
  isMemberExpression,
6
- } = require('@putout/babel').types;
7
-
7
+ } = types;
8
8
  const {
9
9
  isLast,
10
10
  isCoupleLines,
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const {isSimple} = require('@putout/operate');
4
-
4
+ const {types} = require('@putout/babel');
5
5
  const {
6
6
  isObjectExpression,
7
7
  isArrayExpression,
@@ -12,7 +12,7 @@ const {
12
12
  isNullLiteral,
13
13
  isStringLiteral,
14
14
  isSpreadElement,
15
- } = require('@putout/babel').types;
15
+ } = types;
16
16
 
17
17
  const {
18
18
  isStringAndMember,
@@ -5,10 +5,11 @@ const {
5
5
  maybePrintRightBrace,
6
6
  } = require('./maybe-write-brace');
7
7
 
8
+ const {types} = require('@putout/babel');
8
9
  const {
9
10
  isExpressionStatement,
10
11
  isAssignmentExpression,
11
- } = require('@putout/babel').types;
12
+ } = types;
12
13
 
13
14
  module.exports.AssignmentExpression = (path, printer, semantics) => {
14
15
  const {print} = printer;
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isStringLiteral,
5
6
  isTemplateLiteral,
6
7
  isBinaryExpression,
7
- } = require('@putout/babel').types;
8
-
8
+ } = types;
9
9
  const isStringLike = (a) => {
10
10
  if (isStringLiteral(a))
11
11
  return true;
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const {isFunction} = require('@putout/babel').types;
3
+ const {types} = require('@putout/babel');
4
+ const {isFunction} = types;
4
5
  const {isNext} = require('../../is');
5
6
  const {markAfter} = require('../../mark');
6
7
 
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const {isMemberExpression} = require('@putout/babel').types;
3
+ const {types} = require('@putout/babel');
4
+ const {isMemberExpression} = types;
4
5
 
5
6
  module.exports.Decorator = (path, {print, maybe}) => {
6
7
  const {expression} = path.node;
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isTSModuleBlock,
5
6
  isBlockStatement,
6
7
  isExportNamedDeclaration,
7
- } = require('@putout/babel').types;
8
-
8
+ } = types;
9
9
  const {markAfter} = require('../../mark');
10
10
  const {isNext, isNextParent} = require('../../is');
11
11
  const {printParams} = require('./params');
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isLogicalExpression,
5
6
  isReturnStatement,
6
7
  isVariableDeclarator,
7
- } = require('@putout/babel').types;
8
+ } = types;
8
9
 
9
10
  module.exports.isRootOk = (path) => {
10
11
  return isReturnStatement(path) || isVariableDeclarator(path);
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isUnaryExpression,
5
6
  isArrowFunctionExpression,
6
7
  isIfStatement,
7
- } = require('@putout/babel').types;
8
-
8
+ } = types;
9
9
  const {chain} = require('./chain');
10
10
  const {satisfy} = require('../../is');
11
11
 
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isIdentifier,
5
6
  isObjectPattern,
6
7
  isAssignmentPattern,
7
8
  isVariableDeclarator,
8
- } = require('@putout/babel').types;
9
-
9
+ } = types;
10
10
  const {wrongShorthand} = require('./wrong-shortand');
11
11
 
12
12
  const {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const {isJSXElement} = require('@putout/babel').types;
4
-
3
+ const {types} = require('@putout/babel');
4
+ const {isJSXElement} = types;
5
5
  const isInsideArrow = ({parentPath}) => parentPath.isArrowFunctionExpression();
6
6
 
7
7
  module.exports.JSXElement = {
@@ -2,7 +2,7 @@
2
2
 
3
3
  const rendy = require('rendy');
4
4
  const maybeSatisfy = require('./satisfy');
5
-
5
+ const {types} = require('@putout/babel');
6
6
  const {
7
7
  isProgram,
8
8
  isFile,
@@ -10,8 +10,7 @@ const {
10
10
  ExpressionStatement,
11
11
  Program,
12
12
  isStatement,
13
- } = require('@putout/babel').types;
14
-
13
+ } = types;
15
14
  const isFn = (a) => typeof a === 'function';
16
15
 
17
16
  module.exports.maybeThrow = (a, path, b) => {
@@ -8,6 +8,7 @@ const {
8
8
  satisfy,
9
9
  } = require('../../is');
10
10
 
11
+ const {types} = require('@putout/babel');
11
12
  const {
12
13
  isArrowFunctionExpression,
13
14
  isObjectMethod,
@@ -15,8 +16,7 @@ const {
15
16
  isExportDeclaration,
16
17
  isDoWhileStatement,
17
18
  isBlockStatement,
18
- } = require('@putout/babel').types;
19
-
19
+ } = types;
20
20
  const {markAfter} = require('../../mark');
21
21
  const {parseComments} = require('../../comment/comment');
22
22
  const {insideIfWithNoBody} = require('./inside-if-with-no-body');
@@ -1,7 +1,9 @@
1
1
  'use strict';
2
2
 
3
- const {isExportNamespaceSpecifier} = require('@putout/babel').types;
3
+ const {types} = require('@putout/babel');
4
+ const {isExportNamespaceSpecifier} = types;
4
5
  const {markAfter, isMarkedAfter} = require('../../mark');
6
+
5
7
  const {
6
8
  isNewlineBetweenSiblings,
7
9
  exists,
@@ -35,14 +37,14 @@ module.exports.ExportNamespaceSpecifier = (path, {print}) => {
35
37
  };
36
38
 
37
39
  module.exports.ExportNamedDeclaration = {
38
- print(path, {print, traverse, write, indent, maybe}) {
40
+ print(path, {print, traverse, indent, maybe}) {
39
41
  const {exportKind} = path.node;
40
42
  const specifiers = path.get('specifiers');
41
43
  const {maxOneLineSpecifiers} = options.exports;
42
44
  const source = path.get('source');
43
45
 
44
46
  indent();
45
- write('export');
47
+ print('export');
46
48
 
47
49
  if (exportKind === 'type' && specifiers.length)
48
50
  print(' type');
@@ -61,39 +63,43 @@ module.exports.ExportNamedDeclaration = {
61
63
  const n = specifiers.length;
62
64
  const isNewline = !exists(source) || n > maxOneLineSpecifiers;
63
65
 
64
- if (specifiers.length) {
66
+ if (specifiers && !path.node.declaration) {
65
67
  print.space();
66
- write('{');
67
- indent.inc();
68
- maybe.write.newline(isNewline);
69
-
70
- const lastIndex = n - 1;
68
+ print('{');
71
69
 
72
- for (const [i, spec] of specifiers.entries()) {
73
- const isType = spec.node.exportKind === 'type';
74
- maybe.indent(isNewline);
75
- maybe.write(isType, 'type ');
76
- traverse(spec);
70
+ if (specifiers.length) {
71
+ indent.inc();
72
+ maybe.print.newline(isNewline);
77
73
 
78
- if (i < lastIndex && !isNewline)
79
- write(', ');
74
+ const lastIndex = n - 1;
80
75
 
81
- maybe.write(isNewline, ',');
82
- maybe.write.newline(isNewline);
76
+ for (const [i, spec] of specifiers.entries()) {
77
+ const isType = spec.node.exportKind === 'type';
78
+ maybe.indent(isNewline);
79
+ maybe.print(isType, 'type ');
80
+ traverse(spec);
81
+
82
+ if (i < lastIndex && !isNewline)
83
+ print(', ');
84
+
85
+ maybe.print(isNewline, ',');
86
+ maybe.print.newline(isNewline);
87
+ }
88
+
89
+ indent.dec();
90
+ indent();
83
91
  }
84
92
 
85
- indent.dec();
86
- indent();
87
- write('}');
93
+ print('}');
88
94
  const source = path.get('source');
89
95
 
90
96
  if (exists(source)) {
91
- write(' from ');
97
+ print(' from ');
92
98
  traverse(source);
93
99
  }
94
100
 
95
- write(';');
96
- maybe.write.newline(isNext(path) || isInsideNamespace(path));
101
+ print(';');
102
+ maybe.print.newline(isNext(path) || isInsideNamespace(path));
97
103
 
98
104
  return;
99
105
  }
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const {isJSXElement} = require('@putout/babel').types;
4
-
3
+ const {types} = require('@putout/babel');
4
+ const {isJSXElement} = types;
5
5
  const {
6
6
  isPrevBody,
7
7
  noTrailingComment,
@@ -9,7 +9,8 @@ const {
9
9
  } = require('../../is');
10
10
 
11
11
  const {hasPrevNewline} = require('../../mark');
12
- const {isExportDeclaration} = require('@putout/babel').types;
12
+ const {types} = require('@putout/babel');
13
+ const {isExportDeclaration} = types;
13
14
  const {maybeSpaceAfterKeyword} = require('./maybe-space-after-keyword');
14
15
 
15
16
  const {isConcatenation} = require('../../expressions/binary-expression/concatenate');
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  const {maybeParens} = require('../../maybe/maybe-parens');
4
+ const {types} = require('@putout/babel');
4
5
  const {
5
6
  isVariableDeclarator,
6
7
  isObjectExpression,
7
- } = require('@putout/babel').types;
8
+ } = types;
8
9
 
9
10
  module.exports.TSAsExpression = maybeParens((path, {print, maybe}) => {
10
11
  const is = isParens(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "11.9.0",
3
+ "version": "11.10.1",
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",
@@ -53,7 +53,7 @@
53
53
  "devDependencies": {
54
54
  "@putout/eslint": "^3.5.0",
55
55
  "@putout/plugin-minify": "^9.0.0",
56
- "@putout/plugin-printer": "^3.0.0",
56
+ "@putout/plugin-printer": "^4.0.0",
57
57
  "@putout/plugin-promises": "^16.0.0",
58
58
  "@putout/plugin-react-hook-form": "^4.0.0",
59
59
  "@putout/plugin-react-hooks": "^6.0.0",