Skip to content

Latest commit

 

History

History
50 lines (36 loc) · 1.2 KB

File metadata and controls

50 lines (36 loc) · 1.2 KB

Disallow variable declarations from shadowing variables declared in the outer scope (no-shadow)

Rule Details

This rule extends the base eslint/no-shadow rule. It adds support for TypeScript's this parameters, and adds options for TypeScript features.

How to use

{
  // note you must disable the base rule as it can report incorrect errors
  "no-shadow": "off",
  "@typescript-eslint/no-shadow": ["error"]
}

Options

See eslint/no-shadow options. This rule adds the following options:

interface Options extends BaseNoShadowOptions {
  ignoreTypeValueShadow?: boolean;
}

const defaultOptions: Options = {
  ...baseNoShadowDefaultOptions,
  ignoreTypeValueShadow: true,
};

ignoreTypeValueShadow

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