@putout/printer 1.21.0 → 1.22.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 +6 -0
- package/lib/tokenize/expressions/array-expression.js +12 -4
- package/lib/tokenize/expressions/array-pattern.js +0 -1
- package/lib/tokenize/expressions/class.js +1 -0
- package/lib/tokenize/expressions/functions.js +0 -1
- package/lib/tokenize/expressions/new-expression.js +0 -1
- package/lib/tokenize/expressions/object-expression.js +0 -1
- package/lib/tokenize/statements/expression-statement.js +0 -1
- package/lib/tokenize/statements/for-of-statement.js +0 -1
- package/lib/tokenize/statements/if-statement.js +0 -3
- package/lib/tokenize/statements/switch-statement.js +0 -1
- package/lib/tokenize/statements/try-statements.js +0 -1
- package/lib/tokenize/statements/variable-declaration.js +0 -1
- package/lib/tokenize/tokenize.js +0 -1
- package/lib/tokenize/typescript/index.js +1 -1
- package/package.json +1 -1
package/ChangeLog
CHANGED
|
@@ -8,6 +8,7 @@ const isForOf = ({parentPath}) => parentPath.isForOfStatement();
|
|
|
8
8
|
const SECOND = 1;
|
|
9
9
|
|
|
10
10
|
const isStringAndArray = ([a, b]) => a?.isStringLiteral() && b?.isArrayExpression();
|
|
11
|
+
const isStringAndIdentifier = ([a, b]) => a?.isStringLiteral() && b?.isIdentifier();
|
|
11
12
|
const isArrayParent = (path) => path.parentPath.isArrayExpression();
|
|
12
13
|
const isTwoLongStrings = ([a, b]) => {
|
|
13
14
|
const LONG_STRING = 20;
|
|
@@ -27,9 +28,8 @@ module.exports.ArrayExpression = (path, {print, maybe, indent}) => {
|
|
|
27
28
|
|
|
28
29
|
print('[');
|
|
29
30
|
|
|
30
|
-
if (!isTwoLongStrings(elements)
|
|
31
|
-
indent.inc();
|
|
32
|
-
}
|
|
31
|
+
if (!isTwoLongStrings(elements))
|
|
32
|
+
maybe.indent.inc(!shouldIncreaseIndent);
|
|
33
33
|
|
|
34
34
|
const isNewLine = isNewlineBetweenElements(path, {elements});
|
|
35
35
|
const n = elements.length - 1;
|
|
@@ -133,13 +133,21 @@ function isNewlineBetweenElements(path, {elements}) {
|
|
|
133
133
|
if (isStringAndArray(elements))
|
|
134
134
|
return false;
|
|
135
135
|
|
|
136
|
+
if (isStringAndIdentifier(elements))
|
|
137
|
+
return false;
|
|
138
|
+
|
|
136
139
|
if (tooLong(path) || isCoupleLines(path) || !isNumbers(elements) && !isForOf(path) && isLastArg(path) && !isParentProperty(path))
|
|
137
140
|
return true;
|
|
138
141
|
|
|
139
142
|
return false;
|
|
140
143
|
}
|
|
141
144
|
|
|
142
|
-
function isTwoStringsDifferentLength(
|
|
145
|
+
function isTwoStringsDifferentLength(strings) {
|
|
146
|
+
const [a, b] = strings;
|
|
147
|
+
|
|
148
|
+
if (strings.length > 2)
|
|
149
|
+
return false;
|
|
150
|
+
|
|
143
151
|
if (!a?.isStringLiteral() || !b?.isStringLiteral())
|
|
144
152
|
return false;
|
|
145
153
|
|
package/lib/tokenize/tokenize.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",
|