Skip to content
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

How to match import with given specifier (ie. match on list of nodes) #50

Open
kristianmandrup opened this issue Dec 5, 2016 · 1 comment

Comments

@kristianmandrup
Copy link

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)
@kristianmandrup
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant