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

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

Closed
jahed opened this issue Oct 24, 2020 · 3 comments

Comments

@jahed
Copy link

jahed commented Oct 24, 2020

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.

@bcomnes
Copy link
Member

bcomnes commented Oct 27, 2020

Oh hello fellow traveler, I was just about to open this issue. Bitten by this today.

@bcomnes
Copy link
Member

bcomnes commented Oct 27, 2020

I think the idea here would be to disable the indent rule for JSX, which is covered by standard jsx.

Disable: "JSXElement *"

Though I don't know if there are any assumptions regarding indent applying to jsx nodes and properly overlapping.

Sending in a PR to see what people think.

bcomnes added a commit that referenced this issue Oct 27, 2020
Fixes #177

My only worry is that there is some use for indent rules inside of JSX that are intended to overlap with standard-jsx? Not sure, anyone familiar?
@feross feross closed this as completed in 77f1692 Oct 28, 2020
@feross
Copy link
Member

feross commented Oct 28, 2020

Fixed in 15.0.1.

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

Successfully merging a pull request may close this issue.

3 participants