Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent VS Code from adding space before self-closing JSX tag?

I have this issue for a while. We have ESlint and it forbids us to add space before self-closing JSX-tag, but when I format .jsx file within VS Code it inserts it. How may I disable it?

There is screenshot with the problem:

enter image description here

Thanks!

like image 563
Nikita Shchypyplov Avatar asked Dec 21 '18 16:12

Nikita Shchypyplov


2 Answers

Use language mode javascriptreact, instead of javascript

enter image description here

like image 58
Debashis Chowdhury Avatar answered Nov 16 '22 01:11

Debashis Chowdhury


To my knowledge there is no such formatting option within the javascript.format options. But you can always look into extensions for this kind of job.

A lot of people use Prettier these days, but it is opinionated and there is no guarantee it will work well with all your ESLint options. It has an ESLint integrationn though, so maybe you want to have a look at this.

You can also have a look at react-beautify, which seems to have an option for this. But I am not familiar with this extension.

like image 36
Jan P Avatar answered Nov 16 '22 01:11

Jan P