@putout/printer 1.8.9 → 1.8.11

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.03.27, v1.8.11
2
+
3
+ fix:
4
+ - f7a06ec @putout/printer: drop redundant newline after VariableDeclaration
5
+
6
+ 2023.03.27, v1.8.10
7
+
8
+ feature:
9
+ - 8302ebb @putout/printer: isProgram optional
10
+
1
11
  2023.03.27, v1.8.9
2
12
 
3
13
  feature:
@@ -3,8 +3,9 @@
3
3
  module.exports.isFirst = (path) => path.node === path.parentPath.node.body[0];
4
4
  module.exports.isPrevBody = (path) => path.getPrevSibling().isBlockStatement();
5
5
  module.exports.isNext = (path) => path.getNextSibling().node;
6
- module.exports.isProgramParent = (path) => path.parentPath.isProgram();
6
+ module.exports.isProgramParent = (path) => path.parentPath?.isProgram();
7
7
  module.exports.isNextParent = (path) => path.parentPath.getNextSibling().node;
8
+ module.exports.isNextBlock = (path) => path.getNextSibling().isBlockStatement();
8
9
 
9
10
  module.exports.isCoupleLines = (path) => {
10
11
  const start = path.node?.loc?.start?.line;
@@ -27,8 +27,8 @@ module.exports = {
27
27
  ForOfStatement,
28
28
  ReturnStatement,
29
29
  DebuggerStatement,
30
- Program(path, {traverse}) {
31
- path.get('body').forEach(traverse);
30
+ Program(path, {print}) {
31
+ path.get('body').forEach(print);
32
32
  },
33
33
  SwitchStatement,
34
34
  ...TryStatements,
@@ -3,6 +3,8 @@
3
3
  const {
4
4
  isNext,
5
5
  isCoupleLines,
6
+ isNextBlock,
7
+
6
8
  } = require('../is');
7
9
  const {
8
10
  hasPrevNewline,
@@ -42,6 +44,9 @@ function shouldAddNewlineAfter(path) {
42
44
  if (!isNext(path) && path.parentPath.isBlockStatement())
43
45
  return true;
44
46
 
47
+ if (isNextBlock(path))
48
+ return false;
49
+
45
50
  if (isLast(path))
46
51
  return false;
47
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.8.9",
3
+ "version": "1.8.11",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",
@@ -1,2 +0,0 @@
1
- print('__block');
2
- print('__handler');
@@ -1,2 +0,0 @@
1
- print(path.get('block'));
2
- print(path.get('handler'));