@putout/printer 13.0.0 → 13.1.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,15 @@
1
+ 2025.02.25, v13.1.0
2
+
3
+ feature:
4
+ - 4387ef7 @putout/printer: AssignmentExpression: add semicolon even when not inside ExpressionStatement but when inside BlockStatement or Program
5
+
6
+ 2025.02.22, v13.0.1
7
+
8
+ feature:
9
+ - ee27918 @putout/printer: @putout/eslint v4.1.0
10
+ - 7384b14 @putout/printer: eslint-plugin-putout v25.0.1
11
+ - fc42fa2 @putout/printer: ObjectExpression inside ArrayExpression
12
+
1
13
  2025.02.17, v13.0.0
2
14
 
3
15
  fix:
@@ -34,6 +34,7 @@ const {
34
34
  isIdentifier,
35
35
  isFunction,
36
36
  isCallExpression,
37
+ isObjectProperty,
37
38
  } = types;
38
39
 
39
40
  const isNextString = (path) => isStringLiteral(path.getNextSibling());
@@ -133,7 +134,9 @@ module.exports.ArrayExpression = {
133
134
  if (index < n || trailingComma)
134
135
  maybe.print(is, ',');
135
136
 
136
- maybe.print.newline((is || isSpreadBeforeObject(element)) && !isNextObject(element));
137
+ if (!(isObjectExpression(element) && isObjectProperty(path.parentPath)))
138
+ maybe.print.newline((is || isSpreadBeforeObject(element)) && !isNextObject(element));
139
+
137
140
  maybe.print.space(is && isObjectAfterSimple(element));
138
141
 
139
142
  if (!is && index < n) {
@@ -11,6 +11,8 @@ const {
11
11
  isAssignmentExpression,
12
12
  } = types;
13
13
 
14
+ const isInsideBlock = ({parentPath}) => /BlockStatement|Program/.test(parentPath.type);
15
+
14
16
  module.exports.AssignmentExpression = (path, printer, semantics) => {
15
17
  const {print} = printer;
16
18
  const {operator} = path.node;
@@ -26,6 +28,12 @@ module.exports.AssignmentExpression = (path, printer, semantics) => {
26
28
  print.space();
27
29
 
28
30
  print('__right');
31
+
32
+ if (isInsideBlock(path)) {
33
+ print(';');
34
+ print.breakline();
35
+ }
36
+
29
37
  maybePrintRightBrace(path, printer, semantics);
30
38
  };
31
39
 
@@ -37,6 +37,7 @@ const isLast = (path) => isParentProgram(path) && !isNext(path);
37
37
  module.exports.isNextObject = (a) => a
38
38
  .getNextSibling()
39
39
  .isObjectExpression();
40
+
40
41
  module.exports.isPrevObject = (a) => a
41
42
  .getPrevSibling()
42
43
  .isObjectExpression();
@@ -57,4 +57,3 @@ const escape = (list, {slash, quote}) => {
57
57
 
58
58
  return res.join('');
59
59
  };
60
-
@@ -41,7 +41,7 @@ module.exports.maybeVisitor = (plugin, path, printer, options) => {
41
41
  return objectPlugin(plugin, path, printer, options);
42
42
  };
43
43
 
44
- function objectPlugin(plugin, path, printer, options) {
44
+ function objectPlugin(plugin, path, printer, semantics) {
45
45
  const {
46
46
  print,
47
47
  split,
@@ -52,11 +52,11 @@ function objectPlugin(plugin, path, printer, options) {
52
52
  afterIf = condition,
53
53
  } = maybeSatisfy(plugin);
54
54
 
55
- if (beforeIf?.(path, printer))
56
- before(path, printer);
55
+ if (beforeIf?.(path, printer, semantics))
56
+ before(path, printer, semantics);
57
57
 
58
- print(path, printer, options);
58
+ print(path, printer, semantics);
59
59
 
60
- if (afterIf?.(path, printer))
61
- after(path, printer);
60
+ if (afterIf?.(path, printer, semantics))
61
+ after(path, printer, semantics);
62
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "13.0.0",
3
+ "version": "13.1.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",
@@ -65,7 +65,7 @@
65
65
  }
66
66
  },
67
67
  "devDependencies": {
68
- "@putout/eslint": "^3.5.0",
68
+ "@putout/eslint": "^4.1.0",
69
69
  "@putout/eslint-flat": "^2.0.0",
70
70
  "@putout/plugin-minify": "^9.0.0",
71
71
  "@putout/plugin-printer": "^4.0.0",
@@ -77,7 +77,7 @@
77
77
  "check-dts": "^0.8.0",
78
78
  "escover": "^4.0.1",
79
79
  "eslint": "^9.0.0",
80
- "eslint-plugin-putout": "^24.0.0",
80
+ "eslint-plugin-putout": "^25.0.1",
81
81
  "estree-to-babel": "^10.0.0",
82
82
  "goldstein": "^5.14.0",
83
83
  "just-kebab-case": "^4.2.0",