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 behaviour with ternaries #907

Closed
mklopets opened this issue Oct 12, 2016 · 4 comments
Closed

jsx-indent behaviour with ternaries #907

mklopets opened this issue Oct 12, 2016 · 4 comments
Labels

Comments

@mklopets
Copy link

Upgrading from v6.3.0 to v6.4.0 made a perfectly sensible way of doing ternary operators in JSX fail linting due to indentation (did not throw error in 6.3.0).

This:

this.props.asd.length > 0 ?
    <Button className='bacon-yay'>{this.props.asd.length}</Button> :
    <span className='bacon-no-trigger'>0</span>

is supposedly incorrect.

Instead, the linter suggests you should use this, which doesn't make sense:

this.props.asd.length > 0 ?
    <Button className='bacon-yay'>{this.props.asd.length}</Button> :
        <span className='bacon-no-trigger'>0</span>
@ljharb ljharb added the bug label Oct 12, 2016
@klimashkin
Copy link

Yep, it's really critical #901
Can't use 6.4.x with it

@dmt0
Copy link

dmt0 commented Mar 6, 2017

@yannickcr This issue is anything but fixed. Using 6.10.0, I'm getting this:

43:7  error  Expected indentation of 4 space characters but found 6  react/jsx-indent

in this code:

          {!condition === 0 ? '' :
            <a href={this.props.exportUrl} >{t('export_btn')}</a>
          }

which I find indented reasonably. Linter expects it to look like this:

          {!condition === 0 ? '' :
          <a href={this.props.exportUrl} >{t('export_btn')}</a>
          }

@dentuzhik
Copy link

dentuzhik commented May 2, 2017

I have the same issue, our code still heavily affected by this, and we can't update from 6.3.0 for the reason that this gives a bunch of errors.

Can we at least reopen that?
I'm willing to contribute with additional info/tests failing, if necessary.
@yannickcr

@dentuzhik
Copy link

Actually NVM, the problem was related to a different issue, seems like jsx-indent is actually working fine. Sorry for direct ping.

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

No branches or pull requests

5 participants