-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
refactor: SafeEmitter -> SourceCodeVisitor #19708
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
✅ Deploy Preview for docs-eslint canceled.
|
ec670bc
to
4acbab9
Compare
lib/linter/source-code-traverser.js
Outdated
const isAnyTypeSelectorMoreSpecific = | ||
hasMoreAnyTypeSelectors && | ||
hasMoreNodeTypeSelectors && | ||
anyTypeSelector.compare(nodeTypeSelector) < 0; |
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.
I believe this should be isAnyTypeSelectorLessSpecific
, not More.
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.
Thanks. I've found this specificity concept difficult to wrap my brain around. In CSS, higher specificity takes priority but here lower specificity does.
a3ce474
to
586c617
Compare
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
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.
LGTM, thanks!
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
This further refactors the traversal logic, moving it closer to being able to support asynchronous rules.
SafeEmitter
withSourceCodeVisitor
. This is a more accurate representation of what we want to happen (for a given name, retrieve functions to execute) vs. emitting events with multiple listeners. This will also make it easier to implement async rules in the future.SourceCodeTraverser
so thattraverseSync()
is responsible for calling functions instead ofESQueryHelper
.ESQueryHelper
to only match and return selectors instead of emitting events.Depends on #19679
Refs #18787
Is there anything you'd like reviewers to focus on?