-
-
Notifications
You must be signed in to change notification settings - Fork 715
perf(linter): add codegen support for let statements before match #14678
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
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #14678 will not alter performanceComparing Summary
Footnotes
|
|
sorry for hitting you up with so many of these PRs @camc314 😅 just been on a roll lately and figured I might as well try to squeeze all of the performance out of this one optimization if we can. |
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.
Hmm. This one doesn't look quite as reliable as the others.
The init of a let statement could do anything, and that wouldn't be detected here. e.g.:
let _ = match node.kind() {
AstKind::Function(_) => {
ctx.diagnostic(...);
return;
}
_ => {}
};
match node.kind() {
AstKind::Class(_) => {
ctx.diagnostic(...);
}
_ => {}
}This would be identified as only matching Class, but in reality it also acts on Function.
That's a silly example, but I don't think it's out of the question that a pattern something like this could be used in reality.
It looks to me like the 2 rules that this affects could be refactored so this isn't necessary. Would that be a safer approach?
Just to say, you are ON FIRE with this stuff. It's brilliant. It's just this one which looks fishy to me.
|
@overlookmotel oh good point. I'm too used to JavaScript still that I forgot you can just put an expression anywhere 😅 Yeah I'm gonna close this then. But I think it'll be safer to just refactor the lint rules manually. I've only been updating the linter codegen so that it's not quite so manual going forward, but this one's not too useful right now. |

Allows simple
letstatements before thematch node.kind()return. For example: