close

consistent-tuple-labels

Unreleased

Configuration

PresetConfigured Value
✅ unicornPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, unicornPlugin } from '@rslint/core';

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/consistent-tuple-labels': 'error',
    },
  },
]);

Rule Details

Require every element of a tuple type to have a label when any element is labeled. Tuples whose elements are all labeled or all unlabeled are left unchanged.

Examples of incorrect code for this rule:

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

Examples of correct code for this rule:

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

The rule does not provide an autofix because it cannot infer meaningful labels.

Original Documentation