File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
crates/oxc_linter/src/rules/eslint/array_callback_return Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -426,6 +426,10 @@ fn test() {
426426 ( "foo[`${every}`](function() {})" , None ) ,
427427 ( "foo.every(() => true)" , None ) ,
428428 ( "return function() {}" , None ) ,
429+ (
430+ "array.map((node) => { if (isTaskNode(node)) { return someObj; } else if (isOtherNode(node)) { return otherObj; } else { throw new Error('Unsupported'); } })" ,
431+ None ,
432+ ) ,
429433 ] ;
430434
431435 let fail = vec ! [
Original file line number Diff line number Diff line change @@ -200,6 +200,8 @@ pub fn check_statement(statement: &Statement) -> StatementReturnStatus {
200200 status
201201 }
202202
203+ Statement :: ThrowStatement ( _) => StatementReturnStatus :: AlwaysExplicit ,
204+
203205 _ => StatementReturnStatus :: NotReturn ,
204206 }
205207}
@@ -448,4 +450,30 @@ mod tests {
448450 " ;
449451 parse_statement_and_test ( source, StatementReturnStatus :: AlwaysImplicit ) ;
450452 }
453+
454+ #[ test]
455+ fn test_throw_statement ( ) {
456+ let source = "
457+ function foo() {
458+ throw new Error('test');
459+ }
460+ " ;
461+ parse_statement_and_test ( source, StatementReturnStatus :: AlwaysExplicit ) ;
462+ }
463+
464+ #[ test]
465+ fn test_if_with_throw ( ) {
466+ let source = "
467+ function foo() {
468+ if (a) {
469+ return 1;
470+ } else if (b) {
471+ return 2;
472+ } else {
473+ throw new Error('test');
474+ }
475+ }
476+ " ;
477+ parse_statement_and_test ( source, StatementReturnStatus :: AlwaysExplicit ) ;
478+ }
451479}
You can’t perform that action at this time.
0 commit comments