-
-
Notifications
You must be signed in to change notification settings - Fork 475
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
refactor(linter-config): remove dead code and deduplicate code #612
Conversation
Parser conformance results onjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
It would be great if the description of the PR would also explain the PR itself: the dead code part 😅 |
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 for looking after this, that's a significant improvement!
Good point! I added some precision. Most of the dead code comes from never called visitor methods. |
Summary
This PR removes dead code and deduplicate code for linter configuration.
Several visitors were never called and thus outdated. This was the case of
Hooks::visit_array_member
andHooks::visit_map
.There is room for improvement:
I am not sure why we use visitors here while we create the config.
We create a default config, and so we visit the config to initialize it.
This looks like an abuse of the visitor pattern?
Methods such
map_to_*
don't useself
.We should remove
self
from their parameters, this could simplify mutation of self fields (because we cannot both callmap_to_*
and mutate a field ofself
by passing it as visitor tomap_to_*
).Instead of relying on
visit_member_name
to validate field names, we could directly validate them invisit_map
.We have to match against existing fields in
visit_map
, thus we can detect unknown field here. This saves one check.However, I prefer to keep this PR focused on removing dead code and deduplicate code.
NOTE: A significant part of the diff comes from the new generated code.
Test Plan
CI should pass.