no-redeclare
Added in v0.5.0Configuration
Rule Details
This rule disallows redeclaring variables. It extends ESLint's base no-redeclare to understand TypeScript constructs such as type aliases, interfaces, namespaces, and declaration merging.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
builtinGlobals (default: true)
When true, the rule reports redeclaring ECMAScript built-in globals and names
provided by TypeScript's active lib type definitions, such as Object,
Promise, or HTMLElement. Configured
languageOptions.globals also participate as
built-ins; use the globals catalog exported by @rslint/core to select a
runtime environment. Active /* global */ directives participate as
declarations in either mode; a final :off setting removes that inline global.
Turning off a value global does not remove a same-named TypeScript type global.
ignoreDeclarationMerge (default: true)
When true, the rule ignores redeclarations that are legal TypeScript declaration merges:
interface+interfacenamespace+namespaceclass+interface/class+namespace/class+interface+namespace(at most one class)function+namespace(at most one function)enum+namespace(at most one enum)