redeclared-variable
What it does
Section titled “What it does”Reports a name declared again in the same scope (var twice, a var and a parameter, two functions). In TypeScript files declaration merging (interfaces, namespaces, a class with an interface) is allowed. Built-in globals are not checked.
Why it matters
Section titled “Why it matters”The second declaration replaces or merges with the first, so the earlier one is dead, and which of the two a use reaches depends on the order. It is usually a copy that should have had another name.
To fix, remove the repeat, or rename one of them.
Example
Section titled “Example”...function f(a, a2) { var a; return arguments; }var x = 1; var x = 2; function x() {}function f2() {} function f2() {}...Configuration
Section titled “Configuration”js: lint: rules: redeclared-variable: warn # off (default), warn, errorpython: lint: rules: redeclared-variable: warn # off (default), warn, errorEnabled by the presets: js/eslint-recommended, js/biome-recommended, python/ruff.
Suppress one line with sudsy-disable-next-line redeclared-variable in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| eslint | no-redeclare |
partial | the builtinGlobals option and /*global*/ comments are not supported (the files are modules, whose top scope is not the global scope) |
| ruff | F811 |
full | |
| typescript-eslint | no-redeclare |
partial | builtinGlobals and /*global*/ comments are not supported; ignoreDeclarationMerge keeps its default |