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

Require JSX attributes and logical expressions to be indented correctly (react/jsx-indent) #1370

Closed
feross opened this issue Aug 15, 2019 · 1 comment

Comments

@feross
Copy link
Member

commented Aug 15, 2019

https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md

We already have this rule enabled, but I want to add more options to the rule.

Before:

    "react/jsx-indent": ["error", 2],

After:

    "react/jsx-indent": ["error", 2, { "checkAttributes": true, "indentLogicalExpressions": true }],

This is now considered a warning (wasn't before):

    const Component = () => (
      <View
        ListFooterComponent={(
          <View
            rowSpan={3}
            placeholder="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do"
          />
    )} // <--- note this is misaligned
      />
    );

Should be:

    const Component = () => (
      <View
        ListFooterComponent={(
          <View
            rowSpan={3}
            placeholder="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do"
          />
        )}
      />
    );

This is now considered a warning (wasn't before):

<App>
  {condition && (
  <Hello />
  )}
</App>

Should be:

<App>
  {condition && (
    <Hello />
  )}
</App>
@feross

This comment has been minimized.

Copy link
Member Author

commented Aug 15, 2019

Might need to revert this if there's some cases I haven't thought of, but I'm going to ship it and wait for the complaints (if any). I want to get all these JSX rules out at the same time.

Shipping in standard 14.

@feross feross closed this in ff4ef49 Aug 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.