Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Feb 27, 2025
1 parent b77778d commit 8c93700
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions crates/swc_ecma_lints/src/rules/prefer_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,16 @@ impl PreferConst {
Pat::Assign(AssignPat { left, .. }) => {
self.collect_decl_pat(initialized, left.as_ref());
}
Pat::Array(ArrayPat { elems, .. }) => {
Pat::Array(arr) => {
let ArrayPat { elems, .. } = &**arr;

elems.iter().flatten().for_each(|elem| {
self.collect_decl_pat(initialized, elem);
});
}
Pat::Object(ObjectPat { props, .. }) => {
Pat::Object(obj) => {
let ObjectPat { props, .. } = &**obj;

props.iter().for_each(|prop| {
match prop {
ObjectPatProp::KeyValue(KeyValuePatProp { value, .. }) => {
Expand Down Expand Up @@ -169,10 +173,16 @@ impl PreferConst {
Pat::Ident(id) => {
self.consider_mutation_for_ident(&Ident::from(id), destructuring_assign);
}
Pat::Array(ArrayPat { elems, .. }) => elems.iter().flatten().for_each(|elem| {
self.consider_mutation(elem, destructuring_assign);
}),
Pat::Object(ObjectPat { props, .. }) => {
Pat::Array(arr) => {
let ArrayPat { elems, .. } = &**arr;

elems.iter().flatten().for_each(|elem| {
self.consider_mutation(elem, destructuring_assign);
});
}
Pat::Object(obj) => {
let ObjectPat { props, .. } = &**obj;

props.iter().for_each(|prop| match prop {
ObjectPatProp::KeyValue(KeyValuePatProp { value, .. }) => {
self.consider_mutation(value.as_ref(), true);
Expand Down Expand Up @@ -241,12 +251,16 @@ impl Visit for PreferConst {
}

AssignTarget::Pat(pat) => match pat {
AssignTargetPat::Array(ArrayPat { elems, .. }) => {
AssignTargetPat::Array(arr) => {
let ArrayPat { elems, .. } = &**arr;

elems.iter().flatten().for_each(|elem| {
self.consider_mutation(elem, true);
})
}
AssignTargetPat::Object(ObjectPat { props, .. }) => {
AssignTargetPat::Object(obj) => {
let ObjectPat { props, .. } = &**obj;

props.iter().for_each(|prop| match prop {
ObjectPatProp::KeyValue(KeyValuePatProp { value, .. }) => {
self.consider_mutation(value.as_ref(), true);
Expand Down

0 comments on commit 8c93700

Please sign in to comment.