Skip to content

Commit a821e82

Browse files
committed
fix: Account for subscriber chaining.
1 parent 0464f87 commit a821e82

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

source/rules/rxjsNoIgnoredSubscriptionRule.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ export class Rule extends Lint.Rules.TypedRule {
4646
propertyAccessExpression.expression
4747
);
4848
if (couldBeType(type, "Observable")) {
49+
if (
50+
callExpression.arguments.length === 1 &&
51+
couldBeType(
52+
typeChecker.getTypeAtLocation(callExpression.arguments[0]),
53+
"Subscriber"
54+
)
55+
) {
56+
return;
57+
}
4958
const { name } = callExpression.expression;
5059
failures.push(
5160
new Lint.RuleFailure(

test/v6/fixtures/no-ignored-subscription/default/fixture.ts.lint

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { of, Subscription } from "rxjs";
1+
import { of, Subscriber, Subscription } from "rxjs";
22

33
of(42).subscribe();
44
~~~~~~~~~ [no-ignored-subscription]
@@ -9,4 +9,7 @@ b = of(42).subscribe();
99
const c = [of(42).subscribe()];
1010
const d = { subscription: of(42).subscribe() };
1111

12+
const subscriber = new Subscriber<number>();
13+
of(42).subscribe(subscriber);
14+
1215
[no-ignored-subscription]: Ignoring returned subscriptions is forbidden

0 commit comments

Comments
 (0)