Skip to content

Commit

Permalink
fix(linter): fix top level return panic in eslint/array_callback_retu…
Browse files Browse the repository at this point in the history
…rn (#4167)
  • Loading branch information
Boshen committed Jul 10, 2024
1 parent 7967237 commit f3f06a5
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub fn get_array_method_name<'a>(
// return function() {}
// }())
AstKind::ReturnStatement(_) => {
let func_node = get_enclosing_function(parent, ctx).unwrap();
let Some(func_node) = get_enclosing_function(parent, ctx) else { break };
let func_node = outermost_paren(func_node, ctx);

// the node that calls func_node
Expand Down Expand Up @@ -408,6 +408,7 @@ fn test() {
("var every = function() {}", None),
("foo[`${every}`](function() {})", None),
("foo.every(() => true)", None),
("return function() {}", None),
];

let fail = vec![
Expand Down

0 comments on commit f3f06a5

Please sign in to comment.