Closed kristianmandrup closed 7 years ago
Finally getting somewhere, but not quite...
const find = `import-dec > specifiers import-default-specifier[id=#x]`
const replace = `y`
const replacer = grasp.replace('squery', find, replace)
How do I select on the outer import node and not the specifier? Even in this case, the specifier is not replaced by y
Can you give a better example of what you want?
ie. this is the code you have, this is what you want matched. It is unclear from your post
Are you wanting to use grasp "import-dec! import-default-specifier[local=#x]"? ie using http://www.graspjs.com/docs/squery/#subject
oh, wow! Thanks @gkz exactly what I wanted. I wish you had some more examples on how to use the query/select syntax to such great effect for more complex queries. Cheers!
Perfect! It works like a charm! Thanks again :)
As per https://github.com/estools/esquery/issues/50
How do I match
import x
in the following!?Error: Expected operator ), but found: {"type":"operator","value":"="}
Or why not?
import-dec[specifiers[id=#x]]
ORimport-dec[specifiers=(import-default-specifier[id=#x])]
TypeError: Cannot read property 'nodes' of undefined
(last attempt)From esprima parser