vuejs / vue-eslint-parser

The ESLint custom parser for `.vue` files.
MIT License
443 stars 74 forks source link

Incorrect parsing when string contains }} (two closing braces) #94

Closed glen-84 closed 3 years ago

glen-84 commented 3 years ago

https://astexplorer.net/#/gist/50f0fc500a626ee33ec2ea9205f4e598/8be358100a557256023ef600d4aa7e32486ea369

Two closing braces inside a string should not be seen as the end of the expression container.

This will happen frequently when using something like ICU message formatting, as seen in the example at the URL above.

ota-meshi commented 3 years ago

I think your template is incorrect as SFC.

So I think this parser is working fine.

longlho commented 3 years ago

I'm not sure I understand how it's incorrect?

<template>
  <p>{{ $doSomething('}}') }}</p>
</template>

This looks like it should be parsable.

ota-meshi commented 3 years ago

Your template cannot be compiled with Vue's compiler. What do you see and think this template can be parsed?

image

https://template-explorer.vuejs.org/#%3Cp%3E%7B%7B%20%24doSomething('%7D%7D')%20%7D%7D%3C%2Fp%3E

LinusBorg commented 3 years ago

'}}' is interpreted by the parser as the end of an interpolation, but it isn't. This looks to me like a bug or improvement opportunity for the Vue parser.

glen-84 commented 3 years ago

So this is an issue with @vue/compiler-*?

Does GH allow you to transfer this issue there, or should I open a new issue at vuejs/vue-next?

LinusBorg commented 3 years ago

I can't transfer it, maybe @ota-meshi can?

ota-meshi commented 3 years ago

@LinusBorg Thank you for following me. I can't even transfer this issue...

LinusBorg commented 3 years ago

@glen-84 Then please open a new issue in the vue repo

glen-84 commented 3 years ago

I will do, thanks.

LinusBorg commented 3 years ago

FWIW I guess you are aware that a workaround would be '}' + '}'

glen-84 commented 3 years ago

Ya, @longlho put another workaround in the Format.JS documentation, but I wanted to find out why it was necessary. 🙂

I've opened https://github.com/vuejs/vue-next/issues/2944.

Thanks.