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
26 changes: 18 additions & 8 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1321,14 +1321,24 @@ impl<'a> BindingPatternKind<'a> {
match self {
Self::BindingIdentifier(ident) => idents.push(ident),
Self::AssignmentPattern(assign) => assign.left.kind.append_binding_identifiers(idents),
Self::ArrayPattern(pattern) => pattern
.elements
.iter()
.filter_map(|item| item.as_ref())
.for_each(|item| item.kind.append_binding_identifiers(idents)),
Self::ObjectPattern(pattern) => pattern.properties.iter().for_each(|item| {
item.value.kind.append_binding_identifiers(idents);
}),
Self::ArrayPattern(pattern) => {
pattern
.elements
.iter()
.filter_map(|item| item.as_ref())
.for_each(|item| item.kind.append_binding_identifiers(idents));
if let Some(rest) = &pattern.rest {
rest.argument.kind.append_binding_identifiers(idents);
}
}
Self::ObjectPattern(pattern) => {
pattern.properties.iter().for_each(|item| {
item.value.kind.append_binding_identifiers(idents);
});
if let Some(rest) = &pattern.rest {
rest.argument.kind.append_binding_identifiers(idents);
}
}
}
}

Expand Down
6 changes: 2 additions & 4 deletions crates/oxc_linter/src/generated/rule_runner_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,8 @@ impl RuleRunner for crate::rules::eslint::no_console::NoConsole {
}

impl RuleRunner for crate::rules::eslint::no_const_assign::NoConstAssign {
const NODE_TYPES: Option<&AstTypesBitset> = Some(&AstTypesBitset::from_types(&[
AstType::BindingRestElement,
AstType::VariableDeclarator,
]));
const NODE_TYPES: Option<&AstTypesBitset> =
Some(&AstTypesBitset::from_types(&[AstType::VariableDeclarator]));
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
}

Expand Down
5 changes: 0 additions & 5 deletions crates/oxc_linter/src/rules/eslint/no_const_assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ impl Rule for NoConstAssign {
check_symbol_id(ident.symbol_id(), ctx);
}
}
AstKind::BindingRestElement(rest) => {
for ident in rest.argument.get_binding_identifiers() {
check_symbol_id(ident.symbol_id(), ctx);
}
}
_ => {}
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/oxc_minifier/src/peephole/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ mod test {
test("for (const x in y);", "for (let x in y);");
// TypeError: Assignment to constant variable.
test_same("for (const i = 0; i < 1; i++);");
test_same("{ const { a, ...b } = foo; b = 123; }");
test_same("{ const [a, ...b] = foo; b = 123; }");
test_same("for (const x in [1, 2, 3]) x++");
test_same("for (const x of [1, 2, 3]) x++");
test("{ let foo; const bar = undefined; }", "{ let foo, bar; }");
Expand Down
Loading