eslint-plugin-no-one-letter-generics
v1.0.2
Published
eslint plugin to detect the one-letter TypeScript generics
Downloads
4
Maintainers
Readme
eslint-plugin-no-one-letter-generics
Eslint plugin to ban the one-letter TypeScript generic types
Usage
Install it with your package manager
With npm:
npm i -D eslint-plugin-no-one-letter-generics
With pnpm:
pnpm add -D eslint-plugin-no-one-letter-generics
With yarn:
yarn add eslint-plugin-no-one-letter-generics --dev
{
"plugins": ["no-one-letter-generics"],
"rules": {
"no-one-letter-generics/no-one-letter-generics": ["warn"]
}
}
Incorrect examples ❌
interface Response<T> {
data: T;
error: string;
loading: boolean;
}
function fetchPaginatedData<T, P, R>(endpoint: string, params: P): Promise<[T[], R]> {
return fetch(endpoint, { params }).then(response => response.json());
}
Correct examples ✅
interface Response<Data> {
data: Data;
error: string;
loading: boolean;
}
function fetchPaginatedData<Item, Params, MetaData>(
endpoint: string,
params: Params
): Promise<[Item[], MetaData]> {
return fetch(endpoint, { params }).then(response => response.json());
}