Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA JSX code style

I have a JSX file with two-space indents, but IntelliJ keeps adding four-space indents. Changing Settings>Editor>Code Style for Javascript, HTML, and "other file types" does not seem to affect this.

How can I change the code style for JSX files?

like image 441
MikeFHay Avatar asked Jul 25 '16 13:07

MikeFHay


People also ask

How can I beautify code in Intellij?

Go to Settings/Preferences | Editor | Code Style, select your programming language, and open the Wrapping and Braces tab. In the Keep when reformatting section, select the formatting rules which you want to ignore and deselect those which should be applied. Reformat your code ( Ctrl+Alt+L ).

What format is JSX?

JSX stands for JavaScript XML. It is simply a syntax extension of JavaScript. It allows us to directly write HTML in React (within JavaScript code). It is easy to create a template using JSX in React, but it is not a simple template language instead it comes with the full power of JavaScript.

What is the difference between TSX and JSX?

. tsx is similar to jsx except it's TypeScript with the JSX language extension.


1 Answers

Turns out the reason the IDE wasn't responding to my settings changes is it was using EditorConfig mode (Settings>Editor>Code Style>EditorConfig). Editing the .editorconfig file to have the line indent_size = 2 fixed the issue.

like image 87
MikeFHay Avatar answered Oct 17 '22 11:10

MikeFHay