@@ -6225,6 +6225,32 @@ ruleTester.run('no-unused-prop-types', rule, {
6225
6225
message : '\'z\' PropType is defined but prop is never used'
6226
6226
} ]
6227
6227
} ,
6228
+ {
6229
+ // test same name of interface should be merge
6230
+ code : `
6231
+ interface Foo {
6232
+ x: number;
6233
+ }
6234
+
6235
+ interface Foo {
6236
+ z: string;
6237
+ }
6238
+
6239
+ interface Bar extends Foo {
6240
+ y: string;
6241
+ }
6242
+
6243
+ const Baz = ({ x, y }: Bar) => (
6244
+ <span>
6245
+ {x}
6246
+ {y}
6247
+ </span>
6248
+ );` ,
6249
+ parser : parsers . TYPESCRIPT_ESLINT ,
6250
+ errors : [ {
6251
+ message : '\'z\' PropType is defined but prop is never used'
6252
+ } ]
6253
+ } ,
6228
6254
{
6229
6255
// test extends
6230
6256
code : `
@@ -6273,6 +6299,33 @@ ruleTester.run('no-unused-prop-types', rule, {
6273
6299
message : '\'z\' PropType is defined but prop is never used'
6274
6300
} ]
6275
6301
} ,
6302
+ {
6303
+ // test extends
6304
+ code : `
6305
+ interface Foo {
6306
+ x: number;
6307
+ }
6308
+
6309
+ interface Bar {
6310
+ y: string;
6311
+ }
6312
+
6313
+ interface Baz {
6314
+ z:string;
6315
+ }
6316
+
6317
+ const Baz = ({ x }: Bar & Foo & Baz) => (
6318
+ <span>
6319
+ {x}
6320
+ </span>
6321
+ );` ,
6322
+ parser : parsers . TYPESCRIPT_ESLINT ,
6323
+ errors : [ {
6324
+ message : '\'y\' PropType is defined but prop is never used'
6325
+ } , {
6326
+ message : '\'z\' PropType is defined but prop is never used'
6327
+ } ]
6328
+ } ,
6276
6329
{
6277
6330
// test same name merge and extends
6278
6331
code : `
@@ -6309,6 +6362,31 @@ ruleTester.run('no-unused-prop-types', rule, {
6309
6362
z: string;
6310
6363
}
6311
6364
6365
+ interface Bar extends Foo {
6366
+ y: string;
6367
+ }
6368
+
6369
+ const Baz = ({ x }: Bar) => (
6370
+ <span>
6371
+ {x}
6372
+ </span>
6373
+ );` ,
6374
+ parser : parsers . TYPESCRIPT_ESLINT ,
6375
+ errors : [ {
6376
+ message : '\'z\' PropType is defined but prop is never used'
6377
+ } , { message : '\'y\' PropType is defined but prop is never used' } ]
6378
+ } ,
6379
+ {
6380
+ // test same name merge and extends
6381
+ code : `
6382
+ interface Foo {
6383
+ x: number;
6384
+ }
6385
+
6386
+ interface Foo {
6387
+ z: string;
6388
+ }
6389
+
6312
6390
interface Foo {
6313
6391
y: string;
6314
6392
}
@@ -6362,6 +6440,45 @@ ruleTester.run('no-unused-prop-types', rule, {
6362
6440
message : '\'birthday\' PropType is defined but prop is never used'
6363
6441
} ]
6364
6442
} ,
6443
+ {
6444
+ code : `
6445
+ type User = {
6446
+ user: string;
6447
+ }
6448
+
6449
+ type UserProps = {
6450
+ userId: string;
6451
+ }
6452
+
6453
+ type AgeProps = {
6454
+ age: number;
6455
+ }
6456
+
6457
+ type BirthdayProps = {
6458
+ birthday: string;
6459
+ }
6460
+
6461
+ type intersectionUserProps = AgeProps & BirthdayProps;
6462
+
6463
+ type Props = User & UserProps & intersectionUserProps;
6464
+
6465
+ export default (props: Props) => {
6466
+ const { userId, user } = props;
6467
+
6468
+ if (userId === 0) {
6469
+ return <p>userId is 0</p>;
6470
+ }
6471
+
6472
+ return null;
6473
+ };
6474
+ ` ,
6475
+ parser : parsers . TYPESCRIPT_ESLINT ,
6476
+ errors : [ {
6477
+ message : '\'age\' PropType is defined but prop is never used'
6478
+ } , {
6479
+ message : '\'birthday\' PropType is defined but prop is never used'
6480
+ } ]
6481
+ } ,
6365
6482
{
6366
6483
code : `
6367
6484
const mapStateToProps = state => ({
@@ -6380,6 +6497,24 @@ ruleTester.run('no-unused-prop-types', rule, {
6380
6497
message : '\'books\' PropType is defined but prop is never used'
6381
6498
} ]
6382
6499
} ,
6500
+ {
6501
+ code : `
6502
+ const mapStateToProps = state => ({
6503
+ books: state.books
6504
+ });
6505
+
6506
+ interface InfoLibTableProps extends ReturnType<typeof mapStateToProps> {
6507
+ }
6508
+
6509
+ const App = (props: InfoLibTableProps) => {
6510
+ return <div></div>;
6511
+ }
6512
+ ` ,
6513
+ parser : parsers . TYPESCRIPT_ESLINT ,
6514
+ errors : [ {
6515
+ message : '\'books\' PropType is defined but prop is never used'
6516
+ } ]
6517
+ } ,
6383
6518
{
6384
6519
code : `
6385
6520
const mapStateToProps = state => ({
@@ -6401,6 +6536,27 @@ ruleTester.run('no-unused-prop-types', rule, {
6401
6536
message : '\'username\' PropType is defined but prop is never used'
6402
6537
} ]
6403
6538
} ,
6539
+ {
6540
+ code : `
6541
+ const mapStateToProps = state => ({
6542
+ books: state.books,
6543
+ });
6544
+
6545
+ interface BooksTable extends ReturnType<typeof mapStateToProps> {
6546
+ username: string;
6547
+ }
6548
+
6549
+ const App = (props: BooksTable) => {
6550
+ return <div />;
6551
+ }
6552
+ ` ,
6553
+ parser : parsers . TYPESCRIPT_ESLINT ,
6554
+ errors : [ {
6555
+ message : '\'books\' PropType is defined but prop is never used'
6556
+ } , {
6557
+ message : '\'username\' PropType is defined but prop is never used'
6558
+ } ]
6559
+ } ,
6404
6560
{
6405
6561
code : `
6406
6562
interface BooksTable extends ReturnType<() => {books:Array<string>}> {
@@ -6418,6 +6574,23 @@ ruleTester.run('no-unused-prop-types', rule, {
6418
6574
message : '\'username\' PropType is defined but prop is never used'
6419
6575
} ]
6420
6576
} ,
6577
+ {
6578
+ code : `
6579
+ interface BooksTable extends ReturnType<() => {books:Array<string>}> {
6580
+ username: string;
6581
+ }
6582
+
6583
+ const App = (props: BooksTable) => {
6584
+ return <div></div>;
6585
+ }
6586
+ ` ,
6587
+ parser : parsers . TYPESCRIPT_ESLINT ,
6588
+ errors : [ {
6589
+ message : '\'books\' PropType is defined but prop is never used'
6590
+ } , {
6591
+ message : '\'username\' PropType is defined but prop is never used'
6592
+ } ]
6593
+ } ,
6421
6594
{
6422
6595
code : `
6423
6596
type BooksTable = ReturnType<() => {books:Array<string>}> & {
@@ -6435,6 +6608,23 @@ ruleTester.run('no-unused-prop-types', rule, {
6435
6608
message : '\'username\' PropType is defined but prop is never used'
6436
6609
} ]
6437
6610
} ,
6611
+ {
6612
+ code : `
6613
+ type BooksTable = ReturnType<() => {books:Array<string>}> & {
6614
+ username: string;
6615
+ }
6616
+
6617
+ const App = (props: BooksTable) => {
6618
+ return <div></div>;
6619
+ }
6620
+ ` ,
6621
+ parser : parsers . TYPESCRIPT_ESLINT ,
6622
+ errors : [ {
6623
+ message : '\'books\' PropType is defined but prop is never used'
6624
+ } , {
6625
+ message : '\'username\' PropType is defined but prop is never used'
6626
+ } ]
6627
+ } ,
6438
6628
{
6439
6629
code : `
6440
6630
type mapStateToProps = ReturnType<() => {books:Array<string>}>;
@@ -6455,6 +6645,27 @@ ruleTester.run('no-unused-prop-types', rule, {
6455
6645
} , {
6456
6646
message : '\'username\' PropType is defined but prop is never used'
6457
6647
} ]
6648
+ } ,
6649
+ {
6650
+ code : `
6651
+ type mapStateToProps = ReturnType<() => {books:Array<string>}>;
6652
+
6653
+ type Props = {
6654
+ username: string;
6655
+ }
6656
+
6657
+ type BooksTable = mapStateToProps & Props;
6658
+
6659
+ const App = (props: BooksTable) => {
6660
+ return <div></div>;
6661
+ }
6662
+ ` ,
6663
+ parser : parsers . TYPESCRIPT_ESLINT ,
6664
+ errors : [ {
6665
+ message : '\'books\' PropType is defined but prop is never used'
6666
+ } , {
6667
+ message : '\'username\' PropType is defined but prop is never used'
6668
+ } ]
6458
6669
}
6459
6670
6460
6671
/* , {
0 commit comments