cartant / eslint-plugin-rxjs

ESLint rules for RxJS
MIT License
312 stars 37 forks source link

[enhancement] Missing rule to prohibit the use of the tap async operator #103

Open tristan-laroubine opened 2 years ago

tristan-laroubine commented 2 years ago

Considering that the operator rxjs Tap is not blocking on operator chaining but can still contain an async function.

See the example code below:

const { of, tap } = require("rxjs");

const value$ = of(0).pipe(
    tap(async (data) => {
        await sleep(1000);
        console.log("1) async tap", data);
    }),
    tap((data) => console.log("2) tap", data))
);

Output

2) tap 0
1) async tap 0

A rule should be added to give the possibility to forbid the use of floating promises that are in the form of an async tap.

JasonWeinzierl commented 6 days ago

I use @typescript-eslint/no-misused-promises to ban stuff like this.