prefer-type-fest-empty-array
Prefer EmptyArray from type-fest when a type alias defines a readonly tuple with zero elements. The rule is available in the experimental and all presets and requires type-fest 6.
Targeted pattern scopeโ
The complete right-hand side of the alias must be readonly []. A mutable tuple, a tuple with optional or rest elements, and an inline tuple in a larger type fall outside this scope.
What this rule reportsโ
The rule reports the tuple in type NoArguments = readonly []. It leaves inline uses such as type Result = string | readonly [] alone.
Why this rule existsโ
A project that names an empty argument list can reuse TypeFest's definition. The helper preserves the literal length 0 and prevents mutation through the alias.
โ Incorrectโ
export type NoArguments = readonly [];
โ Correctโ
import type { EmptyArray } from "type-fest";
export type NoArguments = EmptyArray;
Behavior and migration notesโ
The rule reports without autofixing. Keep the alias's existing export and local name when changing its definition. If the alias itself is named EmptyArray, import the helper under a different local name.
ESLint flat config exampleโ
import typefest from "eslint-plugin-typefest";
export default [typefest.configs.experimental];
When not to use itโ
Disable this rule if your project prefers the native tuple spelling for named aliases.
Package documentationโ
TypeFest package documentation:
TypeFest defines EmptyArray as readonly [].
import type { EmptyArray } from "type-fest";
const noArguments: EmptyArray = [];
Rule catalog ID: R151