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
3 changes: 2 additions & 1 deletion crates/oxc_linter/src/generated/rule_runner_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2949,7 +2949,8 @@ impl RuleRunner for crate::rules::typescript::use_unknown_in_catch_callback_vari
}

impl RuleRunner for crate::rules::unicorn::catch_error_name::CatchErrorName {
const NODE_TYPES: Option<&AstTypesBitset> = None;
const NODE_TYPES: Option<&AstTypesBitset> =
Some(&AstTypesBitset::from_types(&[AstType::CallExpression, AstType::CatchParameter]));
const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run;
}

Expand Down
32 changes: 17 additions & 15 deletions crates/oxc_linter/src/rules/unicorn/catch_error_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,24 +152,26 @@ impl Rule for CatchErrorName {
}

fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {
if let AstKind::CatchParameter(catch_param) = node.kind() {
self.check_binding_identifier(ctx, &catch_param.pattern.kind);
}

if let AstKind::CallExpression(call_expr) = node.kind()
&& let Some(member_expr) = call_expr.callee.as_member_expression()
{
if member_expr.static_property_name() == Some("catch")
&& let Some(arg) = call_expr.arguments.first()
{
self.check_function_arguments(arg, ctx);
match node.kind() {
AstKind::CatchParameter(catch_param) => {
self.check_binding_identifier(ctx, &catch_param.pattern.kind);
}
AstKind::CallExpression(call_expr) => {
if let Some(member_expr) = call_expr.callee.as_member_expression() {
if member_expr.static_property_name() == Some("catch")
&& let Some(arg) = call_expr.arguments.first()
{
self.check_function_arguments(arg, ctx);
}

if member_expr.static_property_name() == Some("then")
&& let Some(arg) = call_expr.arguments.get(1)
{
self.check_function_arguments(arg, ctx);
if member_expr.static_property_name() == Some("then")
&& let Some(arg) = call_expr.arguments.get(1)
{
self.check_function_arguments(arg, ctx);
}
}
}
_ => {}
}
}
}
Expand Down
Loading