denoland / denoland/deno

Formatting chained function calls is weird

Open
#29,331 1 comment 2 reactions 0 assignees View on GitHub
deno fmt
Dominant language
Rust
Stars
108k
Forks
6.4k
Avg merge
2d 20h
Merged PRs (30d)
58

Description

Formatting chained function calls should move each call to a separate line, similar to how prettier does it. I feel like we should do something simple like "If there are more than 2 function calls, move them each to a separate line".

Actual:

```ts
const result = someObject.getProperty("users").filter((user) => user.isActive)
.map((user) => user.id).sort((a, b) => a - b).find((id) => id > 100);
```

Expected:

```ts
const result = someObject
.getProperty('users')
.filter(user => user.isActive)
.map(user => user.id)
.sort((a, b) => a - b)
.find(id => id > 100);
```

Version: Deno 2.3.1

Contributor guide

Open the contributing guide

Research direction

Reproduce the chained-call example with Deno 2.3.1, then locate the formatter implementation and its existing tests. Confirm the desired line-breaking rule and add coverage for the example; done means chained calls format with each call on its own line without regressing other formatting.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.