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

fix(eslint-plugin): [unified-signatures] no parameters function #6940

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
3 changes: 3 additions & 0 deletions packages/eslint-plugin/src/rules/unified-signatures.ts
Expand Up @@ -213,6 +213,9 @@ export default util.createRule<Options, MessageIds>({
b.typeParameters !== undefined ? b.typeParameters.params : undefined;

if (ignoreDifferentlyNamedParameters) {
if (b.params.length === 0) {
return false;
}
Copy link
Member

Choose a reason for hiding this comment

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

You need to check that every b.params[i] is defined. Test case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Josh-Cena
I fixed it in 47286f7

for (let i = 0; i < a.params.length; i += 1) {
if (
a.params[i].type === b.params[i].type &&
Expand Down
15 changes: 15 additions & 0 deletions packages/eslint-plugin/tests/rules/unified-signatures.test.ts
Expand Up @@ -177,6 +177,21 @@ function f(v: number, u?: string): void {}
},
{
code: `
function f(v: boolean): number;
function f(): string;
`,
options: [{ ignoreDifferentlyNamedParameters: true }],
},
{
code: `
function f(v: number, u?: string): void {}
function f(v: number): void;
function f(): string;
`,
options: [{ ignoreDifferentlyNamedParameters: true }],
},
{
code: `
function f(a: boolean, ...c: number[]): void;
function f(a: boolean, ...d: string[]): void;
function f(a: boolean, ...c: (number | string)[]): void {}
Expand Down