Skip to content

Commit 3e3ee1f

Browse files
committed
feature: @putout/printer: ObjectPattern: shouldAddNewline: simplify
1 parent 539deff commit 3e3ee1f

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

lib/tokenize/expressions/object-pattern/should-add-new-line.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from './has.js';
99

1010
const getMaxPropertiesInOneLine = (a, {maxPropertiesInOneLine}) => maxPropertiesInOneLine;
11+
const getValue = (a) => a.value;
1112

1213
const isMoreCountLessLength = createTypeChecker([
1314
['-: node.properties.length', '>', getMaxPropertiesInOneLine],
@@ -67,21 +68,14 @@ function isCoupleAssigns(path) {
6768
if (isFunctionParam(path))
6869
return false;
6970

70-
let assignsCount = 0;
71-
72-
for (const property of path.node.properties) {
73-
if (!isObjectProperty(property))
74-
continue;
75-
76-
if (isAssignmentPattern(property.value))
77-
++assignsCount;
78-
}
71+
const properties = path.node.properties
72+
.filter(isObjectProperty)
73+
.map(getValue)
74+
.filter(isAssignmentPattern);
7975

80-
return assignsCount > 1;
76+
return properties.length > 1;
8177
}
8278

83-
const getValue = (a) => a.value;
84-
8579
function checkLength(path) {
8680
const identifiers = path
8781
.node

0 commit comments

Comments
 (0)