Skip to content
Sarj Code Standards

no-positional-tuple-return

Disallow returning a multi-field tuple from a named function; return a named object so call sites cannot mismatch slots.

Why

Tuple fields are identified only by position, so reordering can preserve types while changing meaning.

Fix

Return an object whose property names describe each value.

Examples

Before — flagged Keep a mutable tuple-return object checked
src/keys.ts
const userKeys = {
all: ["users"],
detail: (id: string) => [...userKeys.all, id] as const,
};
After — preferred Inherit the query-key anchor const context
src/keys.ts
const userKeys = {
all: ["users"],
detail: (id: string) => [...userKeys.all, id] as const,
} as const;
Before — flagged Do not expose positional fields
src/download.ts
export function download(): [string, number] {
return impl();
}
After — preferred Return named fields
src/download.ts
export function download(): { body: string; status: number } {
return impl();
}