@putout/printer 13.4.0 → 14.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,19 @@
1
+ 2025.03.22, v14.0.0
2
+
3
+ feature:
4
+ - ee8b09d @putout/printer: drop support of node < 20
5
+ - 3e6915a Function inside ExportDefaultDeclaration before VariableDeclaration
6
+ - 7efbba1 @putout/printer: redlint v4.0.0
7
+ - 70b9601 @putout/printer: putout v39.0.2
8
+ - 5038eb4 @putout/printer: @putout/plugin-printer v5.0.0
9
+ - c1b1f56 @putout/printer: madrun v11.0.0
10
+ - 8dc78fb @putout/printer: eslint-plugin-putout v26.0.2
11
+
12
+ 2025.03.13, v13.4.1
13
+
14
+ feature:
15
+ - 982f309 @putout/printer: is: simplify
16
+
1
17
  2025.03.13, v13.4.0
2
18
 
3
19
  feature:
@@ -78,8 +78,20 @@ function isStringAndIdentifier([a, b]) {
78
78
  return isStringLiteral(a) && isIdentifier(b);
79
79
  }
80
80
 
81
+ const checkObject = (elements) => {
82
+ let a = elements.at(-1);
83
+
84
+ if (!isObjectExpression(a))
85
+ a = elements.at(-2);
86
+
87
+ if (!isObjectExpression(a))
88
+ return false;
89
+
90
+ return a.node.properties.length;
91
+ };
92
+
81
93
  module.exports.isSimpleAndNotEmptyObject = (elements) => {
82
- let [a, b] = elements;
94
+ const [a] = elements;
83
95
 
84
96
  const simpleTypes = [
85
97
  'Identifier',
@@ -92,13 +104,7 @@ module.exports.isSimpleAndNotEmptyObject = (elements) => {
92
104
  if (a && !simpleTypes.includes(a.type))
93
105
  return false;
94
106
 
95
- if (!isObjectExpression(b))
96
- b = elements.at(-1);
97
-
98
- if (!isObjectExpression(b))
99
- return false;
100
-
101
- return b.node.properties.length;
107
+ return checkObject(elements);
102
108
  };
103
109
 
104
110
  module.exports.isIdentifierAndIdentifier = ([a, b]) => {
@@ -147,7 +147,6 @@ function shouldAddNewlineAfter(path) {
147
147
  return !isNextIfAlternate(path);
148
148
  }
149
149
 
150
- // export function a() {}
151
150
  function isExportFunction(path) {
152
151
  if (!isFunctionDeclaration(path.parentPath))
153
152
  return false;
@@ -1,8 +1,14 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {isNext} = require('../../is');
4
5
 
5
- function shouldAddSemi(path) {
6
+ const {
7
+ isVariableDeclaration,
8
+ isFunction,
9
+ } = types;
10
+
11
+ function shouldAddSemicolon(path) {
6
12
  if (path.isClassDeclaration())
7
13
  return false;
8
14
 
@@ -14,11 +20,22 @@ module.exports.ExportDefaultDeclaration = {
14
20
  const declaration = path.get('declaration');
15
21
  print('export default ');
16
22
  traverse(declaration);
17
- maybe.print(shouldAddSemi(declaration), ';');
23
+ maybe.print(shouldAddSemicolon(declaration), ';');
18
24
  },
19
25
  afterSatisfy: () => [isNext],
20
- after(path, {print}) {
21
- print.newline();
26
+ after(path, {print, maybe}) {
22
27
  print.newline();
28
+ maybe.print.newline(!isVarAfterFn(path));
23
29
  },
24
30
  };
31
+
32
+ function isVarAfterFn(path) {
33
+ const next = path.getNextSibling();
34
+
35
+ if (!isVariableDeclaration(next))
36
+ return false;
37
+
38
+ const {declaration} = path.node;
39
+
40
+ return isFunction(declaration);
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "13.4.0",
3
+ "version": "14.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",
@@ -70,7 +70,7 @@
70
70
  "devDependencies": {
71
71
  "@putout/eslint": "^4.1.0",
72
72
  "@putout/plugin-minify": "^10.0.0",
73
- "@putout/plugin-printer": "^4.0.0",
73
+ "@putout/plugin-printer": "^5.0.0",
74
74
  "@putout/plugin-promises": "^16.0.0",
75
75
  "@putout/plugin-react-hook-form": "^5.0.0",
76
76
  "@putout/plugin-react-hooks": "^7.0.0",
@@ -79,16 +79,16 @@
79
79
  "check-dts": "^0.8.0",
80
80
  "escover": "^4.0.1",
81
81
  "eslint": "^9.0.0",
82
- "eslint-plugin-putout": "^25.0.1",
82
+ "eslint-plugin-putout": "^26.0.2",
83
83
  "estree-to-babel": "^10.0.0",
84
84
  "goldstein": "^5.14.0",
85
85
  "just-kebab-case": "^4.2.0",
86
- "madrun": "^10.0.0",
86
+ "madrun": "^11.0.0",
87
87
  "mock-require": "^3.0.3",
88
88
  "montag": "^1.0.0",
89
89
  "nodemon": "^3.0.1",
90
- "putout": "^38.0.0",
91
- "redlint": "^3.16.0",
90
+ "putout": "^39.0.2",
91
+ "redlint": "^4.0.0",
92
92
  "samadhi": "^2.8.0",
93
93
  "supertape": "^10.0.0",
94
94
  "try-catch": "^3.0.0",
@@ -96,7 +96,7 @@
96
96
  },
97
97
  "license": "MIT",
98
98
  "engines": {
99
- "node": ">=18"
99
+ "node": ">=20"
100
100
  },
101
101
  "publishConfig": {
102
102
  "access": "public"