Skip to content

Commit

Permalink
fix(linter/tree-shaking): align JSXMemberExpression's report (#5548)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysteryven committed Sep 6, 2024
1 parent 14ee086 commit c8ab353
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <X.Y />
· ───────
·
╰────

eslint-plugin-tree-shaking(no-side-effects-in-initialization): Cannot determine side-effects of calling global function `ext`
Expand Down

0 comments on commit c8ab353

Please sign in to comment.