Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl<'s, 'a> Symbol<'s, 'a> {
Symbol<'s, 'a>: PartialEq<T>,
{
let Some(own_position) = list.iter().position(|el| self == el) else {
debug_assert!(false, "Symbol not found within its own parent declaration list");
// Happens when the symbol is in a destructuring pattern.
return fixer.noop();
};
let mut delete_range = own.span();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ fn test_vars_destructure() {
"const { a: { b }, ...rest } = obj; console.log(rest)",
Some(json!( [{ "ignoreRestSiblings": true }] )),
),
// https://github.com/oxc-project/oxc/issues/4839
(r#"const l="",{e}=r"#, None),
];

let fix = vec![
Expand Down Expand Up @@ -339,6 +341,8 @@ fn test_vars_destructure() {
None,
FixKind::DangerousSuggestion,
),
// TODO: destructures in VariableDeclarations with more than one declarator
(r#"const l="",{e}=r"#, r"const {e}=r", None, FixKind::All),
// renaming
// (
// "let a = 1; a = 2;",
Expand Down
16 changes: 16 additions & 0 deletions crates/oxc_linter/src/snapshots/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,19 @@ source: crates/oxc_linter/src/tester.rs
· ╰── 'b' is declared here
╰────
help: Consider removing this declaration.

⚠ eslint(no-unused-vars): Variable 'l' is declared but never used.
╭─[no_unused_vars.tsx:1:7]
1 │ const l="",{e}=r
· ┬
· ╰── 'l' is declared here
╰────
help: Consider removing this declaration.

⚠ eslint(no-unused-vars): Variable 'e' is declared but never used.
╭─[no_unused_vars.tsx:1:13]
1 │ const l="",{e}=r
· ┬
· ╰── 'e' is declared here
╰────
help: Consider removing this declaration.