@putout/printer 13.4.0 → 13.4.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 +5 -0
- package/lib/tokenize/is.js +15 -8
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/lib/tokenize/is.js
CHANGED
|
@@ -78,8 +78,20 @@ function isStringAndIdentifier([a, b]) {
|
|
|
78
78
|
return isStringLiteral(a) && isIdentifier(b);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
const checkObject = (elements) => {
|
|
82
|
+
let a = elements.at(-1);
|
|
83
|
+
|
|
84
|
+
if (!isObjectExpression(a))
|
|
85
|
+
a = elements.at(-2);
|
|
86
|
+
|
|
87
|
+
if (!isObjectExpression(a))
|
|
88
|
+
return false;
|
|
89
|
+
|
|
90
|
+
return a.node.properties.length;
|
|
91
|
+
};
|
|
92
|
+
|
|
81
93
|
module.exports.isSimpleAndNotEmptyObject = (elements) => {
|
|
82
|
-
|
|
94
|
+
const [a] = elements;
|
|
83
95
|
|
|
84
96
|
const simpleTypes = [
|
|
85
97
|
'Identifier',
|
|
@@ -92,13 +104,7 @@ module.exports.isSimpleAndNotEmptyObject = (elements) => {
|
|
|
92
104
|
if (a && !simpleTypes.includes(a.type))
|
|
93
105
|
return false;
|
|
94
106
|
|
|
95
|
-
|
|
96
|
-
b = elements.at(-1);
|
|
97
|
-
|
|
98
|
-
if (!isObjectExpression(b))
|
|
99
|
-
return false;
|
|
100
|
-
|
|
101
|
-
return b.node.properties.length;
|
|
107
|
+
return checkObject(elements);
|
|
102
108
|
};
|
|
103
109
|
|
|
104
110
|
module.exports.isIdentifierAndIdentifier = ([a, b]) => {
|
|
@@ -172,3 +178,4 @@ module.exports.hasLeadingComment = (path) => path.node?.leadingComments?.length;
|
|
|
172
178
|
|
|
173
179
|
module.exports.noTrailingComment = (path) => !path.node.trailingComments?.length;
|
|
174
180
|
module.exports.noLeadingComment = (path) => !path.node.leadingComments?.length;
|
|
181
|
+
|
package/package.json
CHANGED