-
-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(linter): jsx no undef match scope should check with ancestors #2027
Conversation
CodSpeed Performance ReportMerging #2027 will not alter performanceFalling back to comparing Summary
|
I'm not sure whether enumerating the symbol table is a good idea, @Dunqing can you double check and find a better way? |
If too many symbols with the same name in the symbol table, enumerating the symbol table will affect performance. Instead, we should need to access the ancestor of the node's Look like this for scope_id in ctx.scopes().ancestors(jsx_scope_id) {
if ctx.scopes().has_binding(scope_id, &ident.name) {
return;
}
}
ctx.diagnostic(JsxNoUndefDiagnostic(ident.name.clone(), ident.span)); Usually, the Component is defined or imported from other files in the root scope, So we can do a small optimization by checking if the binding is present in the root scope first. Also, your test case is incorrect, the var React; { var App; }; React.render(<App />); You should change the |
This comment was marked as outdated.
This comment was marked as outdated.
Oh, I got your explanation, will change my PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
when check undef in jsx-no-undef rule, the match one should be scope of current jsx or the ancestors scope of current jsx. cause I just begin to learn rust, I am not sure the code style and performance can be better, if there is any, I would change