-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
removal of backslashes in string. #2789
Comments
@ikatyang this is still a legit issue inside of template literals. I'm using a markdown tagged template literal to output some documentation, which happens to include the syntax for string interpolation ( Before markdown`
const cssString = css\`
background-color: \$\{color('base')\}
\`;
` But prettier is removing the escape backslashes, which causes the content to be interpolated. Prettier Output: markdown`
const cssString = css\`background-color: ${color('base')}\`;
`; |
Can you open a new issue for that? It seems unrelated to this issue, thanks! EDIT: --> #4377 |
We fell in the similar problem.
For example, we pass a string Later in our code, we take out the enum Paths {
Root = "/",
Users = "/users",
UserShow = "/users/:id(\d+)", // <- Prettier deletes the backslash here
} I wish this could be prevented, because |
@ndac-todoroki although the |
You were right! Some how I didn't notice it wasn't working :( |
I'm having a similar issue - I have a string like this: Note the missing backslash before the close brackets inside the character class. The backslash is being used to escape the close bracket. Without it, the close bracket will be interpreted as the end of the character class. I would just //prettier-ignore it, but I also need to //eslint-disable and I'm not sure how to do both for a single line. |
@stclairdaniel You need two slashes for that to work as you’d expect, and four where you currently have |
Sure enough! I couldn't tell if it was user error or not - thanks for the help. |
Prettier Version: 1.5.2 & 1.6.2
Code
No playground, couldn't figure out how to get unique link for my sample.
Expected behavior:
Actual behavior:
The text was updated successfully, but these errors were encountered: