Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsx-indent-props fails on lines following preceding operator #647

Closed
jonvuri opened this issue Jun 22, 2016 · 5 comments · Fixed by #2808
Closed

jsx-indent-props fails on lines following preceding operator #647

jonvuri opened this issue Jun 22, 2016 · 5 comments · Fixed by #2808

Comments

@jonvuri
Copy link

jonvuri commented Jun 22, 2016

Example, with rule setting:

  react/jsx-indent-props:
    - error
    - 2

and source file:

import React from 'react'

const SpanElement = () => {
  const span = true
    ? <span
        attr='value'
      />
    : <span
        attr='otherValue'
      />

  return span
}

export default SpanElement

eslint gives output:

./SpanElement.jsx
  6:9   error  Expected indentation of 6 space characters but found 8  react/jsx-indent-props
  9:9   error  Expected indentation of 6 space characters but found 8  react/jsx-indent-props

I would expect it to understand that the indent is increased by the preceding operator on the line above.

@jonvuri
Copy link
Author

jonvuri commented Sep 13, 2016

Any update on this? Also, the same issue appears with jsx-indent.

@babsonmatt
Copy link

Just came across this issue as well

@AoDev
Copy link

AoDev commented Feb 28, 2017

Same here and I just want to add that using && does work properly. (in eslint-plugin-react: 6.10.0) with jsx-indent.

// Ternary fails
{store.isLoading
  ? <Something/>
  : <MyComponent
    someProp={someProp}
    otherProp={otherProp}/>
}

// && passes
{store.isLoading &&
  <MyComponent
    someProp={someProp}
    otherProp={otherProp}/>
}

@Moong0122
Copy link
Contributor

I will take a look this issue

@Moong0122
Copy link
Contributor

@ljharb I sent a PR, can you confirm if it worked?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants