@@ -28,6 +28,52 @@ ruleTester.run("strategy-onpush", strategyOnPush, {
28
28
}
29
29
` ,
30
30
} ,
31
+ {
32
+ name : "Injected dependency, no strategy onpush" ,
33
+ code : `
34
+ @Component({
35
+ selector: 'app-root',
36
+ })
37
+ public class AppComponent {
38
+ someService = inject(Service);
39
+ }
40
+ ` ,
41
+ } ,
42
+ {
43
+ name : "Input, no property" ,
44
+ code : `
45
+ @Component({
46
+ selector: 'app-root',
47
+ changeDetection: ChangeDetectionStrategy.OnPush,
48
+ })
49
+ public class AppComponent {
50
+ @Input() someInput: string;
51
+ }
52
+ ` ,
53
+ } ,
54
+ {
55
+ name : "Input signal, no property" ,
56
+ code : `
57
+ @Component({
58
+ selector: 'app-root',
59
+ changeDetection: ChangeDetectionStrategy.OnPush,
60
+ })
61
+ public class AppComponent {
62
+ someInput = input("some");
63
+ }
64
+ ` ,
65
+ } ,
66
+ {
67
+ name : "property that is not an input nor an output" ,
68
+ code : `
69
+ @Component({
70
+ selector: 'app-root',
71
+ })
72
+ public class AppComponent {
73
+ someInput = signal();
74
+ }
75
+ ` ,
76
+ }
31
77
] ,
32
78
invalid : [
33
79
{
@@ -57,5 +103,41 @@ public class AppComponent {}`,
57
103
} ,
58
104
] ,
59
105
} ,
106
+ {
107
+ name : "property that is not an input nor an output" ,
108
+ code : `
109
+ @Component({
110
+ selector: 'app-root',
111
+ })
112
+ public class AppComponent {
113
+ someInput = input('');
114
+ }` ,
115
+ output : `
116
+ @Component({
117
+ selector: 'app-root',
118
+ changeDetection: ChangeDetectionStrategy.OnPush,
119
+ })
120
+ public class AppComponent {
121
+ someInput = input('');
122
+ }` ,
123
+ errors : [
124
+ {
125
+ messageId : "strategyOnPush" ,
126
+ suggestions : [
127
+ {
128
+ messageId : 'strategyOnPushSuggestion' ,
129
+ output : `
130
+ @Component({
131
+ selector: 'app-root',
132
+ changeDetection: ChangeDetectionStrategy.OnPush,
133
+ })
134
+ public class AppComponent {
135
+ someInput = input('');
136
+ }` ,
137
+ } ,
138
+ ] ,
139
+ } ,
140
+ ] ,
141
+ }
60
142
] ,
61
143
} ) ;
0 commit comments