src/content/docs/linter/rules/no-redeclare.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/suspicious/noRedeclare`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`no-redeclare`](https://eslint.org/docs/latest/rules/no-redeclare) - Same as [`@typescript-eslint/no-redeclare`](https://typescript-eslint.io/rules/no-redeclare){
"linter": {
"rules": {
"suspicious": {
"noRedeclare": "error"
}
}
}
}
Disallow variable, function, class, and type redeclarations in the same scope.
var a = 3;
var a = 10;
let a = 3;
let a = 10;
function f() {}
function f() {}
class C {
static {
var c = 3;
var c = 10;
}
}
type Person = { name: string; }
class Person { name: string; }
var a = 3;
a = 10;
class Foo {
bar(a: A);
bar(a: A, b: B);
bar(a: A, b: B) {}
}