File tree Expand file tree Collapse file tree 2 files changed +31
-8
lines changed
crates/oxc_linter/src/rules/jest/no_standalone_expect Expand file tree Collapse file tree 2 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -215,14 +215,25 @@ fn is_var_declarator_or_test_block<'a>(
215215 return true ;
216216 }
217217 }
218- AstKind :: Argument ( _) => {
219- if let Some ( parent) = ctx. nodes ( ) . parent_node ( node. id ( ) ) {
220- return is_var_declarator_or_test_block (
221- parent,
222- additional_test_block_functions,
223- id_nodes_mapping,
224- ctx,
225- ) ;
218+ AstKind :: Argument ( _) | AstKind :: ArrayExpression ( _) | AstKind :: ObjectExpression ( _) => {
219+ let mut current = node;
220+ while let Some ( parent) = ctx. nodes ( ) . parent_node ( current. id ( ) ) {
221+ match parent. kind ( ) {
222+ AstKind :: CallExpression ( _) | AstKind :: VariableDeclarator ( _) => {
223+ return is_var_declarator_or_test_block (
224+ parent,
225+ additional_test_block_functions,
226+ id_nodes_mapping,
227+ ctx,
228+ ) ;
229+ }
230+ AstKind :: Argument ( _)
231+ | AstKind :: ArrayExpression ( _)
232+ | AstKind :: ObjectExpression ( _) => {
233+ current = parent;
234+ }
235+ _ => break ,
236+ }
226237 }
227238 }
228239 _ => { }
Original file line number Diff line number Diff line change @@ -62,6 +62,18 @@ fn test() {
6262 " ,
6363 Some ( serde_json:: json!( [ { "additionalTestBlockFunctions" : [ "each.test" ] } ] ) ) ,
6464 ) ,
65+ (
66+ r"function funcWithCallback(callback) { callback(5); }
67+ describe('testWithCallback', () => {
68+ it('should call the callback', (done) => {
69+ funcWithCallback((result) => {
70+ expect(result).toBe(5);
71+ done();
72+ });
73+ });
74+ });" ,
75+ None ,
76+ ) ,
6577 ] ;
6678
6779 let fail = vec ! [
You can’t perform that action at this time.
0 commit comments