-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
See https://developer.mozilla.org/en-US/docs/Web/CSS/:scope
This selector would allow queries to limit the matching to only the direct children of the AST on which the query is run.
For example, in the following code:
const x = function() {
function y() {
return 'bar';
}
return 'foo';
};How do you query for just the outer function's return statement? Currently the query ReturnStatement will return both return statements even if it is run on the Block node that is the body of the outer function.
With the :scope selector you would be able to use :scope > ReturnStatement and then run that on the body of the outer function to only return the outer ReturnStatement.
ESQuery has a PR for adding this already estools/esquery#61
granmoe and minomikula
Metadata
Metadata
Assignees
Labels
No labels