This rule extends the base eslint/no-shadow
rule.
It adds support for TypeScript's this
parameters, and adds options for TypeScript features.
{
// note you must disable the base rule as it can report incorrect errors
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"]
}
See eslint/no-shadow
options.
This rule adds the following options:
interface Options extends BaseNoShadowOptions {
ignoreTypeValueShadow?: boolean;
}
const defaultOptions: Options = {
...baseNoShadowDefaultOptions,
ignoreTypeValueShadow: true,
};
When set to true
, the rule will ignore when you name a type and a variable with the same name.
Examples of correct code with { ignoreTypeValueShadow: true }
:
type Foo = number;
const Foo = 1;
interface Bar {
prop: number;
}
const Bar = 'test';
Taken with ❤️ from ESLint core