@putout/printer 1.103.0 → 1.104.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
+ 2023.05.22, v1.104.0
2
+
3
+ feature:
4
+ - 1b4121a @putout/printer: splitter: add support
5
+
1
6
  2023.05.18, v1.103.0
2
7
 
3
8
  feature:
package/README.md CHANGED
@@ -81,6 +81,7 @@ print(ast, {
81
81
  newline: '\n',
82
82
  space: ' ',
83
83
  comments: true,
84
+ splitter: '\n',
84
85
  },
85
86
  visitors: {
86
87
  AssignmentPattern(path, {print}) {
@@ -1,10 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const {exists} = require('../is');
4
+
4
5
  module.exports.ClassProperty = ClassProperty;
5
6
 
6
7
  module.exports.ClassPrivateProperty = (path, {print}) => {
7
- ClassProperty(path, {print});
8
+ ClassProperty(path, {
9
+ print,
10
+ });
8
11
  };
9
12
 
10
13
  module.exports.PrivateName = (path, {print}) => {
@@ -23,11 +23,13 @@ const {
23
23
  } = require('./object-expression');
24
24
 
25
25
  const {ObjectPattern} = require('./object-pattern');
26
+
26
27
  const {
27
28
  ClassProperty,
28
29
  ClassPrivateProperty,
29
30
  PrivateName,
30
31
  } = require('./class-property');
32
+
31
33
  const {AssignmentExpression} = require('./assignment-expression');
32
34
  const {ArrayExpression} = require('./array-expression');
33
35
  const {ArrayPattern} = require('./array-pattern');
@@ -43,7 +43,8 @@ module.exports.IfStatement = {
43
43
  traverse(alternate);
44
44
  } else if (exists(alternate)) {
45
45
  maybe.indent(!isConsequentBlock);
46
- write('else\n');
46
+ write('else');
47
+ write.splitter();
47
48
  indent.inc();
48
49
  traverse(alternate);
49
50
  indent.dec();
@@ -52,6 +52,7 @@ function initFormat(format) {
52
52
  newline: '\n',
53
53
  space: ' ',
54
54
  comments: true,
55
+ splitter: '\n',
55
56
  ...format,
56
57
  };
57
58
  }
@@ -102,6 +103,13 @@ module.exports.tokenize = (ast, overrides = {}) => {
102
103
  dec: decIndent,
103
104
  });
104
105
 
106
+ const splitter = () => {
107
+ addToken({
108
+ type: TYPES.SPLITTER,
109
+ value: format.splitter,
110
+ });
111
+ };
112
+
105
113
  const linebreak = () => {
106
114
  indent();
107
115
  newline();
@@ -132,6 +140,7 @@ module.exports.tokenize = (ast, overrides = {}) => {
132
140
  linebreak,
133
141
  breakline,
134
142
  space,
143
+ splitter,
135
144
  });
136
145
 
137
146
  assign(maybeWrite, {
package/lib/types.js CHANGED
@@ -4,6 +4,7 @@ module.exports.TYPES = {
4
4
  TOKEN: 'Token',
5
5
  NEWLINE: 'Newline',
6
6
  LINEBREAK: 'Linebreak',
7
+ SPLITTER: 'Splitter',
7
8
  INDENT: 'Indent',
8
9
  DEBUG: 'Debug',
9
10
  SPACE: 'Space',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.103.0",
3
+ "version": "1.104.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",