ChatGPT解决这个技术问题 Extra ChatGPT

Add space in self closing tags before in self closing tags

How do you include a space before the closing tags in self closing tags with WebStorm/IntelliJ-based products?

Default settings turns <ReactComp /> to <ReactComp/>, which is against one of the rules (jsx-space-before-closing) in the commonly used AirBNBs Javascript style guide.


b
bryan kennedy

Maybe a little confusingly, the setting is under "HTML" code style and not the JS code style in IntelliJ.

Enable the setting "In empty tag" in Preferences -> Editor -> Code Style -> HTML.

When you do an explicit reformat the space will be added. To ensure that the space is added when autocompleting React components, check the same box in in the Preferences -> Editor -> Code Style -> XML -> Other tab.

Screenshot from 2016-10-12, IntelliJ IDEA 2016.2

https://i.stack.imgur.com/9ESoy.png


Thank you very much for this help. It works like charme ;-D
Wow, this caused countless hours of debugging, thank you!
This works for me when doing an explicit reformat, but not when autocompleting jsx tags. I.e. when the autocomplete box shows while typing and I press enter it still shows the jsx tag without the space before the /
@Ruben Add the same in XML
Is there any option like this for .editorconfig so I can propagate this to team?
V
Vsevolod Golovanov

The .editorconfig way.

[**]
ij_html_space_inside_empty_tag = true

https://i.stack.imgur.com/MTXR4.png


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now