esquery
esquery copied to clipboard
How to match import with given specifier (ie. match on list of nodes)
I'm trying to use grasp with squery which I think uses esquery under the hood? How do I match an import with a given specifier:
I can't do import-dec[specifiers=x] since specifiers is a list of nodes, such as import {x, y z} from 'v'
const find = 'import-dec[specifiers=x] ~ class-dec[id=#CoolGang]'
const replace = `class {{.id}} {{.body}}`
const replacer = grasp.replace('squery', find, replace)
Been trying a nested selector like this:
const find = `(import-dec[specifiers=(id=#x)], class-dec[id=#CoolGang])`
const replace = `class {{.id}} {{.body}}`
const replacer = grasp.replace('squery', find, replace)
Still to no avail.