jsx-eslint/eslint-plugin-react

jsx-indent rule with ternary operators on multiple lines and JSX elements

Open

#454 建立於 2016年2月18日

在 GitHub 查看
 (29 留言) (16 反應) (0 負責人)JavaScript (2,797 fork)batch import
help wanted

倉庫指標

Star
 (8,630 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

This code

const foo = bar
    ? (
        <p>
            {'Bar is true!'}
        </p>
    )
    : (
        <p>
            {'Bar is false!'}
        </p>
    );

violates the jsx-indent rule on the lines with the <p> opening tags, saying that everything should be brought one level back.

I use a lot this syntax, especially when I have to render one complex component or another according to a boolean variable, and I can't seem to find a workaround to avoid the linting error (apart from not using the ternary operator, which I don't like).

貢獻者指南