Skip to content

Commit 6472c63

Browse files
docs(no-ignored-observable): tips for this rule
1 parent 1a2e615 commit 6472c63

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

docs/rules/no-ignored-observable.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
<!-- end auto-generated rule header -->
88

99
The effects failures if an observable returned by a function is neither assigned to a variable or property or passed to a function.
10+
This rule is like [no-floating-promises](https://typescript-eslint.io/rules/no-floating-promises/) but for Observables.
11+
12+
This rule will report Observable-valued statements that are not treated in one of the following ways:
13+
14+
- Calling its `.subscribe()`
15+
- `return`ing it
16+
- Wrapping it in `lastValueFrom` or `firstValueFrom` and `await`ing it
17+
- [`void`ing it](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void)
18+
19+
> [!TIP]
20+
> `no-ignored-observable` only detects apparently unhandled Observable _statements_.
1021
1122
## Rule details
1223

tests/rules/no-ignored-observable.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ ruleTester({ types: true }).run('no-ignored-observable', noIgnoredObservableRule
3131
const a = arrowSource();
3232
sink(arrowSource());
3333
`,
34+
stripIndent`
35+
// void operator
36+
import { of } from "rxjs";
37+
38+
function functionSource() {
39+
return of(42);
40+
}
41+
42+
void functionSource();
43+
`,
3444
],
3545
invalid: [
3646
fromFixture(

0 commit comments

Comments
 (0)