Skip to content

Commit 3bbdea6

Browse files
committed
indent test code
1 parent f4339d8 commit 3bbdea6

File tree

1 file changed

+111
-111
lines changed

1 file changed

+111
-111
lines changed

tests/lib/rules/jsx-no-leaked-zero.js

+111-111
Original file line numberDiff line numberDiff line change
@@ -31,65 +31,65 @@ ruleTester.run('jsx-no-leaked-zero', rule, {
3131
valid: parsers.all([
3232
{
3333
code: `
34-
const Component = () => {
35-
return <div>{customTitle || defaultTitle}</div>
36-
}
34+
const Component = () => {
35+
return <div>{customTitle || defaultTitle}</div>
36+
}
3737
`,
3838
},
3939
{
4040
code: `
41-
const Component = ({ elements }) => {
42-
return <div>{elements}</div>
43-
}
41+
const Component = ({ elements }) => {
42+
return <div>{elements}</div>
43+
}
4444
`,
4545
},
4646
{
4747
code: `
48-
const Component = ({ elements }) => {
49-
return <div>There are {elements.length} elements</div>
50-
}
48+
const Component = ({ elements }) => {
49+
return <div>There are {elements.length} elements</div>
50+
}
5151
`,
5252
},
5353
{
5454
code: `
55-
const Component = ({ elements, count }) => {
56-
return <div>{!count && 'No results found'}</div>
57-
}
55+
const Component = ({ elements, count }) => {
56+
return <div>{!count && 'No results found'}</div>
57+
}
5858
`,
5959
},
6060
{
6161
code: `
62-
const Component = ({ elements }) => {
63-
return <div>{!!elements.length && <List elements={elements}/>}</div>
64-
}
62+
const Component = ({ elements }) => {
63+
return <div>{!!elements.length && <List elements={elements}/>}</div>
64+
}
6565
`,
6666
},
6767
{
6868
code: `
69-
const Component = ({ elements }) => {
70-
return <div>{Boolean(elements.length) && <List elements={elements}/>}</div>
71-
}
69+
const Component = ({ elements }) => {
70+
return <div>{Boolean(elements.length) && <List elements={elements}/>}</div>
71+
}
7272
`,
7373
},
7474
{
7575
code: `
76-
const Component = ({ elements }) => {
77-
return <div>{elements.length > 0 && <List elements={elements}/>}</div>
78-
}
76+
const Component = ({ elements }) => {
77+
return <div>{elements.length > 0 && <List elements={elements}/>}</div>
78+
}
7979
`,
8080
},
8181
{
8282
code: `
83-
const Component = ({ elements }) => {
84-
return <div>{elements.length ? <List elements={elements}/> : null}</div>
85-
}
83+
const Component = ({ elements }) => {
84+
return <div>{elements.length ? <List elements={elements}/> : null}</div>
85+
}
8686
`,
8787
},
8888
{
8989
code: `
90-
const Component = ({ elements, count }) => {
91-
return <div>{count ? <List elements={elements}/> : null}</div>
92-
}
90+
const Component = ({ elements, count }) => {
91+
return <div>{count ? <List elements={elements}/> : null}</div>
92+
}
9393
`,
9494
},
9595
]),
@@ -98,215 +98,215 @@ ruleTester.run('jsx-no-leaked-zero', rule, {
9898
// Invalid tests with cast to boolean fix strategy
9999
{
100100
code: `
101-
const Component = ({ count, title }) => {
102-
return <div>{count && title}</div>
103-
}
101+
const Component = ({ count, title }) => {
102+
return <div>{count && title}</div>
103+
}
104104
`,
105105
options: [{ fixStrategy: 'cast' }],
106106
errors: [{
107107
message: 'Potential numeric evaluation resulting in an unintentionally rendered `0`',
108108
line: 3,
109-
column: 22,
109+
column: 24,
110110
}],
111111
output: `
112-
const Component = ({ count, title }) => {
113-
return <div>{!!count && title}</div>
114-
}
112+
const Component = ({ count, title }) => {
113+
return <div>{!!count && title}</div>
114+
}
115115
`,
116116
},
117117
{
118118
code: `
119-
const Component = ({ count }) => {
120-
return <div>{count && <span>There are {count} results</span>}</div>
121-
}
119+
const Component = ({ count }) => {
120+
return <div>{count && <span>There are {count} results</span>}</div>
121+
}
122122
`,
123123
options: [{ fixStrategy: 'cast' }],
124124
errors: [{
125125
message: 'Potential numeric evaluation resulting in an unintentionally rendered `0`',
126126
line: 3,
127-
column: 22,
127+
column: 24,
128128
}],
129129
output: `
130-
const Component = ({ count }) => {
131-
return <div>{!!count && <span>There are {count} results</span>}</div>
132-
}
130+
const Component = ({ count }) => {
131+
return <div>{!!count && <span>There are {count} results</span>}</div>
132+
}
133133
`,
134134
},
135135
{
136136
code: `
137-
const Component = ({ elements }) => {
138-
return <div>{elements.length && <List elements={elements}/>}</div>
139-
}
137+
const Component = ({ elements }) => {
138+
return <div>{elements.length && <List elements={elements}/>}</div>
139+
}
140140
`,
141141
options: [{ fixStrategy: 'cast' }],
142142
errors: [{
143143
message: 'Potential numeric evaluation resulting in an unintentionally rendered `0`',
144144
line: 3,
145-
column: 22,
145+
column: 24,
146146
}],
147147
output: `
148-
const Component = ({ elements }) => {
149-
return <div>{!!elements.length && <List elements={elements}/>}</div>
150-
}
148+
const Component = ({ elements }) => {
149+
return <div>{!!elements.length && <List elements={elements}/>}</div>
150+
}
151151
`,
152152
},
153153
{
154154
code: `
155-
const Component = ({ nestedCollection }) => {
156-
return <div>{nestedCollection.elements.length && <List elements={nestedCollection.elements}/>}</div>
157-
}
155+
const Component = ({ nestedCollection }) => {
156+
return <div>{nestedCollection.elements.length && <List elements={nestedCollection.elements}/>}</div>
157+
}
158158
`,
159159
options: [{ fixStrategy: 'cast' }],
160160
errors: [{
161161
message: 'Potential numeric evaluation resulting in an unintentionally rendered `0`',
162162
line: 3,
163-
column: 22,
163+
column: 24,
164164
}],
165165
output: `
166-
const Component = ({ nestedCollection }) => {
167-
return <div>{!!nestedCollection.elements.length && <List elements={nestedCollection.elements}/>}</div>
168-
}
166+
const Component = ({ nestedCollection }) => {
167+
return <div>{!!nestedCollection.elements.length && <List elements={nestedCollection.elements}/>}</div>
168+
}
169169
`,
170170
},
171171
{
172172
code: `
173-
const Component = ({ elements }) => {
174-
return <div>{elements[0] && <List elements={elements}/>}</div>
175-
}
173+
const Component = ({ elements }) => {
174+
return <div>{elements[0] && <List elements={elements}/>}</div>
175+
}
176176
`,
177177
options: [{ fixStrategy: 'cast' }],
178178
errors: [{
179179
message: 'Potential numeric evaluation resulting in an unintentionally rendered `0`',
180180
line: 3,
181-
column: 22,
181+
column: 24,
182182
}],
183183
output: `
184-
const Component = ({ elements }) => {
185-
return <div>{!!elements[0] && <List elements={elements}/>}</div>
186-
}
184+
const Component = ({ elements }) => {
185+
return <div>{!!elements[0] && <List elements={elements}/>}</div>
186+
}
187187
`,
188188
},
189189
{
190190
code: `
191-
const Component = ({ numberA, numberB }) => {
192-
return <div>{(numberA || numberB) && <Results>{numberA+numberB}</Results>}</div>
193-
}
191+
const Component = ({ numberA, numberB }) => {
192+
return <div>{(numberA || numberB) && <Results>{numberA+numberB}</Results>}</div>
193+
}
194194
`,
195195
options: [{ fixStrategy: 'cast' }],
196196
errors: [{
197197
message: 'Potential numeric evaluation resulting in an unintentionally rendered `0`',
198198
line: 3,
199-
column: 23,
199+
column: 25,
200200
}],
201201
output: `
202-
const Component = ({ numberA, numberB }) => {
203-
return <div>{!!(numberA || numberB) && <Results>{numberA+numberB}</Results>}</div>
204-
}
202+
const Component = ({ numberA, numberB }) => {
203+
return <div>{!!(numberA || numberB) && <Results>{numberA+numberB}</Results>}</div>
204+
}
205205
`,
206206
},
207207

208208
// Invalid tests with ternary fix strategy
209209
{
210210
code: `
211-
const Component = ({ count, title }) => {
212-
return <div>{count && title}</div>
213-
}
211+
const Component = ({ count, title }) => {
212+
return <div>{count && title}</div>
213+
}
214214
`,
215215
errors: [{
216216
message: 'Potential numeric evaluation resulting in an unintentionally rendered `0`',
217217
line: 3,
218-
column: 22,
218+
column: 24,
219219
}],
220220
output: `
221-
const Component = ({ count, title }) => {
222-
return <div>{count ? title : null}</div>
223-
}
221+
const Component = ({ count, title }) => {
222+
return <div>{count ? title : null}</div>
223+
}
224224
`,
225225
},
226226
{
227227
code: `
228-
const Component = ({ count }) => {
229-
return <div>{count && <span>There are {count} results</span>}</div>
230-
}
228+
const Component = ({ count }) => {
229+
return <div>{count && <span>There are {count} results</span>}</div>
230+
}
231231
`,
232232
errors: [{
233233
message: 'Potential numeric evaluation resulting in an unintentionally rendered `0`',
234234
line: 3,
235-
column: 22,
235+
column: 24,
236236
}],
237237
output: `
238-
const Component = ({ count }) => {
239-
return <div>{count ? <span>There are {count} results</span> : null}</div>
240-
}
238+
const Component = ({ count }) => {
239+
return <div>{count ? <span>There are {count} results</span> : null}</div>
240+
}
241241
`,
242242
},
243243
{
244244
code: `
245-
const Component = ({ elements }) => {
246-
return <div>{elements.length && <List elements={elements}/>}</div>
247-
}
245+
const Component = ({ elements }) => {
246+
return <div>{elements.length && <List elements={elements}/>}</div>
247+
}
248248
`,
249249
errors: [{
250250
message: 'Potential numeric evaluation resulting in an unintentionally rendered `0`',
251251
line: 3,
252-
column: 22,
252+
column: 24,
253253
}],
254254
output: `
255-
const Component = ({ elements }) => {
256-
return <div>{elements.length ? <List elements={elements}/> : null}</div>
257-
}
255+
const Component = ({ elements }) => {
256+
return <div>{elements.length ? <List elements={elements}/> : null}</div>
257+
}
258258
`,
259259
},
260260
{
261261
code: `
262-
const Component = ({ nestedCollection }) => {
263-
return <div>{nestedCollection.elements.length && <List elements={nestedCollection.elements}/>}</div>
264-
}
262+
const Component = ({ nestedCollection }) => {
263+
return <div>{nestedCollection.elements.length && <List elements={nestedCollection.elements}/>}</div>
264+
}
265265
`,
266266
errors: [{
267267
message: 'Potential numeric evaluation resulting in an unintentionally rendered `0`',
268268
line: 3,
269-
column: 22,
269+
column: 24,
270270
}],
271271
output: `
272-
const Component = ({ nestedCollection }) => {
273-
return <div>{nestedCollection.elements.length ? <List elements={nestedCollection.elements}/> : null}</div>
274-
}
272+
const Component = ({ nestedCollection }) => {
273+
return <div>{nestedCollection.elements.length ? <List elements={nestedCollection.elements}/> : null}</div>
274+
}
275275
`,
276276
},
277277
{
278278
code: `
279-
const Component = ({ elements }) => {
280-
return <div>{elements[0] && <List elements={elements}/>}</div>
281-
}
279+
const Component = ({ elements }) => {
280+
return <div>{elements[0] && <List elements={elements}/>}</div>
281+
}
282282
`,
283283
errors: [{
284284
message: 'Potential numeric evaluation resulting in an unintentionally rendered `0`',
285285
line: 3,
286-
column: 22,
286+
column: 24,
287287
}],
288288
output: `
289-
const Component = ({ elements }) => {
290-
return <div>{elements[0] ? <List elements={elements}/> : null}</div>
291-
}
289+
const Component = ({ elements }) => {
290+
return <div>{elements[0] ? <List elements={elements}/> : null}</div>
291+
}
292292
`,
293293
},
294294
{
295295
code: `
296-
const Component = ({ numberA, numberB }) => {
297-
return <div>{(numberA || numberB) && <Results>{numberA+numberB}</Results>}</div>
298-
}
296+
const Component = ({ numberA, numberB }) => {
297+
return <div>{(numberA || numberB) && <Results>{numberA+numberB}</Results>}</div>
298+
}
299299
`,
300300
options: [{ fixStrategy: 'ternary' }],
301301
errors: [{
302302
message: 'Potential numeric evaluation resulting in an unintentionally rendered `0`',
303303
line: 3,
304-
column: 23,
304+
column: 25,
305305
}],
306306
output: `
307-
const Component = ({ numberA, numberB }) => {
308-
return <div>{(numberA || numberB) ? <Results>{numberA+numberB}</Results> : null}</div>
309-
}
307+
const Component = ({ numberA, numberB }) => {
308+
return <div>{(numberA || numberB) ? <Results>{numberA+numberB}</Results> : null}</div>
309+
}
310310
`,
311311
},
312312
]),

0 commit comments

Comments
 (0)