eslint-stylistic icon indicating copy to clipboard operation
eslint-stylistic copied to clipboard

`@stylistic/jsx-indent-props`: Broken in ternary expression

Open ej612 opened this issue 8 months ago • 1 comments

Validations

  • [X] Follow our Code of Conduct
  • [X] Read the Contributing Guide.
  • [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.

Describe the bug

Hi there!

This is my eslint config:

'@stylistic/indent': ['error', 2],
'@stylistic/jsx-indent': ['error', 2],
'@stylistic/jsx-indent-props': ['error', 2],

This is my code:

const component = (true
  ? <button
    onClick={() => {}}
  />
  : null
);

Which shows the following error: image

I would expect that line to be indented by 4 spaces, analogous to be following code, which doesn't display an error:

const obj = (true
  ? {
    a: 1 // <- indented by 4 spaces
  }
  : null
);

Auto-fixing doesn't work either, because if I indent that line by 6 spaces, as expected by jsx-indent-props, I now get an error from indent (as I would expect): image

I therefore suspect there's something wrong with jsx-indent-props. Thanks a lot in advance!

Reproduction

https://stackblitz.com/edit/github-dgu1fv

Contributes

  • [ ] I am willing to submit a PR to fix this issue
  • [ ] I am willing to submit a PR with failing tests

ej612 avatar Jun 21 '24 09:06 ej612