@putout/printer 8.12.0 → 8.12.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,8 @@
1
+ 2024.04.11, v8.12.1
2
+
3
+ feature:
4
+ - cfb862d @putout/printer: tokenize: ArrayExpression: Identifier, Object: Tuple
5
+
1
6
  2024.04.11, v8.12.0
2
7
 
3
8
  feature:
package/README.md CHANGED
@@ -183,7 +183,10 @@ When you want to improve support of existing visitor or extend **Printer** with
183
183
  When you need to override behavior of existing visitor use:
184
184
 
185
185
  ```js
186
- import {print, visitors as v} from '@putout/printer';
186
+ import {
187
+ print,
188
+ visitors as v,
189
+ } from '@putout/printer';
187
190
 
188
191
  print(ast, {
189
192
  visitors: {
@@ -6,6 +6,7 @@ const {
6
6
  isStringAndIdentifier,
7
7
  isIdentifierAndIdentifier,
8
8
  isStringAndArray,
9
+ isIdentifierAndObject,
9
10
  } = require('../../is');
10
11
 
11
12
  const {
@@ -115,6 +116,11 @@ module.exports.ArrayExpression = {
115
116
  maybe.indent(elements.length && isNewLine);
116
117
  }
117
118
 
119
+ if (isIdentifierAndObject(elements)) {
120
+ print(',');
121
+ print.breakline();
122
+ }
123
+
118
124
  print(']');
119
125
  },
120
126
  afterIf(path) {
@@ -12,7 +12,6 @@ const {
12
12
  isNullLiteral,
13
13
  isStringLiteral,
14
14
  isSpreadElement,
15
- isIdentifier,
16
15
  } = require('@putout/babel').types;
17
16
 
18
17
  const {
@@ -1,5 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
4
+ const {isIdentifier} = types;
5
+
3
6
  const {
4
7
  isCoupleLines,
5
8
  isForOf,
@@ -9,7 +12,6 @@ const {
9
12
  noLeadingComment,
10
13
  hasLeadingComment,
11
14
  exists,
12
- isIdentifierAndObject,
13
15
  } = require('../../is');
14
16
 
15
17
  const {parseComments} = require('../../comment/comment');
@@ -89,24 +91,10 @@ module.exports.ObjectExpression = (path, printer, semantics) => {
89
91
  }
90
92
 
91
93
  indent.dec();
92
- const isInsideArrayWithIdentifierFirst = ({parentPath}) => {
93
- if (!parentPath.isArrayExpression())
94
- return false;
95
-
96
- return isIdentifierAndObject(parentPath.get('elements'));
97
- };
98
94
 
99
95
  maybe.indent(manyLines);
100
96
 
101
- if (isInsideArrayWithIdentifierFirst(path)) {
102
- print('},');
103
- indent.dec();
104
- print.breakline();
105
- indent.inc();
106
- } else {
107
- print('}');
108
- }
109
-
97
+ print('}');
110
98
  maybe.print(parens, ')');
111
99
 
112
100
  maybe.indent.dec(isMemberExpressionCallee(path));
@@ -166,4 +154,3 @@ function isParens(path) {
166
154
 
167
155
  return isParentExpression(path);
168
156
  }
169
-
@@ -83,7 +83,6 @@ module.exports.VariableDeclaration = {
83
83
  write.newline();
84
84
  wasNewline = true;
85
85
  } else if (isParentSwitchCase(path)) {
86
- //write.breakline();
87
86
  write.newline();
88
87
  }
89
88
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "8.12.0",
3
+ "version": "8.12.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",