@putout/printer 2.23.0 → 2.25.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,13 @@
1
+ 2023.06.19, v2.25.0
2
+
3
+ feature:
4
+ - 0a70e74 @putout/printer: FunctionDeclaration: generator: imporve support (coderaiser/minify#108)
5
+
6
+ 2023.06.16, v2.24.0
7
+
8
+ feature:
9
+ - 32d4852 @putout/printer: VariableDeclaration: newline
10
+
1
11
  2023.06.16, v2.23.0
2
12
 
3
13
  feature:
@@ -26,9 +26,7 @@ const ClassMethod = {
26
26
  print.space();
27
27
  print('__body');
28
28
  },
29
- afterSatisfy: () => [
30
- isNext,
31
- ],
29
+ afterSatisfy: () => [isNext],
32
30
  after(path, {print}) {
33
31
  print.linebreak();
34
32
  },
@@ -2,17 +2,25 @@
2
2
 
3
3
  const {markAfter} = require('../../mark');
4
4
 
5
- const {isNext, isNextParent} = require('../../is');
5
+ const {
6
+ isNext,
7
+ isNextParent,
8
+ } = require('../../is');
6
9
 
7
10
  const {printParams} = require('./params');
8
11
 
9
12
  module.exports.FunctionDeclaration = {
10
13
  print(path, {print, maybe}) {
11
- const {async} = path.node;
14
+ const {
15
+ async,
16
+ generator,
17
+ } = path.node;
12
18
 
13
19
  maybe.print(async, 'async ');
14
20
 
15
21
  print('function ');
22
+ maybe.print(generator, '*');
23
+
16
24
  print('__id');
17
25
  print('__typeParameters');
18
26
 
@@ -23,9 +23,7 @@ module.exports.ExportDefaultDeclaration = {
23
23
  traverse(declaration);
24
24
  maybe.print(shouldAddSemi(declaration), ';');
25
25
  },
26
- afterSatisfy: () => [
27
- notClass,
28
- ],
26
+ afterSatisfy: () => [notClass],
29
27
  after(path, {print}) {
30
28
  print.newline();
31
29
  print.newline();
@@ -59,9 +59,7 @@ module.exports.SwitchStatement = {
59
59
  if (!isNext(path) && !isLast(path))
60
60
  print.newline();
61
61
  },
62
- afterSatisfy: () => [
63
- isNext,
64
- ],
62
+ afterSatisfy: () => [isNext],
65
63
  after(path, {print}) {
66
64
  print.breakline();
67
65
  print.breakline();
@@ -130,6 +130,9 @@ function isNextCoupleLines(path) {
130
130
  const next = path.getNextSibling();
131
131
  const prev = path.getPrevSibling();
132
132
 
133
+ if (!exists(prev.getPrevSibling()) && next.isVariableDeclaration())
134
+ return false;
135
+
133
136
  if (path.node.loc?.start.line === prev.node?.loc?.start.line + 2)
134
137
  return false;
135
138
 
@@ -8,9 +8,7 @@ module.exports.TSInterfaceDeclaration = {
8
8
  print('__id');
9
9
  print('__body');
10
10
  },
11
- afterSatisfy: () => [
12
- isNext,
13
- ],
11
+ afterSatisfy: () => [isNext],
14
12
  after(path, {print}) {
15
13
  print.breakline();
16
14
  print.breakline();
@@ -9,9 +9,7 @@ module.exports.TSModuleDeclaration = {
9
9
  print.space();
10
10
  print('__body');
11
11
  },
12
- afterSatisfy: () => [
13
- isNext,
14
- ],
12
+ afterSatisfy: () => [isNext],
15
13
  after(path, {print}) {
16
14
  print.newline();
17
15
  print.newline();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.23.0",
3
+ "version": "2.25.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",