@putout/printer 13.0.1 → 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,8 @@
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
+
1
6
  2025.02.22, v13.0.1
2
7
 
3
8
  feature:
@@ -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
 
@@ -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.1",
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",