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 rule doesn't properly validate ternary (?:) expressions with no parens #1315

Open
jonvuri opened this issue Jul 22, 2017 · 6 comments

Comments

@jonvuri
Copy link

jonvuri commented Jul 22, 2017

Prior related issues:

#540
#625

Patterns:

{ condition
  ? <div>
      <div> something </div>
    </div>
  : <div>
      <div> something </div>
    </div>
}

{ condition
    ? <div>
        <div> something </div>
      </div>
    : <div>
        <div> something </div>
      </div>
}

{
  condition
  ? <div>
      <div> something </div>
    </div>
  : <div>
      <div> something </div>
    </div>
}

{
  condition
    ? <div>
        <div> something </div>
      </div>
    : <div>
        <div> something </div>
      </div>
}

Expected behavior:
All of these patterns properly validate and flag no errors.

Actual behavior:
All of these patterns flag errors for lines following and indented after the ternary result clauses (after ? and : lines).

@jonvuri
Copy link
Author

jonvuri commented Jul 23, 2017

Note: Also an issue with jsx-indent-props, e.g.:

{
  condition
    ? <El
        prop1={ 1 }
        prop2={ 2 }
      />
    : <OtherEl
        prop1={ 1 }
        prop2={ 2 }
      />
}

I could make a separate issue for this if necessary.

@derekjobst
Copy link

I've also experienced these issues. Any idea what steps we could take to get moving on a fix?

@ljharb
Copy link
Member

ljharb commented Nov 9, 2017

Someone coming forward with a PR would be helpful; however, #1317 may have mitigated this and isn't yet released, afaik.

@ljharb
Copy link
Member

ljharb commented Oct 24, 2021

A PR with failing test cases would be most helpful.

ljharb added a commit to ljharb/eslint-plugin-react that referenced this issue Sep 30, 2022
@ljharb
Copy link
Member

ljharb commented Sep 30, 2022

I've pushed up a branch with failing tests, in case anyone can pick this up.

@ljharb ljharb added the bug label Sep 30, 2022
@root0x

This comment was marked as spam.

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

No branches or pull requests

4 participants