@putout/printer 11.6.0 → 11.7.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,10 @@
1
+ 2024.12.17, v11.7.0
2
+
3
+ feature:
4
+ - 8fd4fd6 @putout/printer: FunctionDeclaration inside TSModuleDeclarationExportnamed
5
+ - ab8c280 @putout/printer: @putout/plugin-promises v16.0.0
6
+ - ba04427 @putout/printer: LabeledStatement: indent
7
+
1
8
  2024.12.16, v11.6.0
2
9
 
3
10
  feature:
@@ -1,16 +1,20 @@
1
1
  'use strict';
2
2
 
3
+ const {
4
+ isTSModuleBlock,
5
+ isBlockStatement,
6
+ isExportNamedDeclaration,
7
+ } = require('@putout/babel').types;
8
+
3
9
  const {markAfter} = require('../../mark');
4
10
  const {isNext, isNextParent} = require('../../is');
5
11
  const {printParams} = require('./params');
6
12
 
13
+ const isInsideNamedExport = ({parentPath}) => isExportNamedDeclaration(parentPath);
14
+
7
15
  module.exports.FunctionDeclaration = {
8
16
  print(path, printer, semantics) {
9
- const {
10
- print,
11
- maybe,
12
- indent,
13
- } = printer;
17
+ const {print, maybe} = printer;
14
18
 
15
19
  const {
16
20
  async,
@@ -18,7 +22,7 @@ module.exports.FunctionDeclaration = {
18
22
  returnType,
19
23
  } = path.node;
20
24
 
21
- indent();
25
+ maybe.indent(!isInsideNamedExport(path));
22
26
  maybe.print(async, 'async ');
23
27
 
24
28
  print('function');
@@ -49,7 +53,12 @@ module.exports.FunctionDeclaration = {
49
53
  };
50
54
 
51
55
  function isInsideBlockStatement(path) {
52
- if (!path.parentPath.isBlockStatement())
56
+ const {parentPath} = path;
57
+
58
+ if (isTSModuleBlock(parentPath.parentPath))
59
+ return true;
60
+
61
+ if (!isBlockStatement(parentPath))
53
62
  return false;
54
63
 
55
64
  return !path.node.body.body.length;
@@ -51,4 +51,3 @@ function printUnary(path, name, {print}) {
51
51
  print(`${name} `);
52
52
  print('__argument');
53
53
  }
54
-
@@ -26,4 +26,3 @@ const maybeParensCondition = ({print, condition}) => ({
26
26
  ...maybeParensPrint(print),
27
27
  condition: (path) => condition?.(path) || isParens(path),
28
28
  });
29
-
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const {isLabeledStatement} = require('@putout/babel').types;
3
4
  const {
4
5
  isNext,
5
6
  isLast,
@@ -35,9 +36,11 @@ const shouldBreakline = satisfy([
35
36
  isStrictMode,
36
37
  ]);
37
38
 
39
+ const isInsideLabel = ({parentPath}) => isLabeledStatement(parentPath);
40
+
38
41
  module.exports.ExpressionStatement = {
39
- print(path, {indent, print, maybe, store}) {
40
- indent();
42
+ print(path, {print, maybe, store}) {
43
+ maybe.indent(!isInsideLabel(path));
41
44
 
42
45
  print('__expression');
43
46
  print(';');
@@ -21,6 +21,7 @@ const {BreakStatement} = require('./break-statement');
21
21
  const {DoWhileStatement} = require('./do-while-statement');
22
22
  const {Program} = require('./program/program');
23
23
  const {ContinueStatement} = require('./continue-statement');
24
+ const {LabeledStatement} = require('./labeled-statement/labeled-satement');
24
25
 
25
26
  const {
26
27
  ExportNamespaceSpecifier,
@@ -44,12 +45,7 @@ module.exports = {
44
45
  ForOfStatement,
45
46
  ReturnStatement,
46
47
  DebuggerStatement,
47
- LabeledStatement(path, {print}) {
48
- print('__label');
49
- print(':');
50
- print.space();
51
- print('__body');
52
- },
48
+ LabeledStatement,
53
49
  Program,
54
50
  EmptyStatement(path, {write}) {
55
51
  write(';');
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ module.exports.LabeledStatement = (path, {print, indent}) => {
4
+ indent();
5
+ print('__label');
6
+ print(':');
7
+ print.space();
8
+ print('__body');
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "11.6.0",
3
+ "version": "11.7.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",
@@ -54,7 +54,7 @@
54
54
  "@putout/eslint": "^3.5.0",
55
55
  "@putout/plugin-minify": "^9.0.0",
56
56
  "@putout/plugin-printer": "^3.0.0",
57
- "@putout/plugin-promises": "^15.0.0",
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",
60
60
  "acorn": "^8.8.2",