Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/generation/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9811,8 +9811,8 @@ fn allows_inline_multi_line<'a>(node: Node<'a>, context: &Context<'a>, has_sibli
_ => allows_inline_multi_line(as_expr.type_ann.into(), context, has_siblings),
}
}
Node::ArrowExpr(arrow) => matches!(arrow.body, BlockStmtOrExpr::BlockStmt(_)),
Node::FnExpr(_)
| Node::ArrowExpr(_)
| Node::ObjectLit(_)
| Node::ArrayLit(_)
| Node::ObjectPat(_)
Expand Down
45 changes: 45 additions & 0 deletions tests/specs/issues/issue0686.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
~~ lineWidth: 80, indentWidth: 2, memberExpression.linePerExpression: true ~~
== generator ==
const createTestData = () =>
function*() {
const startingFrom = yield* Effect.map(DateTime.now, now => DateTime.startOf(now, "day"))

return HashSet.make(DateTime.toEpochMillis(startingFrom))
};


[expect]
const createTestData = () =>
function*() {
const startingFrom = yield* Effect.map(
DateTime.now,
now => DateTime.startOf(now, "day"),
);

return HashSet.make(DateTime.toEpochMillis(startingFrom));
};

== function ==
const func = () =>
function() {
const startingFrom = Effect.map(DateTime.now, now => DateTime.startOf(now, 'day'))

return myObj
.myMethod({
missionType: otherObj.prop.nested,
});
};

[expect]
const func = () =>
function() {
const startingFrom = Effect.map(
DateTime.now,
now => DateTime.startOf(now, "day"),
);

return myObj
.myMethod({
missionType: otherObj.prop.nested,
});
};
46 changes: 46 additions & 0 deletions tests/specs/issues/issue0753.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
~~ lineWidth: 80, indentWidth: 2, memberExpression.linePerExpression: true ~~
Copy link
Copy Markdown

@naimonon77 naimonon77 Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrian-gierakowski
Let me just comment on one thing.
I think it should have a name starting with 0, like other files, like "issue0753.txt".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Btw. I'm not sure of this is the correct fix. Please see my comments in related issue.

Copy link
Copy Markdown

@naimonon77 naimonon77 Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my environment, the behavior of the following test case changed when memberExpression.linePerExpression:
false was set. You may want to check this.

When you do, it's a good idea to incorporate the latest changes from the main branch and check them just to be sure.

https://github.com/naimonon77/dprint-plugin-typescript/blob/issue0753_2/tests/specs/issues/issue0753_02.txt

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my environment, the behavior of the following test case changed when memberExpression.linePerExpression:
false was set. You may want to check this.

Yes, the issue only manifests when memberExpression.linePerExpression: true. I think that's the reason @dsherret keeps ignoring it since this option is disabled in deno. I'm not interested in disabling this option as without it dprint allows formatting which is quite inconsistent, like:

a.b.c
  .b.e
  .f

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main problem at this point is: what's the intended behaviour in #753 as that would determine if solution in this PR is valid or not

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can confirm, the intended behavior in #753 is fine.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dsherret would be great if you could confirm and merge if you agree with the above. Thanks!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebased on main and renamed the test from issue753 to issue0753

== function args ==
const startingFrom = Mylib.map(DateTime.now, now => DateTime.startOf(now, "day"))

const func = () =>
function() {
const startingFrom = Mylib.map(DateTime.now, now => DateTime.startOf(now, "day"))
}


[expect]
const startingFrom = Mylib.map(
DateTime.now,
now => DateTime.startOf(now, "day"),
);

const func = () =>
function() {
const startingFrom = Mylib.map(
DateTime.now,
now => DateTime.startOf(now, "day"),
);
};

== function args same line length ==
const startingFroom = Mylib.map(DateTime.now, now => DateTime.startOf(now, "day"))

const func = () =>
function() {
const startingF = Mylib.map(DateTime.now, now => DateTime.startOf(now, "day"))
}


[expect]
const startingFroom = Mylib.map(
DateTime.now,
now => DateTime.startOf(now, "day"),
);

const func = () =>
function() {
const startingF = Mylib.map(
DateTime.now,
now => DateTime.startOf(now, "day"),
);
};