@typescript-eslint/adjacent-overload-signatures
Require the overloads of a function to be next to each other
Also called typescript-eslint/adjacent-overload-signatures, typescript/adjacent-overload-signatures
When a function's overloads are spread across a file, a reader who finds the first group thinks they've seen every way to call it, and misses the one further down.
The rule looks at functions in a file, block, or namespace, and at the members of classes, interfaces, and object types. A static method and an instance method with the same name are different methods.
Configure#
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"@typescript-eslint/adjacent-overload-signatures" = "error" # or "warn"Examples#
example.ts1 problem
interface Storage {
get(key: string): string;
clear(): void;
get(key: string, fallback: string): string;All get signatures should be adjacent.
}example.ts1 problem
declare function parse(input: string): number;
declare function format(value: number): string;
declare function parse(input: Uint8Array): number;All parse signatures should be adjacent.example.tsNo problems
interface Storage {
get(key: string): string;
get(key: string, fallback: string): string;
clear(): void;
}example.tsNo problems
class Cache {
static create(): Cache {
return new Cache();
}
size = 0;
create(): void {}
}