Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint-plugin): Add unified-signature rule (#178)
- Loading branch information
1 parent
0ef07c4
commit 6ffaa0b
Showing
7 changed files
with
1,234 additions
and
1 deletion.
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
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,33 @@ | ||
# Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter. (unified-signatures) | ||
|
||
Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter. | ||
|
||
## Rule Details | ||
|
||
This rule aims to keep the source code as maintanable as posible by reducing the amount of overloads. | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```ts | ||
function f(x: number): void; | ||
function f(x: string): void; | ||
``` | ||
|
||
```ts | ||
f(): void; | ||
f(...x: number[]): void; | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```ts | ||
function f(x: number | string): void; | ||
``` | ||
|
||
```ts | ||
function f(x?: ...number[]): void; | ||
``` | ||
|
||
## Related to | ||
|
||
- TSLint: ['unified-signatures`](https://palantir.github.io/tslint/rules/unified-signatures/) |
Oops, something went wrong.