-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
fixture.ts.lint
101 lines (93 loc) · 3.05 KB
/
fixture.ts.lint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import { Component, OnDestroy, OnInit } from "@angular/core";
import { of, Subscription } from "rxjs";
@Component({
selector: "composed-component",
template: "<span>{{ value }}</span>"
})
export class ComposedComponent implements OnInit, OnDestroy {
value: string;
private subscription = new Subscription();
ngOnInit() {
this.subscription.add(of("foo").subscribe(value => this.value = value));
}
ngOnDestroy() {
this.subscription.unsubscribe();
}
}
@Component({
selector: "variable-composed-component",
template: "<span>{{ value }}</span>"
})
export class VariableComposedComponent implements OnInit, OnDestroy {
value: string;
private subscription = new Subscription();
ngOnInit() {
let subscription = of("foo").subscribe(value => this.value = value);
this.subscription.add(subscription);1
subscription = of("bar").subscribe(value => this.value = value);
this.subscription.add(subscription);
}
ngOnDestroy() {
this.subscription.unsubscribe();
}
}
@Component({
selector: "destructured-composed-component",
template: "<span>{{ value }}</span>"
})
export class DestructuredComposedComponent implements OnInit, OnDestroy {
value: string;
private subscription = new Subscription();
ngOnInit() {
const { subscription } = this;
subscription.add(of("foo").subscribe(value => this.value = value));
}
ngOnDestroy() {
const { subscription } = this;
subscription.unsubscribe();
}
}
@Component({
selector: "not-composed-component",
template: "<span>{{ value }}</span>"
})
export class NotComposedComponent implements OnInit, OnDestroy {
value: string;
ngOnInit() {
of("foo").subscribe(value => this.value = value);
~~~~~~~~~ [prefer-composition-not-composed]
const subscription = of("bar").subscribe(value => this.value = value);
~~~~~~~~~ [prefer-composition-not-composed]
}
ngOnDestroy() {
}
}
@Component({
selector: "not-unsubscribed-component",
template: "<span>{{ value }}</span>"
})
export class NotUnsubscribedComponent implements OnInit, OnDestroy {
value: string;
private subscription = new Subscription();
~~~~~~~~~~~~ [prefer-composition-not-unsubscribed]
ngOnInit() {
this.subscription.add(of("foo").subscribe(value => this.value = value));
}
ngOnDestroy() {
}
}
@Component({
selector: "not-destroyed-component",
template: "<span>{{ value }}</span>"
})
export class NotDestroyedComponent implements OnInit {
~~~~~~~~~~~~~~~~~~~~~ [prefer-composition-not-implemented]
value: string;
private subscription = new Subscription();
ngOnInit() {
this.subscription.add(of("foo").subscribe(value => this.value = value));
}
}
[prefer-composition-not-composed]: Subscription not composed
[prefer-composition-not-unsubscribed]: Composed subscription not unsubscribed
[prefer-composition-not-implemented]: ngOnDestroy not implemented