Skip to content

Commit

Permalink
refactor(jsx-no-leaked-render): move tests options after code
Browse files Browse the repository at this point in the history
  • Loading branch information
Belco90 committed May 26, 2022
1 parent b2e45f0 commit f74e30c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/lib/rules/jsx-no-leaked-render.js
Expand Up @@ -93,52 +93,51 @@ ruleTester.run('jsx-no-leaked-render', rule, {
`,
},
{
options: [{ validStrategies: ['ternary'] }],
code: `
const Component = ({ elements, count }) => {
return <div>{count ? <List elements={elements}/> : null}</div>
}
`,
options: [{ validStrategies: ['ternary'] }],
},
{
options: [{ validStrategies: ['coerce'] }],
code: `
const Component = ({ elements, count }) => {
return <div>{!!count && <List elements={elements}/>}</div>
}
`,
options: [{ validStrategies: ['coerce'] }],
},
{
options: [{ validStrategies: ['coerce', 'ternary'] }],
code: `
const Component = ({ elements, count }) => {
return <div>{count ? <List elements={elements}/> : null}</div>
}
`,
options: [{ validStrategies: ['coerce', 'ternary'] }],
},
{
options: [{ validStrategies: ['coerce', 'ternary'] }],
code: `
const Component = ({ elements, count }) => {
return <div>{!!count && <List elements={elements}/>}</div>
}
`,
options: [{ validStrategies: ['coerce', 'ternary'] }],
},
{
options: [{ validStrategies: ['coerce'] }],
code: `
const Component = ({ elements, count }) => {
return <div>{!!count && <List elements={elements}/>}</div>
}
`,
options: [{ validStrategies: ['coerce'] }],
},

// Fixes for:
// - https://github.com/jsx-eslint/eslint-plugin-react/issues/3292
// - https://github.com/jsx-eslint/eslint-plugin-react/issues/3297
{
// It shouldn't delete valid alternate from ternary expressions when "coerce" is the only valid strategy
options: [{ validStrategies: ['coerce'] }],
code: `
const Component = ({ elements, count }) => {
return (
Expand All @@ -149,19 +148,19 @@ ruleTester.run('jsx-no-leaked-render', rule, {
)
}
`,
options: [{ validStrategies: ['coerce'] }],
},
{
// It shouldn't delete valid branches from ternary expressions when ["coerce", "ternary"] are only valid strategies
options: [{ validStrategies: ['coerce', 'ternary'] }],
code: `
const Component = ({ elements, count }) => {
return <div>{direction ? (direction === "down" ? "▼" : "▲") : ""}</div>
}
`,
options: [{ validStrategies: ['coerce', 'ternary'] }],
},
{
// It shouldn't report nested logical expressions when "coerce" is the only valid strategy
options: [{ validStrategies: ['coerce'] }],
code: `
const Component = ({ direction }) => {
return (
Expand All @@ -174,6 +173,7 @@ ruleTester.run('jsx-no-leaked-render', rule, {
)
}
`,
options: [{ validStrategies: ['coerce'] }],
},
]),

Expand Down

0 comments on commit f74e30c

Please sign in to comment.