@putout/printer 16.3.0 → 16.5.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,13 @@
1
+ 2025.12.27, v16.5.0
2
+
3
+ feature:
4
+ - 039ab4a @putout/printer: SwitchCase: maybe space after case
5
+
6
+ 2025.12.11, v16.4.0
7
+
8
+ feature:
9
+ - 34371e9 @putout/printer: MemberExpression: chain: improve support
10
+
1
11
  2025.12.09, v16.3.0
2
12
 
3
13
  feature:
@@ -24,9 +24,21 @@ const isInsideMemberCall = (path) => {
24
24
  if (!isIdentifier(path.node.property))
25
25
  return false;
26
26
 
27
+ if (isLastArgInCall(path))
28
+ return true;
29
+
27
30
  return isCallExpression(path.parentPath.parentPath);
28
31
  };
29
32
 
33
+ function isLastArgInCall(path) {
34
+ const {parentPath} = path;
35
+
36
+ if (!isCallExpression(parentPath))
37
+ return false;
38
+
39
+ return path === parentPath.get('arguments').at(-1);
40
+ }
41
+
30
42
  module.exports.isLooksLikeChain = (path) => {
31
43
  const [root, properties] = chain(path);
32
44
 
@@ -14,7 +14,7 @@ const exportDeclarations = require('./export-declaration/export-declaration');
14
14
  const {ExportAllDeclaration} = require('./export-declaration/export-all-declaration');
15
15
 
16
16
  const {WhileStatement} = require('./while-statement/while-statement');
17
- const {SwitchStatement} = require('./switch-statement');
17
+ const {SwitchStatement} = require('./switch-statement/switch-statement');
18
18
  const {ForInStatement} = require('./for-in-statement');
19
19
  const {ExportDefaultDeclaration} = require('./export-declaration/export-default-declaration');
20
20
  const {BreakStatement} = require('./break-statement/break-statement');
@@ -2,12 +2,12 @@
2
2
 
3
3
  module.exports.maybeSpaceAfterKeyword = (path, {print}, semantics) => {
4
4
  const {roundBraces} = semantics;
5
- const {argument} = path.node;
5
+ const {node} = path;
6
6
 
7
- if (!argument)
7
+ if (!node)
8
8
  return;
9
9
 
10
- const {type} = argument;
10
+ const {type} = node;
11
11
 
12
12
  if (type === 'SequenceExpression' && roundBraces.sequence)
13
13
  return print.space();
@@ -18,7 +18,7 @@ module.exports.maybeSpaceAfterKeyword = (path, {print}, semantics) => {
18
18
  if (type === 'ArrayExpression' || type === 'ObjectExpression')
19
19
  return print.space();
20
20
 
21
- if (type === 'UnaryExpression' && argument.operator === '!')
21
+ if (type === 'UnaryExpression' && node.operator === '!')
22
22
  return print.space();
23
23
 
24
24
  if (type === 'ArrowFunctionExpression' && roundBraces.arrow)
@@ -29,7 +29,10 @@ module.exports.ReturnStatement = {
29
29
 
30
30
  maybe.indent(!isInsideLabel(path));
31
31
  print('return');
32
- maybeSpaceAfterKeyword(path, printer, semantics);
32
+
33
+ const arg = path.get('argument');
34
+
35
+ maybeSpaceAfterKeyword(arg, printer, semantics);
33
36
 
34
37
  if (isJSXWithComment(path)) {
35
38
  print('(');
@@ -4,9 +4,11 @@ const {
4
4
  isNext,
5
5
  exists,
6
6
  isLast,
7
- } = require('../is');
7
+ } = require('#is');
8
8
 
9
- const {parseLeadingComments} = require('../comment/comment');
9
+ const {parseLeadingComments} = require('../../comment/comment');
10
+
11
+ const {maybeSpaceAfterKeyword} = require('../return-statement/maybe-space-after-keyword.js');
10
12
 
11
13
  module.exports.SwitchStatement = {
12
14
  print(path, printer, semantics) {
@@ -36,7 +38,8 @@ module.exports.SwitchStatement = {
36
38
  parseLeadingComments(switchCase, printer, semantics);
37
39
 
38
40
  if (exists(test)) {
39
- write('case ');
41
+ write('case');
42
+ maybeSpaceAfterKeyword(test, printer, semantics);
40
43
  traverse(test);
41
44
  } else {
42
45
  write('default');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "16.3.0",
3
+ "version": "16.5.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",