Skip to content

Commit

Permalink
fix(es/lint): Remove box_patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Sep 18, 2023
1 parent e749328 commit b86b66f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
1 change: 0 additions & 1 deletion crates/swc_ecma_lints/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![cfg_attr(feature = "non_critical_lints", deny(unused))]
#![cfg_attr(feature = "non_critical_lints", deny(clippy::all))]
#![feature(box_patterns)]

pub mod config;
pub mod rule;
Expand Down
68 changes: 35 additions & 33 deletions crates/swc_ecma_lints/src/rules/no_alert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,46 +129,48 @@ impl NoAlert {
}
}

fn handle_member_expr(&mut self, member_expr: &MemberExpr) {
let MemberExpr { obj, prop, .. } = member_expr;

match obj.as_ref() {
Expr::Ident(obj) => {
if !self.is_satisfying_indent(obj) {
return;
}

self.obj = Some(obj.sym.clone());

self.handle_member_prop(prop);
}
Expr::This(_) => {
let inside_arrow_fn = self.is_inside_arrow_fn();
let inside_class = self.is_inside_class();

if inside_arrow_fn && inside_class {
return;
}

if !inside_arrow_fn && (inside_class || self.is_inside_object()) {
return;
}

self.handle_member_prop(prop);
}
_ => {}
}
}

fn handle_callee(&mut self, expr: &Expr) {
match expr {
Expr::Ident(ident) => {
if self.is_satisfying_indent(ident) {
self.prop = Some(ident.sym.clone());
}
}
Expr::Member(member_expr)
| Expr::OptChain(OptChainExpr {
base: box OptChainBase::Member(member_expr),
..
}) => {
let MemberExpr { obj, prop, .. } = member_expr;

match obj.as_ref() {
Expr::Ident(obj) => {
if !self.is_satisfying_indent(obj) {
return;
}

self.obj = Some(obj.sym.clone());

self.handle_member_prop(prop);
}
Expr::This(_) => {
let inside_arrow_fn = self.is_inside_arrow_fn();
let inside_class = self.is_inside_class();

if inside_arrow_fn && inside_class {
return;
}

if !inside_arrow_fn && (inside_class || self.is_inside_object()) {
return;
}

self.handle_member_prop(prop);
}
_ => {}
}
Expr::Member(member_expr) => self.handle_member_expr(member_expr),
Expr::OptChain(OptChainExpr { base, .. }) if base.is_member() => {
let member_expr = base.as_member().unwrap();
self.handle_member_expr(member_expr);
}
Expr::OptChain(opt_chain) => {
opt_chain.visit_children_with(self);
Expand Down
9 changes: 4 additions & 5 deletions crates/swc_ecma_lints/src/rules/radix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,10 @@ impl Radix {
Expr::Member(member_expr) => {
return self.extract_obj_and_prop_member_case(member_expr);
}
Expr::OptChain(OptChainExpr {
base: box OptChainBase::Member(member_expr),
..
}) => {
return self.extract_obj_and_prop_member_case(member_expr);
Expr::OptChain(OptChainExpr { base, .. }) => {
if let OptChainBase::Member(member_expr) = &**base {
return self.extract_obj_and_prop_member_case(member_expr);
}
}
Expr::Paren(ParenExpr { expr, .. }) => {
return self.extract_obj_and_prop(expr.as_ref());
Expand Down

0 comments on commit b86b66f

Please sign in to comment.