Skip to content

offsetTernaryExpressions and multiline-ternary conflicts with jsx/indent (standard-react) #177

@jahed

Description

@jahed

What version of this package are you using?
15.0.0

What operating system, Node.js, and npm version?
Fedora 32, Node 12, Yarn 1

What happened?
The offsetTernaryExpressions option for indent rule tries to "fix" JSX code that includes ternaries, but then jsx/indent (via standard-react) gets upset that the indentation isn't what it wants. multiline-ternary may also be contributing to this issue.

Here's some example failing code. Attempting to "autofix" will just trigger the other rule, and so on. I tried manually find a structure that it's happy with but nothing seems to satisfy it.

const Test = ({ children }) => {
  const t = true
  return (
    <div>
      {t ? (
        <div>
          true
        </div>
      ) : (
        <div>
          false
        </div>
      )}
    </div>
  )
}

What did you expect to happen?
Both standard and standard-react are happy to work together.

Are you willing to submit a pull request to fix this bug?

Depends on the agreed solution. I don't know if this is an issue with indent and/or jsx/indent. Disabling offsetTernaryExpressions and multiline-ternary "fixes" the conflict in the mean time.

Personally, I'm happy to stick with 14.x as the ternary rules can't autofix everything and there's a lot of fixes I'll need to make on my end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions