@putout/printer 15.22.0 → 15.23.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
+ 2025.10.01, v15.23.1
2
+
3
+ feature:
4
+ - d10b125 @putout/printer: ForStatement inside LabeledStatement: indent
5
+
6
+ 2025.10.01, v15.23.0
7
+
8
+ feature:
9
+ - be1ec5d @putout/printer: WithStatement: add
10
+
1
11
  2025.10.01, v15.22.0
2
12
 
3
13
  feature:
@@ -1,18 +1,19 @@
1
1
  'use strict';
2
2
 
3
+ const {isInsideLabel} = require('#is');
3
4
  const {exists} = require('../is');
4
5
 
5
6
  const {markAfter} = require('../mark');
6
7
 
7
8
  module.exports.ForStatement = {
8
- print(path, {print, maybe, indent}) {
9
+ print(path, {print, maybe}) {
9
10
  const {
10
11
  test,
11
12
  update,
12
13
  body,
13
14
  } = path.node;
14
15
 
15
- indent();
16
+ maybe.indent(!isInsideLabel(path));
16
17
  print('for');
17
18
  print.space();
18
19
  print('(');
@@ -23,6 +23,7 @@ const {Program} = require('./program/program');
23
23
  const {ContinueStatement} = require('./continue-statement/continue-statement');
24
24
  const {LabeledStatement} = require('./labeled-statement/labeled-statement');
25
25
  const {EmptyStatement} = require('./empty-statement/empty-statement');
26
+ const {WithStatement} = require('./with-statement/with-statement');
26
27
 
27
28
  const {
28
29
  ExportNamespaceSpecifier,
@@ -59,4 +60,5 @@ module.exports = {
59
60
  BreakStatement,
60
61
  ContinueStatement,
61
62
  WhileStatement,
63
+ WithStatement,
62
64
  };
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ const {isNext} = require('#is');
4
+ const {markAfter} = require('../../mark');
5
+
6
+ module.exports.WithStatement = {
7
+ print(path, {print, indent}) {
8
+ indent();
9
+ print('with');
10
+ print.space();
11
+ print('(');
12
+ print('__object');
13
+ print(')');
14
+
15
+ if (path.node.body.body) {
16
+ print.space();
17
+ print('__body');
18
+ } else {
19
+ indent.inc();
20
+ print.newline();
21
+ print('__body');
22
+ indent.dec();
23
+ }
24
+ },
25
+ afterIf(path) {
26
+ return isNext(path);
27
+ },
28
+ after(path, {print}) {
29
+ print.linebreak();
30
+ markAfter(path);
31
+ },
32
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "15.22.0",
3
+ "version": "15.23.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",