diff --git a/crates/oxc_linter/src/rules/tree_shaking/no_side_effects_in_initialization/listener_map.rs b/crates/oxc_linter/src/rules/tree_shaking/no_side_effects_in_initialization/listener_map.rs index 09db37c3234bc..427e880bfaa97 100644 --- a/crates/oxc_linter/src/rules/tree_shaking/no_side_effects_in_initialization/listener_map.rs +++ b/crates/oxc_linter/src/rules/tree_shaking/no_side_effects_in_initialization/listener_map.rs @@ -7,11 +7,11 @@ use oxc_ast::{ ConditionalExpression, Declaration, ExportSpecifier, Expression, ForStatementInit, FormalParameter, Function, IdentifierReference, JSXAttribute, JSXAttributeItem, JSXAttributeValue, JSXChild, JSXElement, JSXElementName, JSXExpression, - JSXExpressionContainer, JSXFragment, JSXMemberExpression, JSXMemberExpressionObject, - JSXOpeningElement, LogicalExpression, MemberExpression, ModuleExportName, NewExpression, - ObjectExpression, ObjectPropertyKind, ParenthesizedExpression, PrivateFieldExpression, - Program, PropertyKey, SequenceExpression, SimpleAssignmentTarget, Statement, - StaticMemberExpression, SwitchCase, ThisExpression, UnaryExpression, VariableDeclarator, + JSXExpressionContainer, JSXFragment, JSXMemberExpression, JSXOpeningElement, + LogicalExpression, MemberExpression, ModuleExportName, NewExpression, ObjectExpression, + ObjectPropertyKind, ParenthesizedExpression, PrivateFieldExpression, Program, PropertyKey, + SequenceExpression, SimpleAssignmentTarget, Statement, StaticMemberExpression, SwitchCase, + ThisExpression, UnaryExpression, VariableDeclarator, }, AstKind, }; @@ -799,17 +799,7 @@ impl<'a> ListenerMap for JSXElementName<'a> { impl<'a> ListenerMap for JSXMemberExpression<'a> { fn report_effects_when_called(&self, options: &NodeListenerOptions) { - self.object.report_effects_when_called(options); - } -} - -impl<'a> ListenerMap for JSXMemberExpressionObject<'a> { - fn report_effects_when_called(&self, options: &NodeListenerOptions) { - match self { - Self::IdentifierReference(ident) => ident.report_effects_when_called(options), - Self::MemberExpression(member) => member.report_effects_when_called(options), - Self::ThisExpression(expr) => expr.report_effects_when_called(options), - } + options.ctx.diagnostic(super::call_member(self.property.span())); } } diff --git a/crates/oxc_linter/src/snapshots/no_side_effects_in_initialization.snap b/crates/oxc_linter/src/snapshots/no_side_effects_in_initialization.snap index 2aead01f07f70..4e9b7ea1b2814 100644 --- a/crates/oxc_linter/src/snapshots/no_side_effects_in_initialization.snap +++ b/crates/oxc_linter/src/snapshots/no_side_effects_in_initialization.snap @@ -825,10 +825,10 @@ source: crates/oxc_linter/src/tester.rs · ─── ╰──── - ⚠ eslint-plugin-tree-shaking(no-side-effects-in-initialization): Cannot determine side-effects of calling - ╭─[no_side_effects_in_initialization.tsx:1:11] + ⚠ eslint-plugin-tree-shaking(no-side-effects-in-initialization): Cannot determine side-effects of calling member function + ╭─[no_side_effects_in_initialization.tsx:1:34] 1 │ const X = {Y: ext}; const x = - · ──────── + · ─ ╰──── ⚠ eslint-plugin-tree-shaking(no-side-effects-in-initialization): Cannot determine side-effects of calling global function `ext`