@putout/printer 5.7.0 → 5.7.2

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.09.22, v5.7.2
2
+
3
+ fix:
4
+ - 45631de @putout/printer: avoid leaking mutation of a tree
5
+
6
+ 2023.09.22, v5.7.1
7
+
8
+ feature:
9
+ - 24a2ca5 @putout/printer: ClassAcessorProperty: breakline
10
+
1
11
  2023.09.22, v5.7.0
2
12
 
3
13
  feature:
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const {exists} = require('../../is');
3
+ const {exists, isPrev} = require('../../is');
4
4
  const {maybePrintTypeAnnotation} = require('../../literals/maybe-type-annotation');
5
5
 
6
6
  module.exports.ClassProperty = ClassProperty;
@@ -16,7 +16,6 @@ function ClassProperty(path, printer) {
16
16
  const {node} = path;
17
17
  const {
18
18
  accessibility,
19
- accessor,
20
19
  declare,
21
20
  optional,
22
21
  decorators,
@@ -24,12 +23,13 @@ function ClassProperty(path, printer) {
24
23
 
25
24
  if (decorators) {
26
25
  for (const decorator of path.get('decorators')) {
26
+ maybe.print.breakline(isPrev(path));
27
27
  print(decorator);
28
28
  print.breakline();
29
29
  }
30
30
  }
31
31
 
32
- if (accessor) {
32
+ if (path.__putout_printer_accessor) {
33
33
  print('accessor ');
34
34
  }
35
35
 
@@ -56,6 +56,7 @@ function ClassProperty(path, printer) {
56
56
  }
57
57
 
58
58
  module.exports.ClassAccessorProperty = (path, printer) => {
59
- path.node.accessor = true;
59
+ path.__putout_printer_accessor = true;
60
60
  ClassProperty(path, printer);
61
+ delete path.__putout_printer_accessor;
61
62
  };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const {isNext} = require('../../is');
3
+ const {isNext, isPrev} = require('../../is');
4
4
  const {printParams} = require('./params');
5
5
 
6
6
  const ClassMethod = {
@@ -22,6 +22,7 @@ const ClassMethod = {
22
22
 
23
23
  if (decorators) {
24
24
  for (const decorator of path.get('decorators')) {
25
+ maybe.print.breakline(isPrev(path));
25
26
  print(decorator);
26
27
  print.breakline();
27
28
  }
@@ -23,11 +23,18 @@ const isNext = (path) => {
23
23
  return !next.isEmptyStatement();
24
24
  };
25
25
 
26
+ const isPrev = (path) => {
27
+ const prev = path.getPrevSibling();
28
+
29
+ return prev.node;
30
+ };
31
+
26
32
  const isNextParent = (path) => isNext(path.parentPath);
27
33
  const isLast = (path) => isParentProgram(path) && !isNext(path);
28
34
 
29
35
  module.exports.isFirst = (path) => path.node === path.parentPath.node.body?.[0];
30
36
  module.exports.isPrevBody = (path) => path.getPrevSibling().isBlockStatement();
37
+ module.exports.isPrev = isPrev;
31
38
  module.exports.isNext = isNext;
32
39
  module.exports.isNextParent = isNextParent;
33
40
  module.exports.isParentProgram = isParentProgram;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "5.7.0",
3
+ "version": "5.7.2",
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",