@@ -124,23 +124,27 @@ ruleTester.run('jsx-no-leaked-render', rule, {
124
124
}
125
125
` ,
126
126
} ,
127
-
128
- // Fixes for // https://github.com/jsx-eslint/eslint-plugin-react/issues/3297
129
127
{
130
- // It shouldn't delete valid alternate from ternary expressions when "coerce" is the only valid strategy - 1
131
128
options : [ { validStrategies : [ 'coerce' ] } ] ,
132
129
code : `
133
130
const Component = ({ elements, count }) => {
134
- return <div>{direction ? (direction === "down" ? "▼" : "▲") : "" }</div>
131
+ return <div>{!!count && <List elements={elements}/> }</div>
135
132
}
136
133
` ,
137
134
} ,
135
+
136
+ // Fixes for // https://github.com/jsx-eslint/eslint-plugin-react/issues/3297
138
137
{
139
- // It shouldn't delete valid alternate from ternary expressions when "coerce" is the only valid strategy - 2
138
+ // It shouldn't delete valid alternate from ternary expressions when "coerce" is the only valid strategy
140
139
options : [ { validStrategies : [ 'coerce' ] } ] ,
141
140
code : `
142
- const Component = ({ containerName }) => {
143
- return <div>{ containerName.length > 0 ? "Loading several stuff" : "Loading" }</div>
141
+ const Component = ({ elements, count }) => {
142
+ return (
143
+ <div>
144
+ <div> {direction ? (direction === "down" ? "▼" : "▲") : ""} </div>
145
+ <div>{ containerName.length > 0 ? "Loading several stuff" : "Loading" }</div>
146
+ </div>
147
+ )
144
148
}
145
149
` ,
146
150
} ,
@@ -153,6 +157,21 @@ ruleTester.run('jsx-no-leaked-render', rule, {
153
157
}
154
158
` ,
155
159
} ,
160
+ {
161
+ // It shouldn't report nested logical expressions when "coerce" is the only valid strategy
162
+ options : [ { validStrategies : [ 'coerce' ] } ] ,
163
+ code : `
164
+ const Component = ({ direction }) => {
165
+ return (
166
+ <div>
167
+ <div>{!!direction && direction === "down" && "▼"}</div>
168
+ <div>{direction === "down" && !!direction && "▼"}</div>
169
+ <div>{direction === "down" || !!direction && "▼"}</div>
170
+ </div>
171
+ )
172
+ }
173
+ ` ,
174
+ } ,
156
175
] ) ,
157
176
158
177
invalid : parsers . all ( [
0 commit comments