no-shadow
Configuration
Disallow variable declarations from shadowing variables declared in the outer scope.
Rule Details
Shadowing occurs when a local variable shares the same name as a variable in its containing scope. Inside the inner scope, the outer variable becomes inaccessible, which can be a source of confusion.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
builtinGlobals
Shadowing a built-in global (for example Object, Array) is reported when
this option is true. Default: false.
Configured languageOptions.globals and active /* global */ directives
participate as built-in globals; an explicit "off" setting un-declares the
name, so shadowing it is no longer reported.
hoist
Controls whether shadowing is reported before the outer declaration. Default:
"functions".
"functions": report only before function declarations."all": always report, even when the outer declaration appears after the inner one."never": never report before the outer declaration."types": report when the outer declaration is a type (typeorinterface)."functions-and-types": report for both outer function declarations and type declarations.
allow
Array of names for which shadowing is allowed. Default: [].
ignoreOnInitialization
Ignores shadowing inside the initializer of the outer declaration when it is
called as a callback or IIFE. Default: false.
ignoreTypeValueShadow
Ignores shadowing between a value and a type of the same name (TypeScript).
Default: true.
ignoreFunctionTypeParameterNameValueShadow
Ignores shadowing for parameters declared inside a function type. Default:
true.