esquery
esquery copied to clipboard
esquery.matches does not respect subject indicator.
var esprima = require('esprima');
var esquery = require('esquery');
var ast = esprima.parse('a + !b');
var query = esquery.parse('BinaryExpression! > UnaryExpression.right');
// should be true (does not work)
console.log(esquery.matches(ast.body[0].expression, query, [ast.body[0], ast]));
// should be false (does not work)
console.log(esquery.matches(ast.body[0].expression.right, query, [ast.body[0].expression, ast.body[0], ast]));
// should include only the BinaryExpression (works)
console.log(JSON.stringify(esquery.match(ast, query, []), null, 4));