File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -66,4 +66,14 @@ function Baz() {}
66
66
namespace Baz {}
67
67
```
68
68
69
+ ** Note:** Even with this option set to true, this rule will report if you name a type and a variable the same name. ** _ This is intentional_ ** .
70
+ Declaring a variable and a type and a variable the same is usually an accident, and it can lead to hard-to-understand code.
71
+ If you have a rare case where you're intentionally naming a type the same name as a variable, use a disable comment. For example:
72
+
73
+ ``` ts
74
+ type something = string ;
75
+ // eslint-disable-next-line @typescript-eslint/no-redeclare -- intentionally naming the variable the same as the type
76
+ const something = 2 ;
77
+ ```
78
+
69
79
<sup >Taken with ❤️ [ from ESLint core] ( https://github.com/eslint/eslint/blob/master/docs/rules/no-redeclare.md ) </sup >
Original file line number Diff line number Diff line change @@ -627,5 +627,20 @@ namespace A {}
627
627
} ,
628
628
] ,
629
629
} ,
630
+ {
631
+ code : `
632
+ type something = string;
633
+ const something = 2;
634
+ ` ,
635
+ errors : [
636
+ {
637
+ messageId : 'redeclared' ,
638
+ data : {
639
+ id : 'something' ,
640
+ } ,
641
+ line : 3 ,
642
+ } ,
643
+ ] ,
644
+ } ,
630
645
] ,
631
646
} ) ;
You can’t perform that action at this time.
0 commit comments