chrisgrieser / nvim-puppeteer

Automatically convert strings to f-strings or template strings and back.
MIT License
61 stars 4 forks source link

Do not transform template strings to regular strings if parent is function call #5

Closed guivazcabral closed 1 year ago

guivazcabral commented 1 year ago

Checks if parent of template string is a function call. This allows avoiding unwanted behavior when editing a graphql query using graphql-tag, for example:

const query = gql`
  query {}
`;

This applies to any tagged template literal.

Might need some testing :)

chrisgrieser commented 1 year ago

Hmm, I am not familiar with graphql, so I cannot really assess this.

I can see quite a bit of false positives for parent:type() == "call_expression". Have you checked various test cases like string arguments in a function call? I could imagine that some variation of this could also match that condition?

a.replace(`foobar${baz}`)
guivazcabral commented 1 year ago

It's not really related to graphql, it's related to tagged templates

I did test that, and in that particular case for example, the parent node of the template string is of type arguments so the plugin functions as expected

chrisgrieser commented 1 year ago

Okay then, we'll give it a go then.

guivazcabral commented 1 year ago

let me know if something goes wrong and I can try to make it better :)