@@ -24,12 +24,12 @@ const rule = ruleCreator({
2424 defaultOptions,
2525 meta : {
2626 docs : {
27- category : "Best Practices" ,
2827 description :
2928 "Forbids `subscribe` calls that are not composed within Angular components (and, optionally, within services, directives, and pipes)." ,
3029 recommended : false ,
3130 } ,
3231 fixable : undefined ,
32+ hasSuggestions : false ,
3333 messages : {
3434 notComposed : "Subscription not composed." ,
3535 notDeclared : "Composed subscription `{{name}}` not a class property." ,
@@ -58,7 +58,7 @@ const rule = ruleCreator({
5858 type Entry = {
5959 addCallExpressions : es . CallExpression [ ] ;
6060 classDeclaration : es . ClassDeclaration ;
61- classProperties : es . ClassProperty [ ] ;
61+ propertyDefinitions : es . PropertyDefinition [ ] ;
6262 hasDecorator : boolean ;
6363 ngOnDestroyDefinition ?: es . MethodDefinition ;
6464 subscribeCallExpressions : es . CallExpression [ ] ;
@@ -70,7 +70,7 @@ const rule = ruleCreator({
7070 function checkEntry ( record : Entry ) {
7171 const {
7272 classDeclaration,
73- classProperties ,
73+ propertyDefinitions ,
7474 ngOnDestroyDefinition,
7575 subscribeCallExpressions,
7676 subscriptions,
@@ -106,10 +106,11 @@ const rule = ruleCreator({
106106 }
107107
108108 subscriptions . forEach ( ( subscription ) => {
109- const classProperty = classProperties . find (
110- ( classProperty : any ) => classProperty . key . name === subscription
109+ const propertyDefinition = propertyDefinitions . find (
110+ ( propertyDefinition : any ) =>
111+ propertyDefinition . key . name === subscription
111112 ) ;
112- if ( ! classProperty ) {
113+ if ( ! propertyDefinition ) {
113114 context . report ( {
114115 data : { name : subscription } ,
115116 messageId : "notDeclared" ,
@@ -128,7 +129,7 @@ const rule = ruleCreator({
128129 context . report ( {
129130 data : { name : subscription } ,
130131 messageId : "notUnsubscribed" ,
131- node : classProperty . key ,
132+ node : propertyDefinition . key ,
132133 } ) ;
133134 return ;
134135 }
@@ -260,7 +261,7 @@ const rule = ruleCreator({
260261 entries . push ( {
261262 addCallExpressions : [ ] ,
262263 classDeclaration : node ,
263- classProperties : [ ] ,
264+ propertyDefinitions : [ ] ,
264265 hasDecorator : hasDecorator ( node ) ,
265266 subscribeCallExpressions : [ ] ,
266267 subscriptions : new Set < string > ( ) ,
@@ -273,10 +274,10 @@ const rule = ruleCreator({
273274 checkEntry ( entry ) ;
274275 }
275276 } ,
276- ClassProperty : ( node : es . ClassProperty ) => {
277+ PropertyDefinition : ( node : es . PropertyDefinition ) => {
277278 const entry = getEntry ( ) ;
278279 if ( entry && entry . hasDecorator ) {
279- entry . classProperties . push ( node ) ;
280+ entry . propertyDefinitions . push ( node ) ;
280281 }
281282 } ,
282283 "MethodDefinition[key.name='ngOnDestroy'][kind='method']" : (
@@ -287,14 +288,13 @@ const rule = ruleCreator({
287288 entry . ngOnDestroyDefinition = node ;
288289 }
289290 } ,
290- "MethodDefinition[key.name='ngOnDestroy'][kind='method'] CallExpression[callee.property.name='unsubscribe']" : (
291- node : es . CallExpression
292- ) => {
293- const entry = getEntry ( ) ;
294- if ( entry && entry . hasDecorator ) {
295- entry . unsubscribeCallExpressions . push ( node ) ;
296- }
297- } ,
291+ "MethodDefinition[key.name='ngOnDestroy'][kind='method'] CallExpression[callee.property.name='unsubscribe']" :
292+ ( node : es . CallExpression ) => {
293+ const entry = getEntry ( ) ;
294+ if ( entry && entry . hasDecorator ) {
295+ entry . unsubscribeCallExpressions . push ( node ) ;
296+ }
297+ } ,
298298 } ;
299299 } ,
300300} ) ;
0 commit comments