Skip to content

Commit a5ded4d

Browse files
committed
Add line/column checks in tests for deprecated lifecycle methods
1 parent c4cef42 commit a5ded4d

File tree

1 file changed

+106
-22
lines changed

1 file changed

+106
-22
lines changed

tests/lib/rules/no-deprecated.js

Lines changed: 106 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,32 @@ ruleTester.run('no-deprecated', rule, {
224224
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
225225
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
226226
),
227-
type: 'Identifier'
227+
type: 'Identifier',
228+
line: 3,
229+
column: 11,
230+
endLine: 3,
231+
endColumn: 29
228232
},
229233
{
230234
message: errorMessage(
231235
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
232236
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
233237
),
234-
type: 'Identifier'
238+
type: 'Identifier',
239+
line: 4,
240+
column: 11,
241+
endLine: 4,
242+
endColumn: 36
235243
},
236244
{
237245
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
238246
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
239247
),
240-
type: 'Identifier'
248+
type: 'Identifier',
249+
line: 5,
250+
column: 11,
251+
endLine: 5,
252+
endColumn: 30
241253
}
242254
]
243255
},
@@ -257,20 +269,32 @@ ruleTester.run('no-deprecated', rule, {
257269
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
258270
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
259271
),
260-
type: 'Identifier'
272+
type: 'Identifier',
273+
line: 4,
274+
column: 13,
275+
endLine: 4,
276+
endColumn: 31
261277
},
262278
{
263279
message: errorMessage(
264280
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
265281
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
266282
),
267-
type: 'Identifier'
283+
type: 'Identifier',
284+
line: 5,
285+
column: 13,
286+
endLine: 5,
287+
endColumn: 38
268288
},
269289
{
270290
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
271291
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
272292
),
273-
type: 'Identifier'
293+
type: 'Identifier',
294+
line: 6,
295+
column: 13,
296+
endLine: 6,
297+
endColumn: 32
274298
}
275299
]
276300
},
@@ -288,20 +312,32 @@ ruleTester.run('no-deprecated', rule, {
288312
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
289313
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
290314
),
291-
type: 'Identifier'
315+
type: 'Identifier',
316+
line: 3,
317+
column: 11,
318+
endLine: 3,
319+
endColumn: 29
292320
},
293321
{
294322
message: errorMessage(
295323
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
296324
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
297325
),
298-
type: 'Identifier'
326+
type: 'Identifier',
327+
line: 4,
328+
column: 11,
329+
endLine: 4,
330+
endColumn: 36
299331
},
300332
{
301333
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
302334
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
303335
),
304-
type: 'Identifier'
336+
type: 'Identifier',
337+
line: 5,
338+
column: 11,
339+
endLine: 5,
340+
endColumn: 30
305341
}
306342
]
307343
},
@@ -319,20 +355,32 @@ ruleTester.run('no-deprecated', rule, {
319355
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
320356
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
321357
),
322-
type: 'Identifier'
358+
type: 'Identifier',
359+
line: 3,
360+
column: 11,
361+
endLine: 3,
362+
endColumn: 29
323363
},
324364
{
325365
message: errorMessage(
326366
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
327367
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
328368
),
329-
type: 'Identifier'
369+
type: 'Identifier',
370+
line: 4,
371+
column: 11,
372+
endLine: 4,
373+
endColumn: 36
330374
},
331375
{
332376
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
333377
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
334378
),
335-
type: 'Identifier'
379+
type: 'Identifier',
380+
line: 5,
381+
column: 11,
382+
endLine: 5,
383+
endColumn: 30
336384
}
337385
]
338386
},
@@ -350,20 +398,32 @@ ruleTester.run('no-deprecated', rule, {
350398
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
351399
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
352400
),
353-
type: 'Identifier'
401+
type: 'Identifier',
402+
line: 3,
403+
column: 11,
404+
endLine: 3,
405+
endColumn: 29
354406
},
355407
{
356408
message: errorMessage(
357409
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
358410
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
359411
),
360-
type: 'Identifier'
412+
type: 'Identifier',
413+
line: 4,
414+
column: 11,
415+
endLine: 4,
416+
endColumn: 36
361417
},
362418
{
363419
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
364420
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
365421
),
366-
type: 'Identifier'
422+
type: 'Identifier',
423+
line: 5,
424+
column: 11,
425+
endLine: 5,
426+
endColumn: 30
367427
}
368428
]
369429
},
@@ -381,25 +441,37 @@ ruleTester.run('no-deprecated', rule, {
381441
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
382442
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
383443
),
384-
type: 'Identifier'
444+
type: 'Identifier',
445+
line: 3,
446+
column: 11,
447+
endLine: 3,
448+
endColumn: 29
385449
},
386450
{
387451
message: errorMessage(
388452
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
389453
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
390454
),
391-
type: 'Identifier'
455+
type: 'Identifier',
456+
line: 4,
457+
column: 11,
458+
endLine: 4,
459+
endColumn: 36
392460
},
393461
{
394462
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
395463
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
396464
),
397-
type: 'Identifier'
465+
type: 'Identifier',
466+
line: 5,
467+
column: 11,
468+
endLine: 5,
469+
endColumn: 30
398470
}
399471
]
400472
},
401473
{
402-
code: `un
474+
code: `
403475
class Foo extends React.Component {
404476
constructor() {}
405477
componentWillMount() {}
@@ -413,20 +485,32 @@ ruleTester.run('no-deprecated', rule, {
413485
'componentWillMount', '16.3.0', 'UNSAFE_componentWillMount',
414486
'https://reactjs.org/docs/react-component.html#unsafe_componentwillmount'
415487
),
416-
type: 'Identifier'
488+
type: 'Identifier',
489+
line: 4,
490+
column: 11,
491+
endLine: 4,
492+
endColumn: 29
417493
},
418494
{
419495
message: errorMessage(
420496
'componentWillReceiveProps', '16.3.0', 'UNSAFE_componentWillReceiveProps',
421497
'https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops'
422498
),
423-
type: 'Identifier'
499+
type: 'Identifier',
500+
line: 5,
501+
column: 11,
502+
endLine: 5,
503+
endColumn: 36
424504
},
425505
{
426506
message: errorMessage('componentWillUpdate', '16.3.0', 'UNSAFE_componentWillUpdate',
427507
'https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate'
428508
),
429-
type: 'Identifier'
509+
type: 'Identifier',
510+
line: 6,
511+
column: 11,
512+
endLine: 6,
513+
endColumn: 30
430514
}
431515
]
432516
}

0 commit comments

Comments
 (0)