Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6ffaa0b

Browse files
Armando AguirreJamesHenry
Armando Aguirre
authored andcommitted
feat(eslint-plugin): Add unified-signature rule (typescript-eslint#178)
1 parent 0ef07c4 commit 6ffaa0b

File tree

7 files changed

+1234
-1
lines changed

7 files changed

+1234
-1
lines changed

packages/eslint-plugin/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,6 @@ Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.e
152152
| [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Requires any function or method that returns a Promise to be marked async. (`promise-function-async` from TSLint) | :heavy_check_mark: | |
153153
| [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string. (`restrict-plus-operands` from TSLint) | | |
154154
| [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: |
155+
| [`@typescript-eslint/unified-signatures`](./docs/rules/unified-signatures.md) | Warns for any two overloads that could be unified into one. (`unified-signatures` from TSLint) | | |
155156

156157
<!-- end rule list -->

packages/eslint-plugin/ROADMAP.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
| [`promise-function-async`] || [`@typescript-eslint/promise-function-async`] |
3535
| [`typedef`] | 🛑 | N/A |
3636
| [`typedef-whitespace`] || [`@typescript-eslint/type-annotation-spacing`] |
37-
| [`unified-signatures`] | 🛑 | N/A |
37+
| [`unified-signatures`] | | [`@typescript-eslint/unified-signatures`] |
3838

3939
### Functionality
4040

@@ -589,6 +589,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
589589
[`@typescript-eslint/no-unnecessary-type-assertion`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md
590590
[`@typescript-eslint/no-var-requires`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-var-requires.md
591591
[`@typescript-eslint/type-annotation-spacing`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/type-annotation-spacing.md
592+
[`@typescript-eslint/unified-signatures`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/unified-signatures.md
592593
[`@typescript-eslint/no-misused-new`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-misused-new.md
593594
[`@typescript-eslint/no-object-literal-type-assertion`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-object-literal-type-assertion.md
594595
[`@typescript-eslint/no-this-alias`]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-this-alias.md
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter. (unified-signatures)
2+
3+
Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter.
4+
5+
## Rule Details
6+
7+
This rule aims to keep the source code as maintanable as posible by reducing the amount of overloads.
8+
9+
Examples of **incorrect** code for this rule:
10+
11+
```ts
12+
function f(x: number): void;
13+
function f(x: string): void;
14+
```
15+
16+
```ts
17+
f(): void;
18+
f(...x: number[]): void;
19+
```
20+
21+
Examples of **correct** code for this rule:
22+
23+
```ts
24+
function f(x: number | string): void;
25+
```
26+
27+
```ts
28+
function f(x?: ...number[]): void;
29+
```
30+
31+
## Related to
32+
33+
- TSLint: ['unified-signatures`](https://palantir.github.io/tslint/rules/unified-signatures/)

0 commit comments

Comments
 (0)