@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 CHANGED
@@ -1,3 +1,8 @@
1
+ 2023.06.12, v2.2.0
2
+
3
+ feature:
4
+ - 5be9df9 printer: comments
5
+
1
6
  2023.06.12, v2.1.0
2
7
 
3
8
  feature:
package/README.md CHANGED
@@ -104,7 +104,8 @@ write(ast, {
104
104
 
105
105
  ### `format`
106
106
 
107
- With help of `format` you can override next options:
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`
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "2.1.0",
3
+ "version": "2.2.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",