mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(linter): fix panic in fixer for oxc/only-used-in-recursion (#6070)
closes #6068
This commit is contained in:
parent
01b9c4bedc
commit
c2616f7fa1
2 changed files with 14 additions and 6 deletions
|
|
@ -234,15 +234,13 @@ fn is_function_maybe_reassigned<'a>(
|
|||
// skipping whitespace, commas, finds the next character (exclusive)
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
fn skip_to_next_char(s: &str, start: u32) -> u32 {
|
||||
let mut i = start as usize;
|
||||
while i < s.len() {
|
||||
let c = s.chars().nth(i).unwrap();
|
||||
for (i, c) in s.char_indices().skip(start as usize) {
|
||||
if !c.is_whitespace() && c != ',' {
|
||||
break;
|
||||
return i as u32;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
i as u32
|
||||
|
||||
s.len() as u32
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -401,6 +399,8 @@ fn test() {
|
|||
return a(arg0);
|
||||
}
|
||||
",
|
||||
"//¿
|
||||
function writeChunks(a,callac){writeChunks(m,callac)}writeChunks(i,{})",
|
||||
];
|
||||
|
||||
let fix = vec![
|
||||
|
|
|
|||
|
|
@ -72,3 +72,11 @@ source: crates/oxc_linter/src/tester.rs
|
|||
3 │ return a(arg0);
|
||||
╰────
|
||||
help: Remove the argument and its usage. Alternatively, use the argument in the function body.
|
||||
|
||||
⚠ oxc(only-used-in-recursion): Parameter `callac` is only used in recursive calls
|
||||
╭─[only_used_in_recursion.tsx:2:24]
|
||||
1 │ //¿
|
||||
2 │ function writeChunks(a,callac){writeChunks(m,callac)}writeChunks(i,{})
|
||||
· ──────
|
||||
╰────
|
||||
help: Remove the argument and its usage. Alternatively, use the argument in the function body.
|
||||
|
|
|
|||
Loading…
Reference in a new issue