Skip to content

Commit

Permalink
fix(linter): panic in consistent-function-scoping (#5613)
Browse files Browse the repository at this point in the history
Closes #5608
  • Loading branch information
DonIsaac committed Sep 9, 2024
1 parent d22a9b7 commit af6d240
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions crates/oxc_linter/src/rules/unicorn/consistent_function_scoping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,23 @@ impl Rule for ConsistentFunctionScoping {
}),
)
} else if let Some(function_id) = &function.id {
(function_id.symbol_id.get().unwrap(), function_body, function_id.span())
let Some(symbol_id) = function_id.symbol_id.get() else {
return;
};
(symbol_id, function_body, function_id.span())
} else {
return;
}
}
AstKind::ArrowFunctionExpression(arrow_function) if self.check_arrow_functions => {
if let Some(binding_ident) = get_function_like_declaration(node, ctx) {
(
binding_ident.symbol_id.get().unwrap(),
&arrow_function.body,
binding_ident.span(),
)
} else {
let Some(binding_ident) = get_function_like_declaration(node, ctx) else {
return;
}
};
let Some(symbol_id) = binding_ident.symbol_id.get() else {
return;
};

(symbol_id, &arrow_function.body, binding_ident.span())
}
_ => return,
};
Expand Down Expand Up @@ -586,6 +588,7 @@ fn test() {
("module.exports = function foo() {};", None),
("module.exports.foo = function foo() {};", None),
("foo.bar.func = function foo() {};", None),
("if(f) function f(){}", None),
];

let fail = vec![
Expand Down

0 comments on commit af6d240

Please sign in to comment.