Skip to main content

no-t

Disallow single-character generic type parameter names.

This rule helps keep type parameter names self-documenting and easier to read in larger codebases.

Targeted pattern scope

This rule targets type parameter identifiers in generic declarations.

It reports:

  • single-character names (for example T, K, U), and
  • names with two or more characters that do not start with configured prefix (when prefix is set).

What this rule reports

  • Generic type parameters with a single-character name (for example T, U, K).
  • Optional: type parameter names that do not use a configured prefix.

Why this rule exists

Single-character type parameter names are terse but often ambiguous outside narrowly scoped declarations. Descriptive names improve readability and maintenance.

❌ Incorrect

function identity<T>(value: T): T {
return value;
}

✅ Correct

function identity<ValueType>(value: ValueType): ValueType {
return value;
}

Behavior and migration notes

This rule reports only and does not provide an autofix.

Adopt in warning mode first, then rename generic parameters to descriptive names in touched code paths.

Options

type Options = [
{
prefix?: string;
}?,
];

Default configuration

[{}];

prefix

Type: string

When configured, all type parameter names longer than one character must start with the specified prefix.

Example configuration:

"etc-misc/no-t": ["error", { prefix: "Type" }];

Additional examples

// config: { prefix: "Type" }
function map<TypeInput, TypeOutput>(value: TypeInput): TypeOutput {
return value as unknown as TypeOutput;
}
// ✅ valid

function map<Input, Output>(value: Input): Output {
return value as unknown as Output;
}
// ❌ reported because names do not start with "Type"

ESLint flat config example

import etcMisc from "eslint-plugin-etc-misc";

export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/no-t": "error",
},
},
];

When not to use it

Disable this rule if your project intentionally follows short generic naming conventions (for example, single-letter parameters in mathematical or algorithm-heavy APIs).

Package documentation

Rule catalog ID: R043

Further reading

Adoption resources

  • Start at warning level in CI, then move to error after cleanup.
  • Use focused codemods/autofix batches per package or directory.