mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(linter): false positive in eslint/no-lone-blocks (#8587)
closes #8515
This commit is contained in:
parent
ee8ee55cda
commit
c15af02e52
2 changed files with 15 additions and 12 deletions
|
|
@ -63,7 +63,9 @@ impl Rule for NoLoneBlocks {
|
|||
|
||||
let body = &stmt.body;
|
||||
if body.is_empty() {
|
||||
if !matches!(parent_node.kind(), AstKind::TryStatement(_) | AstKind::CatchClause(_)) {
|
||||
report(ctx, node, parent_node);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -206,6 +208,8 @@ fn test() {
|
|||
{
|
||||
await using x = makeDisposable();
|
||||
}", // { "parser": require(parser("typescript-parsers/no-lone-blocks/await-using")), "ecmaVersion": 2022 }
|
||||
// Issue: <https://github.com/oxc-project/oxc/issues/8515>
|
||||
"try {} catch {}",
|
||||
];
|
||||
|
||||
let fail = vec![
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
source: crates/oxc_linter/src/tester.rs
|
||||
snapshot_kind: text
|
||||
---
|
||||
⚠ eslint(no-lone-blocks): Block is unnecessary.
|
||||
╭─[no_lone_blocks.tsx:1:1]
|
||||
|
|
|
|||
Loading…
Reference in a new issue