Skip to content

Commit

Permalink
fix(linter) fix bug in fixer for func-name,closes #5128
Browse files Browse the repository at this point in the history
  • Loading branch information
camc314 committed Aug 23, 2024
1 parent f7958c4 commit f2659e5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/oxc_linter/src/rules/eslint/func_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ impl Rule for FuncNames {
let func_name = get_function_name(func);
let func_name_complete = get_function_name_with_kind(func, parent_node);

let span = Span::new(func.span.start, func.params.span.start);
let span = Span::sized(func.span.start, 8);
if func_name.is_some() {
ctx.diagnostic_with_suggestion(
named_diagnostic(&func_name_complete, span),
Expand Down Expand Up @@ -729,6 +729,11 @@ fn test() {
never.clone(),
),
("class C { foo = function foo() {} }", "class C { foo = function () {} }", never.clone()),
(
"const restoreGracefully = function <T>(entries: T[]) { }",
"const restoreGracefully = function restoreGracefully <T>(entries: T[]) { }",
None,
),
];

Tester::new(FuncNames::NAME, pass, fail).expect_fix(fix).test_and_snapshot();
Expand Down

0 comments on commit f2659e5

Please sign in to comment.