michaelgmcd / vscode-language-babel

VSCode syntax highlighting for today's JavaScript
https://marketplace.visualstudio.com/items?itemName=mgmcdermott.vscode-language-babel
MIT License
131 stars 17 forks source link

A backslash at the end of a string in a JSXAttribute breaks syntax highlighting #51

Open rattrayalex-stripe opened 5 years ago

rattrayalex-stripe commented 5 years ago

Both of these semantically-equivalent bits of code are broken:

<Foo x="\" y />
<Foo x={'\\'} y />
Screen Shot 2019-07-05 at 1 51 47 PM Screen Shot 2019-07-05 at 1 51 32 PM

Neither is broken when another character exists between the \ and the closing quote.

I work around this like so:

<Foo 
  x="\" 
  /* " // fix syntax highlighting */
  y 
/>
Screen Shot 2019-07-05 at 1 53 59 PM
michaelgmcd commented 5 years ago

It looks like strings in JSX attributes are treated the same as normal strings in JS. Not sure when I'll be able to get to this, but I can look into preventing \ escapes in these cases.