@@ -90,67 +90,64 @@ impl Rule for NoDoneCallback {
90
90
91
91
fn run < ' a > ( possible_jest_node : & PossibleJestNode < ' a , ' _ > , ctx : & LintContext < ' a > ) {
92
92
let node = possible_jest_node. node ;
93
- if let AstKind :: CallExpression ( call_expr) = node. kind ( ) {
94
- if let Some ( jest_fn_call) = parse_general_jest_fn_call ( call_expr, possible_jest_node, ctx) {
95
- let kind = jest_fn_call. kind ;
96
- if !matches ! (
97
- kind,
98
- JestFnKind :: General ( JestGeneralFnKind :: Test | JestGeneralFnKind :: Hook )
99
- ) {
100
- return ;
101
- }
93
+ let AstKind :: CallExpression ( call_expr) = node. kind ( ) else { return } ;
94
+ let Some ( jest_fn_call) = parse_general_jest_fn_call ( call_expr, possible_jest_node, ctx) else {
95
+ return ;
96
+ } ;
102
97
103
- let is_jest_each = get_node_name ( & call_expr. callee ) . ends_with ( "each" ) ;
98
+ let kind = jest_fn_call. kind ;
99
+ if !matches ! ( kind, JestFnKind :: General ( JestGeneralFnKind :: Test | JestGeneralFnKind :: Hook ) ) {
100
+ return ;
101
+ }
104
102
105
- if is_jest_each && !matches ! ( call_expr. callee, Expression :: TaggedTemplateExpression ( _) )
106
- {
107
- // isJestEach but not a TaggedTemplateExpression, so this must be
108
- // the `jest.each([])()` syntax which this rule doesn't support due
109
- // to its complexity (see jest-community/eslint-plugin-jest#710)
110
- return ;
111
- }
103
+ let is_jest_each = get_node_name ( & call_expr. callee ) . ends_with ( "each" ) ;
112
104
113
- let Some ( arg) = find_argument_of_callback ( call_expr, is_jest_each, kind) else {
114
- return ;
115
- } ;
105
+ if is_jest_each && !matches ! ( call_expr. callee, Expression :: TaggedTemplateExpression ( _) ) {
106
+ // isJestEach but not a TaggedTemplateExpression, so this must be
107
+ // the `jest.each([])()` syntax which this rule doesn't support due
108
+ // to its complexity (see jest-community/eslint-plugin-jest#710)
109
+ return ;
110
+ }
116
111
117
- let callback_arg_index = usize:: from ( is_jest_each) ;
112
+ let Some ( arg) = find_argument_of_callback ( call_expr, is_jest_each, kind) else {
113
+ return ;
114
+ } ;
118
115
119
- match arg {
120
- Argument :: FunctionExpression ( func_expr) => {
121
- if func_expr. params . parameters_count ( ) != 1 + callback_arg_index {
122
- return ;
123
- }
124
- let Some ( span) = get_span_of_first_parameter ( & func_expr. params ) else {
125
- return ;
126
- } ;
116
+ let callback_arg_index = usize:: from ( is_jest_each) ;
127
117
128
- if func_expr. r#async {
129
- ctx. diagnostic ( use_await_instead_of_callback ( span) ) ;
130
- return ;
131
- }
118
+ match arg {
119
+ Argument :: FunctionExpression ( func_expr) => {
120
+ if func_expr. params . parameters_count ( ) != 1 + callback_arg_index {
121
+ return ;
122
+ }
123
+ let Some ( span) = get_span_of_first_parameter ( & func_expr. params ) else {
124
+ return ;
125
+ } ;
132
126
133
- ctx. diagnostic ( no_done_callback ( span) ) ;
134
- }
135
- Argument :: ArrowFunctionExpression ( arrow_expr) => {
136
- if arrow_expr. params . parameters_count ( ) != 1 + callback_arg_index {
137
- return ;
138
- }
127
+ if func_expr. r#async {
128
+ ctx. diagnostic ( use_await_instead_of_callback ( span) ) ;
129
+ return ;
130
+ }
139
131
140
- let Some ( span) = get_span_of_first_parameter ( & arrow_expr. params ) else {
141
- return ;
142
- } ;
132
+ ctx. diagnostic ( no_done_callback ( span) ) ;
133
+ }
134
+ Argument :: ArrowFunctionExpression ( arrow_expr) => {
135
+ if arrow_expr. params . parameters_count ( ) != 1 + callback_arg_index {
136
+ return ;
137
+ }
143
138
144
- if arrow_expr. r#async {
145
- ctx. diagnostic ( use_await_instead_of_callback ( span) ) ;
146
- return ;
147
- }
139
+ let Some ( span) = get_span_of_first_parameter ( & arrow_expr. params ) else {
140
+ return ;
141
+ } ;
148
142
149
- ctx . diagnostic ( no_done_callback ( span ) ) ;
150
- }
151
- _ => { }
143
+ if arrow_expr . r#async {
144
+ ctx . diagnostic ( use_await_instead_of_callback ( span ) ) ;
145
+ return ;
152
146
}
147
+
148
+ ctx. diagnostic ( no_done_callback ( span) ) ;
153
149
}
150
+ _ => { }
154
151
}
155
152
}
156
153
0 commit comments