fix(linter): stack overflow in oxc/no-async-endpoint-handlers (#6614)

Closes #6583
This commit is contained in:
DonIsaac 2024-10-16 06:37:11 +00:00
parent 78fe4af3ad
commit 41dc8e314e

View file

@ -231,6 +231,15 @@ impl NoAsyncEndpointHandlers {
AstKind::Function(f) => self.check_function(ctx, registered_at, id_name, f), AstKind::Function(f) => self.check_function(ctx, registered_at, id_name, f),
AstKind::VariableDeclarator(decl) => { AstKind::VariableDeclarator(decl) => {
if let Some(init) = &decl.init { if let Some(init) = &decl.init {
if let Expression::Identifier(id) = &init {
if decl
.id
.get_identifier()
.is_some_and(|declared| declared == id.name)
{
return;
}
}
self.check_endpoint_expr(ctx, id_name, registered_at, init); self.check_endpoint_expr(ctx, id_name, registered_at, init);
} }
} }
@ -334,6 +343,14 @@ fn test() {
", ",
Some(json!([ { "allowedNames": ["middleware"] } ])), Some(json!([ { "allowedNames": ["middleware"] } ])),
), ),
// https://github.com/oxc-project/oxc/issues/6583
(
"
class B{o(a={}){const attribute=attribute
c.get(attribute)}}
",
None,
),
]; ];
let fail = vec![ let fail = vec![