Skip to content

Commit 1691bba

Browse files
authored
By flattening the array we have a better analysis of the output of a chain of objects (#531)
1 parent 7092f00 commit 1691bba

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/nodes/MemberAccess.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ const shallIndent = (path) => {
6262

6363
const MemberAccess = {
6464
print: ({ node, path, print }) => {
65-
const expressionDoc = path.call(print, 'expression');
65+
let expressionDoc = path.call(print, 'expression');
6666
let separator = [softline, '.'];
6767
let labelData;
6868
if (expressionDoc.label) {
6969
labelData = JSON.parse(expressionDoc.label);
70+
expressionDoc = expressionDoc.contents.flat();
7071
}
7172
if (labelData && labelData.groupId) {
7273
separator = ifBreak('.', [softline, '.'], {
@@ -78,7 +79,7 @@ const MemberAccess = {
7879
expressionDoc,
7980
shallIndent(path) ? indent(separator) : separator,
8081
node.memberName
81-
];
82+
].flat();
8283

8384
return isEndOfChain(node, path) ? group(doc) : doc;
8485
}

0 commit comments

Comments
 (0)