-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: consume new scope analysis package (#2039)
- Loading branch information
1 parent
faf9494
commit b91cee7
Showing
58 changed files
with
3,129 additions
and
166,548 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Disallow variable redeclaration (`no-redeclare`) | ||
|
||
## Rule Details | ||
|
||
This rule extends the base [`eslint/no-redeclare`](https://eslint.org/docs/rules/no-redeclare) rule. | ||
It adds support for TypeScript function overloads, and declaration merging. | ||
|
||
## How to use | ||
|
||
```jsonc | ||
{ | ||
// note you must disable the base rule as it can report incorrect errors | ||
"no-redeclare": "off", | ||
"@typescript-eslint/no-redeclare": ["error"] | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
See [`eslint/no-redeclare` options](https://eslint.org/docs/rules/no-redeclare#options). | ||
This rule adds the following options: | ||
|
||
```ts | ||
interface Options extends BaseNoShadowOptions { | ||
ignoreDeclarationMerge?: boolean; | ||
} | ||
|
||
const defaultOptions: Options = { | ||
...baseNoShadowDefaultOptions, | ||
ignoreDeclarationMerge: true, | ||
}; | ||
``` | ||
|
||
### `ignoreDeclarationMerge` | ||
|
||
When set to `true`, the rule will ignore declaration merges between the following sets: | ||
|
||
- interface + interface | ||
- namespace + namespace | ||
- class + interface | ||
- class + namespace | ||
- class + interface + namespace | ||
- function + namespace | ||
|
||
Examples of **correct** code with `{ ignoreDeclarationMerge: true }`: | ||
|
||
```ts | ||
interface A { | ||
prop1: 1; | ||
} | ||
interface A { | ||
prop2: 2; | ||
} | ||
|
||
namespace Foo { | ||
export const a = 1; | ||
} | ||
namespace Foo { | ||
export const b = 2; | ||
} | ||
|
||
class Bar {} | ||
namespace Bar {} | ||
|
||
function Baz() {} | ||
namespace Baz {} | ||
``` | ||
|
||
<sup>Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/no-redeclare.md)</sup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Disallow variable declarations from shadowing variables declared in the outer scope (`no-shadow`) | ||
|
||
## Rule Details | ||
|
||
This rule extends the base [`eslint/no-shadow`](https://eslint.org/docs/rules/no-shadow) rule. | ||
It adds support for TypeScript's `this` parameters, and adds options for TypeScript features. | ||
|
||
## How to use | ||
|
||
```jsonc | ||
{ | ||
// 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](https://eslint.org/docs/rules/no-shadow#options). | ||
This rule adds the following options: | ||
|
||
```ts | ||
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 }`: | ||
|
||
```ts | ||
type Foo = number; | ||
const Foo = 1; | ||
|
||
interface Bar { | ||
prop: number; | ||
} | ||
const Bar = 'test'; | ||
``` | ||
|
||
<sup>Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/no-shadow.md)</sup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.