Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint-plugin): Add unified-signature rule #178

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f44e75f
Added tslint unified-signatures rule
armanio123 Feb 1, 2019
ce97e17
Added unified-signatures documentation
armanio123 Feb 1, 2019
04a4d8f
Merge branch 'master' into AddTypeScriptUnifiedSignatureRule
armanio123 Feb 1, 2019
ccabfcf
Merge branch 'master' into AddTypeScriptUnifiedSignatureRule
armanio123 Feb 1, 2019
a4d6425
Fixes to unified-signatures rule
armanio123 Feb 2, 2019
c89abbd
Merge branch 'AddTypeScriptUnifiedSignatureRule' of https://github.co…
armanio123 Feb 2, 2019
97c33d9
Fixed formatting on unified-signatures rule
armanio123 Feb 2, 2019
be3cbc5
Merge branch 'master' into AddTypeScriptUnifiedSignatureRule
armano2 Feb 10, 2019
1f4c7fe
docs(eslint-plugin): fix merge conflict
armano2 Feb 10, 2019
2c85da6
Merge remote-tracking branch 'upstream/master' into AddTypeScriptUnif…
armanio123 Feb 26, 2019
f36a9c3
Merge remote-tracking branch 'upstream/master' into AddTypeScriptUnif…
armanio123 Mar 8, 2019
aa24eda
feat(unified-signature): migrated to ts, used messageId
armanio123 Mar 11, 2019
5361fa1
Merge remote-tracking branch 'upstream/master' into AddTypeScriptUnif…
armanio123 Mar 11, 2019
8ddc74f
Merge branch 'AddTypeScriptUnifiedSignatureRule' of https://github.co…
armanio123 Mar 11, 2019
312a182
fix(eslint-plugin): fixed case block lint issue
armanio123 Mar 11, 2019
2fd63d1
fix(unified-signatures): improved types
armanio123 Mar 14, 2019
f2a0d9d
fix(unified-signatures): improved tests
armanio123 Mar 14, 2019
13a26e5
fix(unified-signatures): fixed link in roadmap
armanio123 Mar 14, 2019
c73f278
fix(unified-signatures): fixed lint break
armanio123 Mar 14, 2019
e634646
Merge branch 'master' into AddTypeScriptUnifiedSignatureRule
armanio123 Mar 14, 2019
95f88f8
fix(unified-signatures): more tests improvements
armanio123 Mar 14, 2019
d66539c
Merge branch 'AddTypeScriptUnifiedSignatureRule' of https://github.co…
armanio123 Mar 14, 2019
e755f3b
fix(unified-signatures): even more tests improvements
armanio123 Mar 14, 2019
6bc8f5a
Merge branch 'master' into AddTypeScriptUnifiedSignatureRule
JamesHenry Mar 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/eslint-plugin/README.md
Expand Up @@ -129,5 +129,6 @@ Install [`eslint-config-prettier`](https://github.com/prettier/eslint-config-pre
| [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: |
| [`@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) | | |
| [`@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: |
| [`@typescript-eslint/unified-signatures`](./docs/rules/unified-signatures.md) | Warns for any two overloads that could be unified into one. (`unified-signatures` from TSLint) | | |

<!-- end rule list -->
28 changes: 14 additions & 14 deletions packages/eslint-plugin/ROADMAP.md
@@ -1,10 +1,10 @@
# Roadmap

✅ (28) = done
🌟 (79) = in ESLint core
🔌 (33) = in another plugin
🌓 (16) = implementations differ or ESLint version is missing functionality
🛑 (70) = unimplemented
✅ (29) = done
armano2 marked this conversation as resolved.
Show resolved Hide resolved
🌟 (79) = in ESLint core
🔌 (33) = in another plugin
🌓 (16) = implementations differ or ESLint version is missing functionality
🛑 (69) = unimplemented

## TSLint rules

Expand Down Expand Up @@ -33,7 +33,7 @@
| [`promise-function-async`] | 🛑 | N/A ([relevant plugin][plugin:promise]) |
| [`typedef`] | 🛑 | N/A |
| [`typedef-whitespace`] | ✅ | [`@typescript-eslint/type-annotation-spacing`] |
| [`unified-signatures`] | 🛑 | N/A |
| [`unified-signatures`] | | [`@typescript-eslint/unified-signatures`] |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to add the link at the bottom of the file or else this won't work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


### Functionality

Expand Down Expand Up @@ -96,7 +96,7 @@
| [`use-default-type-parameter`] | 🛑 | N/A |
| [`use-isnan`] | 🌟 | [`use-isnan`][use-isnan] |

<sup>[1]</sup> The ESLint rule also supports silencing with an extra set of parens (`if ((foo = bar)) {}`)
<sup>[1]</sup> The ESLint rule also supports silencing with an extra set of parens (`if ((foo = bar)) {}`)
<sup>[2]</sup> Missing private class member support. [`@typescript-eslint/no-unused-vars`] adds support for some TS-specific features.

### Maintainability
Expand All @@ -120,7 +120,7 @@
| [`prefer-readonly`] | 🛑 | N/A |
| [`trailing-comma`] | 🌓 | [`comma-dangle`][comma-dangle] or [Prettier] |

<sup>[1]</sup> Only warns when importing deprecated symbols
<sup>[1]</sup> Only warns when importing deprecated symbols
<sup>[2]</sup> Missing support for blank-line-delimited sections

### Style
Expand Down Expand Up @@ -179,7 +179,7 @@
| [`variable-name`] | 🌟 | <sup>[2]</sup> |
| [`whitespace`] | 🔌 | Use [Prettier] |

<sup>[1]</sup> Recommended config: `["error", { blankLine: "always", prev: "*", next: "return" }]`
<sup>[1]</sup> Recommended config: `["error", { blankLine: "always", prev: "*", next: "return" }]`
<sup>[2]</sup> [`camelcase`][camelcase], [`no-underscore-dangle`][no-underscore-dangle], [`id-blacklist`][id-blacklist], and/or [`id-match`][id-match]

## tslint-microsoft-contrib rules
Expand Down Expand Up @@ -245,10 +245,10 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
| `use-named-parameter` | 🛑 | N/A |
| `use-simple-attributes` | 🛑 | N/A |

<sup>[1]</sup> Enforces blank lines both at the beginning and end of a block
<sup>[2]</sup> Recommended config: `["error", "ForInStatement"]`
<sup>[3]</sup> Recommended config: `["error", "declaration", { "allowArrowFunctions": true }]`
<sup>[4]</sup> Recommended config: `["error", { "terms": ["BUG", "HACK", "FIXME", "LATER", "LATER2", "TODO"], "location": "anywhere" }]`
<sup>[1]</sup> Enforces blank lines both at the beginning and end of a block
<sup>[2]</sup> Recommended config: `["error", "ForInStatement"]`
<sup>[3]</sup> Recommended config: `["error", "declaration", { "allowArrowFunctions": true }]`
<sup>[4]</sup> Recommended config: `["error", { "terms": ["BUG", "HACK", "FIXME", "LATER", "LATER2", "TODO"], "location": "anywhere" }]`
<sup>[5]</sup> Does not check class fields.

[insecure-random]: https://github.com/desktop/desktop/blob/master/eslint-rules/insecure-random.js
Expand Down Expand Up @@ -310,7 +310,7 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
| `react-a11y-titles` | 🛑 | N/A |
| `react-anchor-blank-noopener` | 🛑 | N/A |

<sup>[1]</sup> TSLint rule is more strict
<sup>[1]</sup> TSLint rule is more strict
<sup>[2]</sup> ESLint rule only reports for click handlers

[prettier]: https://prettier.io
Expand Down
31 changes: 31 additions & 0 deletions packages/eslint-plugin/docs/rules/unified-signatures.md
@@ -0,0 +1,31 @@
# 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 | stting): void;
armanio123 marked this conversation as resolved.
Show resolved Hide resolved
```
```ts
function f(x?: ...number[]): void;
```

## Related to

- TSLint: ['unified-signatures`](https://palantir.github.io/tslint/rules/unified-signatures/)