@@ -120,6 +120,40 @@ export default createTestingLibraryRule<Options, MessageIds>({
120120			return  node . expressions . some ( isRenderInAssignmentExpression ) ; 
121121		} 
122122
123+ 		/** 
124+ 		 * Checks if there are side effects in variable declarations. 
125+ 		 * 
126+ 		 * For example, these variable declarations have side effects: 
127+ 		 * const a = userEvent.doubleClick(button); 
128+ 		 * const b = fireEvent.click(button); 
129+ 		 * const wrapper = render(<Component />); 
130+ 		 * 
131+ 		 * @param  node 
132+ 		 * @returns  {Boolean } Boolean indicating if variable declarataion has side effects 
133+ 		 */ 
134+ 		function  isSideEffectInVariableDeclaration ( 
135+ 			node : TSESTree . VariableDeclaration 
136+ 		) : boolean  { 
137+ 			return  node . declarations . some ( ( declaration )  =>  { 
138+ 				if  ( isCallExpression ( declaration . init ) )  { 
139+ 					const  test  =  getPropertyIdentifierNode ( declaration . init ) ; 
140+ 
141+ 					if  ( ! test )  { 
142+ 						return  false ; 
143+ 					} 
144+ 
145+ 					return  ( 
146+ 						helpers . isFireEventUtil ( test )  || 
147+ 						helpers . isUserEventUtil ( test )  || 
148+ 						helpers . isRenderUtil ( test ) 
149+ 					) ; 
150+ 				} 
151+ 				return  false ; 
152+ 			} ) ; 
153+ 
154+ 			return  false ; 
155+ 		} 
156+ 
123157		function  getSideEffectNodes ( 
124158			body : TSESTree . Node [ ] 
125159		) : TSESTree . ExpressionStatement [ ]  { 
@@ -135,6 +169,13 @@ export default createTestingLibraryRule<Options, MessageIds>({
135169					return  true ; 
136170				} 
137171
172+ 				if  ( 
173+ 					isVariableDeclaration ( node )  && 
174+ 					isSideEffectInVariableDeclaration ( node ) 
175+ 				)  { 
176+ 					return  true ; 
177+ 				} 
178+ 
138179				const  expressionIdentifier  =  getPropertyIdentifierNode ( node ) ; 
139180
140181				if  ( ! expressionIdentifier )  { 
0 commit comments