-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
lang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!Issues with an accompanying pull request. These issues will probably be fixed soon!status:needs discussionIssues needing discussion and a decision to be made before action can be takenIssues needing discussion and a decision to be made before action can be taken
Description
Prettier 1.11.1
Playground link
Input:
import { range } from 'rxjs/observable/range';
import { map, filter, scan } from 'rxjs/operators';
const source$ = range(0, 10);
source$.pipe(
filter(x => x % 2 === 0),
map(x => x + x),
scan((acc, x) => acc + x, 0)
)
.subscribe(x => console.log(x))Output:
import { range } from "rxjs/observable/range";
import { map, filter, scan } from "rxjs/operators";
const source$ = range(0, 10);
source$
.pipe(filter(x => x % 2 === 0), map(x => x + x), scan((acc, x) => acc + x, 0))
.subscribe(x => console.log(x));Expected behavior:
As in the official RxJS documentation, the given input shouldn't be modified as it is considered as methods chaining. The piped functions filter, map and scan should remain on a separate line.
I don't know how it can be handled by prettier without too much impacts, but maybe considering that a function call that includes at least 2 function calls as parameters (eg: fn1(fn2(), fn3())) could be printed as a chain as below:
fn1(
fn2(),
fn3()
)It would also help when using Lo-Dash FP chaining which encounters the same problem.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
lang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!Issues with an accompanying pull request. These issues will probably be fixed soon!status:needs discussionIssues needing discussion and a decision to be made before action can be takenIssues needing discussion and a decision to be made before action can be taken