--- source: crates/rome_formatter_test/src/snapshot_builder.rs info: test_file: js/bind-expressions/method_chain.js --- # Input ```js import {interval} from 'rxjs/observable/interval'; import {filter} from 'rxjs/operator/filter'; import {take} from 'rxjs/operator/take'; import {map} from 'rxjs/operator/map'; import {throttle} from 'rxjs/operator/throttle'; import {takeUntil} from 'rxjs/operator/takeUntil'; function test(observable) { return observable ::filter(data => data.someTest) ::throttle(() => interval(10) ::take(1) ::takeUntil(observable::filter(data => someOtherTest)) ) ::map(someFunction); } ``` # Prettier differences ```diff --- Prettier +++ Rome @@ -6,12 +6,12 @@ import { takeUntil } from "rxjs/operator/takeUntil"; function test(observable) { - return observable - ::filter((data) => data.someTest) - ::throttle(() => - interval(10) - ::take(1) - ::takeUntil(observable::filter((data) => someOtherTest)), - ) - ::map(someFunction); + return observable; + ::filter(data => data.someTest) + ::throttle(() => + interval(10) + ::take(1) + ::takeUntil(observable::filter(data => someOtherTest)) + ) + ::map(someFunction) } ``` # Output ```js import { interval } from "rxjs/observable/interval"; import { filter } from "rxjs/operator/filter"; import { take } from "rxjs/operator/take"; import { map } from "rxjs/operator/map"; import { throttle } from "rxjs/operator/throttle"; import { takeUntil } from "rxjs/operator/takeUntil"; function test(observable) { return observable; ::filter(data => data.someTest) ::throttle(() => interval(10) ::take(1) ::takeUntil(observable::filter(data => someOtherTest)) ) ::map(someFunction) } ``` # Errors ``` method_chain.js:10:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found '::filter(data => data.someTest) ::throttle(() => interval(10) ::take(1) ::takeUntil(observable::filter(data => someOtherTest)) ) ::map(someFunction)' 8 │ function test(observable) { 9 │ return observable > 10 │ ::filter(data => data.someTest) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > 11 │ ::throttle(() => ... > 15 │ ) > 16 │ ::map(someFunction); │ ^^^^^^^^^^^^^^^^^^^ 17 │ } 18 │ i Expected a statement here 8 │ function test(observable) { 9 │ return observable > 10 │ ::filter(data => data.someTest) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > 11 │ ::throttle(() => ... > 15 │ ) > 16 │ ::map(someFunction); │ ^^^^^^^^^^^^^^^^^^^ 17 │ } 18 │ ```