Skip to content

useConsistentTupleLabels (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"nursery": {
"useConsistentTupleLabels": "error"
}
}
}
}

Require either all or none of the elements of a tuple type to have labels.

A tuple type describes an array with a fixed number of elements, where each position has its own type. Each element can have a label, such as x in [x: number, y: number], that describes what the position means. When only some elements have labels, the elements without one look like they were forgotten, and the tuple is harder to read.

This rule reports the elements without a label in a tuple type where at least one other element has a label. Tuple types where no element has a label are allowed. A rest element, such as ...rest: number[], can also have a label, and is checked the same way as the other elements.

type Point = [x: number, number];
code-block.ts:1:26 lint/nursery/useConsistentTupleLabels ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This tuple element has no label, but other elements of the same tuple do.

> 1 │ type Point = [x: number, number];
│ ^^^^^^
2 │

ℹ Labeling only some elements of a tuple makes it unclear what the other positions mean.

ℹ Add a label to this element, or remove the labels from the other elements.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

type Route = [name: string, ...string[]];
code-block.ts:1:29 lint/nursery/useConsistentTupleLabels ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ℹ This tuple element has no label, but other elements of the same tuple do.

> 1 │ type Route = [name: string, ...string[]];
│ ^^^^^^^^^^^
2 │

ℹ Labeling only some elements of a tuple makes it unclear what the other positions mean.

ℹ Add a label to this element, or remove the labels from the other elements.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

type Point = [x: number, y: number];
type Pair = [number, number];
type Route = [name: string, ...segments: string[]];