-
-
Notifications
You must be signed in to change notification settings - Fork 930
Closed
Closed
Copy link
Labels
A-astArea - ASTArea - AST
Description
#5223 did the bulk of the work of revamping JSXElementName (#3528). Only thing that's missing is to add:
JSXElementName::ThisExpressionJSXMemberExpressionObject::ThisExpression
A couple of notes:
Arrow functions transform
This code is currently broken:
oxc/crates/oxc_transformer/src/es2015/arrow_functions.rs
Lines 140 to 156 in f052a6d
| let ident = match name { | |
| JSXElementName::Identifier(ident) => ident, | |
| JSXElementName::MemberExpression(member_expr) => { | |
| member_expr.get_object_identifier_mut() | |
| } | |
| JSXElementName::IdentifierReference(_) | JSXElementName::NamespacedName(_) => return, | |
| }; | |
| if ident.name == "this" { | |
| // We can't produce a proper identifier with a `ReferenceId` because `JSXIdentifier` | |
| // lacks that field. https://github.com/oxc-project/oxc/issues/3528 | |
| // So generate a reference and just use its name. | |
| // If JSX transform is enabled, that transform runs before this and will have converted | |
| // this to a proper `ThisExpression`, and this visitor won't run. | |
| // So only a problem if JSX transform is disabled. | |
| let new_ident = self.get_this_name(ctx).create_read_reference(ctx); | |
| ident.name = new_ident.name; | |
| } |
We can fix after we have the ThisExpression variants.
Linter
Once this is done, we can remove these lines from linter.
oxc/crates/oxc_linter/src/rules/react/jsx_no_undef.rs
Lines 60 to 64 in f052a6d
| let name = ident.name.as_str(); | |
| // TODO: Remove this check once we have `JSXMemberExpressionObject::ThisExpression` | |
| if name == "this" { | |
| return; | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-astArea - ASTArea - AST
Type
Fields
Give feedbackPriority
None yet