Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 809 Bytes

no-t.md

File metadata and controls

48 lines (37 loc) · 809 Bytes

Use descriptive type parameters (no-t)

This rule forbids the use of single-character type parameters.

Rule details

Examples of incorrect code for this rule:

function toArray<T>(elements: ArrayLike<T>) {
  return Array.from(elements);
}
type Entry<K, V> = {
  key: K;
  value: V;
};

Examples of correct code for this rule:

function toArray<Element>(elements: ArrayLike<Element>) {
  return Array.from(elements);
}
type Entry<Key, Value> = {
  key: Key;
  value: Value;
};

Options

This rule accepts a single option which is an object with a prefix property that indicates the prefix - if any - that must be used for all type parameters. By default, there is no prefix.

{
  "etc/no-t": [
    "error",
    { "prefix": "T" }
  ]
}