Eslint AirBNB with 4 spaces for indent

Notorious picture Notorious · Feb 21, 2018 · Viewed 25.2k times · Source

I am configuring eslint and am using the AirBNB style guide.

I want to over-ride the indent (supposed to be 2 spaces) to be 4 spaces. But no matter what I do within my .eslintrc I cannot get this error supressed so that I can use indentation of 4 spaces.

I have the message "Expected indentation of 2 spaces chatacters but found 4. (react/jsx-indent)" everywhere within my code base.

I am using eslint 4.9.0. How can I resolve this? Thanks.

Answer

Notorious picture Notorious · Feb 21, 2018

Ok so this is relatively easy to do and is achievable by adding the following to your eslint config:

// Indent with 4 spaces
"indent": ["error", 4],

// Indent JSX with 4 spaces
"react/jsx-indent": ["error", 4],

// Indent props with 4 spaces
"react/jsx-indent-props": ["error", 4],