noRedeclare
Diagnostic Category: lint/suspicious/noRedeclare
Since: v1.0.0
Sources:
- Same as: 
no-redeclare - Same as: 
@typescript-eslint/no-redeclare 
Description
Section titled “Description”Disallow variable, function, class, and type redeclarations in the same scope.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”var a = 3;var a = 10;code-block.js:2:5 lint/suspicious/noRedeclare ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Shouldn’t redeclare ‘a’. Consider to delete it or rename it.
  
    1 │ var a = 3;
  > 2 │ var a = 10;
      │     ^
    3 │ 
  
  ℹ ‘a’ is defined here:
  
  > 1 │ var a = 3;
      │     ^
    2 │ var a = 10;
    3 │ 
  
let a = 3;let a = 10;code-block.js:2:5 lint/suspicious/noRedeclare ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Shouldn’t redeclare ‘a’. Consider to delete it or rename it.
  
    1 │ let a = 3;
  > 2 │ let a = 10;
      │     ^
    3 │ 
  
  ℹ ‘a’ is defined here:
  
  > 1 │ let a = 3;
      │     ^
    2 │ let a = 10;
    3 │ 
  
function f() {}function f() {}code-block.js:2:10 lint/suspicious/noRedeclare ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Shouldn’t redeclare ‘f’. Consider to delete it or rename it.
  
    1 │ function f() {}
  > 2 │ function f() {}
      │          ^
    3 │ 
  
  ℹ ‘f’ is defined here:
  
  > 1 │ function f() {}
      │          ^
    2 │ function f() {}
    3 │ 
  
class C {    static {        var c = 3;        var c = 10;    }}code-block.js:4:13 lint/suspicious/noRedeclare ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Shouldn’t redeclare ‘c’. Consider to delete it or rename it.
  
    2 │     static {
    3 │         var c = 3;
  > 4 │         var c = 10;
      │             ^
    5 │     }
    6 │ }
  
  ℹ ‘c’ is defined here:
  
    1 │ class C {
    2 │     static {
  > 3 │         var c = 3;
      │             ^
    4 │         var c = 10;
    5 │     }
  
type Person = { name: string; }class Person { name: string; }code-block.ts:2:7 lint/suspicious/noRedeclare ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ Shouldn’t redeclare ‘Person’. Consider to delete it or rename it.
  
    1 │ type Person = { name: string; }
  > 2 │ class Person { name: string; }
      │       ^^^^^^
    3 │ 
  
  ℹ ‘Person’ is defined here:
  
  > 1 │ type Person = { name: string; }
      │      ^^^^^^
    2 │ class Person { name: string; }
    3 │ 
  
var a = 3;a = 10;class Foo {    bar(a: A);    bar(a: A, b: B);    bar(a: A, b: B) {}}How to configure
Section titled “How to configure”{  "linter": {    "rules": {      "suspicious": {        "noRedeclare": "error"      }    }  }}