mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(linter): AllowFunction doesn't support generator (#2277)
This commit is contained in:
parent
3cb85778bc
commit
37a2676e1e
1 changed files with 6 additions and 10 deletions
|
|
@ -43,19 +43,14 @@ impl Rule for RequireYield {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let span = match kind {
|
if let AstKind::Function(func) = kind {
|
||||||
AstKind::Function(func)
|
if func.generator && func.body.as_ref().is_some_and(|body| !body.statements.is_empty())
|
||||||
if func.generator
|
|
||||||
&& func.body.as_ref().is_some_and(|body| !body.statements.is_empty()) =>
|
|
||||||
{
|
{
|
||||||
func.id.as_ref().map_or_else(|| kind.span(), |ident| ident.span)
|
let span = func.id.as_ref().map_or_else(|| kind.span(), |ident| ident.span);
|
||||||
}
|
|
||||||
AstKind::ArrowExpression(arrow) if !arrow.body.statements.is_empty() => arrow.span,
|
|
||||||
_ => return,
|
|
||||||
};
|
|
||||||
|
|
||||||
ctx.diagnostic(RequireYieldDiagnostic(span));
|
ctx.diagnostic(RequireYieldDiagnostic(span));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -72,6 +67,7 @@ fn test() {
|
||||||
("var obj = { *foo() { } };", None),
|
("var obj = { *foo() { } };", None),
|
||||||
("class A { *foo() { yield 0; } };", None),
|
("class A { *foo() { yield 0; } };", None),
|
||||||
("class A { *foo() { } };", None),
|
("class A { *foo() { } };", None),
|
||||||
|
("() => {}", None),
|
||||||
];
|
];
|
||||||
|
|
||||||
let fail = vec![
|
let fail = vec![
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue