ESLint plugin that flags single-use type definitions in function parameters.
npm install -d eslint-plugin-ts-inline-parameter-types
# bun add -d eslint-plugin-ts-inline-parameter-typesimport tsInlineParameterTypes from 'eslint-plugin-ts-inline-parameter-types';
export default [
{
plugins: {
'ts-inline-parameter-types': tsInlineParameterTypes,
},
rules: {
'ts-inline-parameter-types/prefer-inline-type-parameters': 'warn',
},
},
];Warns when a type is defined separately but only used once in a function parameter.
type UserProps = {
name: string;
age: number;
};
const User = ({ name, age }: UserProps) => {
return <div>{name}</div>;
};interface Config {
apiUrl: string;
timeout: number;
}
function initApi(config: Config) {
return config.apiUrl;
}const User = ({ name, age }: {
name: string;
age: number;
}) => {
return <div>{name}</div>;
};function initApi(config: {
apiUrl: string;
timeout: number;
}) {
return config.apiUrl;
}Auto-fix handles this transformation automatically.
type UserProps = {
name: string;
};
const UserA = ({ name }: UserProps) => <div>{name}</div>;
const UserB = ({ name }: UserProps) => <span>{name}</span>;export type UserProps = {
name: string;
};
export const User = ({ name }: UserProps) => {
return <div>{name}</div>;
};type Config = {
enabled: boolean;
};
const config: Config = { enabled: true };type Config = {
enabled: boolean;
};
const config: Config = { enabled: true };
function updateConfig(newConfig: Config) {
// ...
}bun install
bun test
bun run format
bun run lintMIT