简体   繁体   中英

How to disable prettier adding {" "} in jsx?

I have got a problem with prettier's formatting, which when I'm saving the code, it will add annoying {" "} to some parts of the jsx code eg:

在此处输入图像描述

I've searched about how to fix this issue, but couldn't find any solution, can anybody help on this?

Here is the reprex: prettier playground and here is the related issue on github

Since there is an issue about this on prettier's GitHub , and it has been closed without any practical solution, So this question does not have any practical answer. The only answer which has been mentioned in that github issue is just use //prettier-ignore that will disable it:

Default version:

/*source*/
<p>hello <a href="#" target="_blank">LINK</a> world</p>


/*output*/
<p>
  hello{" "}
  <a href="#" target="_blank">
    LINK
  </a>{" "}
  world
</p>;

Using //prettier-ignore to disable it:

/*source*/

//prettier-ignore
<p>hello <a href="#" target="_blank">LINK</a> world</p>


/*output:*/

//prettier-ignore
<p>hello <a href="#" target="_blank">LINK</a> world</p>

Here is the playground

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM