jsx-eslint/eslint-plugin-react
View on GitHubjsx-no-leaked-render removes parentheses effecting formatting
Open
#3357 opened on Aug 15, 2022
bughelp wanted
Description
Hello I am trying to get the jsx-no-leaked-render to fix some code in my repo. When it runs its fix it is changing more code than necessary. In this case, it is removing parentheses around the conditionally rendered element. Although, not strictly necessary, the added parentheses are a convention we use in our codebase to keep formatting consistent, resulting in more clearly scoped conditional statements and components.
Although one could argue it doesn't matter for some people or its not a big deal, I think it's best that a rule not have any unintended effect on code structure other than what it is built to fix.
Note: This also happens when fixing strategy is set to coerce.
Before fixing
{item.validateResult && item.validateResult.error && (
<ErrorWrapper>
<ErrorIconContainer>
<ErrorIcon name="info" size={40} />
</ErrorIconContainer>
<Text size="medium" $warning>
{item.validateResult.error.message}
</Text>
</ErrorWrapper>
)}
After fixing
{item.validateResult && item.validateResult.error ? <ErrorWrapper>
<ErrorIconContainer>
<ErrorIcon name="info" size={40} />
</ErrorIconContainer>
<Text size="medium" $warning>
{item.validateResult.error.message}
</Text>
</ErrorWrapper> : null}