jsx-eslint/eslint-plugin-react

jsx-indent-props > 'first' option forces you to use 'space' identation

Open

#2839 opened on Oct 21, 2020

View on GitHub
 (3 comments) (0 reactions) (0 assignees)JavaScript (8,630 stars) (2,797 forks)batch import
help wanted

Description

Hello, I'm using eslint with typescript and react. I was trying to use this rule jsx-indent-props and I wanted to use the option 'first' but with tab indentation. The documentation doesn't point that if you select 'first' option you are forced to use 'space' indentation:

It takes an option as the second parameter which can be "tab" for tab-based indentation, a positive number for space indentations or "first" for aligning the first prop for each line with the tag's first prop. Note that using the "first" option allows very inconsistent indentation unless you also enable a rule that enforces the position of the first prop.

The code actually is like this:

      if (context.options[0] === 'first') {
        indentSize = 'first';
        indentType = 'space';
      } else if (context.options[0] === 'tab') {
        indentSize = 1;
        indentType = 'tab';
      } else if (typeof context.options[0] === 'number') {
        indentSize = context.options[0];
        indentType = 'space';
      }
    }

Maybe we can add more than one option to reach a combination between 'first' and 'tabs or spaces'? Is there a problem with doing this?

Thank you!

Contributor guide