@putout/printer 2.1.0 → 2.2.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 +5 -0
- package/README.md +13 -7
- package/lib/tokenize/comments.js +1 -1
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -104,7 +104,8 @@ write(ast, {
|
|
|
104
104
|
|
|
105
105
|
### `format`
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
Options related to visuals and not related to logic of output can be changed with help of `format`,
|
|
108
|
+
you can override next options:
|
|
108
109
|
|
|
109
110
|
```js
|
|
110
111
|
const overrides = {
|
|
@@ -112,8 +113,9 @@ const overrides = {
|
|
|
112
113
|
indent: ' ',
|
|
113
114
|
newline: '\n',
|
|
114
115
|
space: ' ',
|
|
115
|
-
comments: true,
|
|
116
116
|
splitter: '\n',
|
|
117
|
+
roundBraceOpen: '(',
|
|
118
|
+
roundBraceClose: ')',
|
|
117
119
|
},
|
|
118
120
|
};
|
|
119
121
|
```
|
|
@@ -121,8 +123,8 @@ const overrides = {
|
|
|
121
123
|
- `indent` - use two spaces, tabs, or anything you want;
|
|
122
124
|
- `newline` - symbol for used for line separation;
|
|
123
125
|
- `space` - default symbol used for space character;
|
|
124
|
-
- `comments` - produce comments in output or skip them;
|
|
125
126
|
- `splitter` - mandatory symbol that used inside of statements like this:
|
|
127
|
+
- `roundBraceOpen` and `roundBraceClose` symbols to to output braces in a single argument arrow function expressions: `(a) => {}`.
|
|
126
128
|
|
|
127
129
|
Default options produce:
|
|
128
130
|
|
|
@@ -148,11 +150,15 @@ const overrides = {
|
|
|
148
150
|
|
|
149
151
|
And have minified code:
|
|
150
152
|
|
|
153
|
+
```
|
|
154
|
+
if(a>3)console.log('ok');else console.log('not ok');
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Semantics
|
|
158
|
+
|
|
159
|
+
Options used to configure logic of output, similar to ESLint rules:
|
|
160
|
+
|
|
151
161
|
```js
|
|
152
|
-
if (a > 3)
|
|
153
|
-
console.log('ok');
|
|
154
|
-
else
|
|
155
|
-
console.log('not ok');
|
|
156
162
|
```
|
|
157
163
|
|
|
158
164
|
### `write`
|
package/lib/tokenize/comments.js
CHANGED
|
@@ -104,7 +104,7 @@ module.exports.parseComments = (path, {write}, semantics) => {
|
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
function isSameLine(path, loc) {
|
|
107
|
-
return path.node.loc.start.line === loc.start.line;
|
|
107
|
+
return path.node.loc.start.line === loc.start.line || path.node.loc.end.line === loc.end.line;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
function maybeInsideFn(insideFn, {print, indent}) {
|
package/package.json
CHANGED