@putout/printer 1.105.0 → 1.106.1
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.05.22, v1.106.1
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- ee28ef7 @putout/printer: IfStatement: improve support
|
|
5
|
+
|
|
6
|
+
2023.05.22, v1.106.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- f859c20 @putout/printer: AssignmentExpression inside LogicalExpression (coderaiser/minify#100)
|
|
10
|
+
|
|
1
11
|
2023.05.22, v1.105.0
|
|
2
12
|
|
|
3
13
|
feature:
|
package/README.md
CHANGED
|
@@ -95,6 +95,57 @@ print(ast, {
|
|
|
95
95
|
'const {a/* [hello world] */= 5} = b;\n';
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
### `format`
|
|
99
|
+
|
|
100
|
+
With help of `format` you can override next options:
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
const overrides = {
|
|
104
|
+
format: {
|
|
105
|
+
indent: ' ',
|
|
106
|
+
newline: '\n',
|
|
107
|
+
space: ' ',
|
|
108
|
+
comments: true,
|
|
109
|
+
splitter: '\n',
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
- `indent` - use two spaces, tabs, or anything you want;
|
|
115
|
+
- `newline` - symbol for used for line separation;
|
|
116
|
+
- `space` - default symbol used for space character;
|
|
117
|
+
- `comments` - produce comments in output or skip them;
|
|
118
|
+
- `splitter` - mandatory symbol that used inside of statements like this:
|
|
119
|
+
|
|
120
|
+
Default options produce:
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
if (a > 3)
|
|
124
|
+
console.log('ok');else
|
|
125
|
+
console.log('not ok');
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
But you can override them with:
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
const overrides = {
|
|
132
|
+
format: {
|
|
133
|
+
indent: '',
|
|
134
|
+
newline: '',
|
|
135
|
+
space: '',
|
|
136
|
+
splitter: ' ',
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
And have minified code:
|
|
142
|
+
|
|
143
|
+
```js
|
|
144
|
+
if (a > 3)
|
|
145
|
+
console.log('ok');else
|
|
146
|
+
console.log('not ok');
|
|
147
|
+
```
|
|
148
|
+
|
|
98
149
|
### `print`
|
|
99
150
|
|
|
100
151
|
Used in previous example `print` can be used for a couple purposes:
|
|
@@ -3,12 +3,26 @@
|
|
|
3
3
|
const {isObjectPattern} = require('@babel/types');
|
|
4
4
|
|
|
5
5
|
module.exports.AssignmentExpression = {
|
|
6
|
-
condition: (path) =>
|
|
6
|
+
condition: (path) => {
|
|
7
|
+
const {
|
|
8
|
+
left,
|
|
9
|
+
extra,
|
|
10
|
+
} = path.node;
|
|
11
|
+
|
|
12
|
+
if (isObjectPattern(left))
|
|
13
|
+
return true;
|
|
14
|
+
|
|
15
|
+
if (extra?.parenthesized)
|
|
16
|
+
return true;
|
|
17
|
+
|
|
18
|
+
return path.parentPath.isLogicalExpression();
|
|
19
|
+
},
|
|
7
20
|
before(path, {write}) {
|
|
8
21
|
write('(');
|
|
9
22
|
},
|
|
10
23
|
print(path, {print}) {
|
|
11
24
|
const {operator} = path.node;
|
|
25
|
+
|
|
12
26
|
print('__left');
|
|
13
27
|
print.space();
|
|
14
28
|
print(operator);
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
const {ArrowFunctionExpression} = require('./arrow-function-expression');
|
|
4
4
|
const {FunctionDeclaration} = require('./function-declaration');
|
|
5
|
+
|
|
5
6
|
const {
|
|
6
7
|
ClassMethod,
|
|
7
8
|
ClassPrivateMethod,
|
|
8
9
|
} = require('./class-method');
|
|
10
|
+
|
|
9
11
|
const {ObjectMethod} = require('./object-method');
|
|
10
12
|
const {FunctionExpression} = require('./function-expression');
|
|
11
13
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.106.1",
|
|
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",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"generate"
|
|
47
47
|
],
|
|
48
48
|
"devDependencies": {
|
|
49
|
+
"@putout/plugin-minify": "^1.8.0",
|
|
49
50
|
"@putout/plugin-printer": "^1.0.0",
|
|
50
51
|
"@putout/plugin-react-hooks": "^5.0.0",
|
|
51
52
|
"@putout/test": "^6.0.1",
|