mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
feat(linter): Fix suggestion for eslint:no_empty_static_block rule (#6732)
Relates to https://github.com/oxc-project/oxc/issues/4179 --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
ab0353553a
commit
619d06f004
1 changed files with 18 additions and 3 deletions
|
|
@ -48,7 +48,7 @@ declare_oxc_lint!(
|
|||
/// ```
|
||||
NoEmptyStaticBlock,
|
||||
correctness,
|
||||
pending // TODO: add a safe suggestion
|
||||
suggestion,
|
||||
);
|
||||
|
||||
impl Rule for NoEmptyStaticBlock {
|
||||
|
|
@ -58,7 +58,10 @@ impl Rule for NoEmptyStaticBlock {
|
|||
if ctx.semantic().has_comments_between(static_block.span) {
|
||||
return;
|
||||
}
|
||||
ctx.diagnostic(no_empty_static_block_diagnostic(static_block.span));
|
||||
ctx.diagnostic_with_suggestion(
|
||||
no_empty_static_block_diagnostic(static_block.span),
|
||||
|fixer| fixer.delete(&static_block.span),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -86,5 +89,17 @@ fn test() {
|
|||
"class Foo { static { bar(); } static {} }",
|
||||
];
|
||||
|
||||
Tester::new(NoEmptyStaticBlock::NAME, pass, fail).test_and_snapshot();
|
||||
let fix = vec![
|
||||
("class Foo { static {} }", "class Foo { }"),
|
||||
("class Foo { static { } }", "class Foo { }"),
|
||||
(
|
||||
"class Foo { static {
|
||||
|
||||
} }",
|
||||
"class Foo { }",
|
||||
),
|
||||
("class Foo { static { bar(); } static {} }", "class Foo { static { bar(); } }"),
|
||||
];
|
||||
|
||||
Tester::new(NoEmptyStaticBlock::NAME, pass, fail).expect_fix(fix).test_and_snapshot();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue