npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-prefer-inline-types

v1.0.3

Published

ESLint plugin to enforce inline TypeScript types in function parameters

Readme

eslint-plugin-prefer-inline-types

ESLint plugin that flags single-use type definitions so you can inline them for clarity. You can limit the rule to function parameters only or apply it everywhere (return types, variables, class properties, etc.).

Installation

npm install -D eslint-plugin-prefer-inline-types
# or
pnpm add -D eslint-plugin-prefer-inline-types
import preferInlineTypes from 'eslint-plugin-prefer-inline-types';

export default [
  {
    plugins: {
      'prefer-inline-types': preferInlineTypes,
    },
    rules: {
      'prefer-inline-types/prefer-inline-type-parameters': 'warn',
      // Or limit to function parameters only:
      // 'prefer-inline-types/prefer-inline-type-parameters': ['warn', { scope: 'parameters' }],
    },
  },
];

Rule: prefer-inline-type-parameters

Warns when a type is defined separately but only used once. Supports both non-generic and generic type aliases and interfaces. Also fixes types used nested inside other types (e.g. Map<string, PushStatus>).

Options

| Option | Values | Default | Description | | -------- | -------------- | ------------ | ----------- | | scope | "parameters", "everywhere" | "everywhere" | "parameters" — only report types that are used once in a function parameter. "everywhere" — report any type that is used exactly once (parameters, return types, variables, class properties, etc.). |

❌ Incorrect

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;
}

✅ Correct

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 (including nested usage like Map<string, MyType>).


Skipped cases

Type is reused

type UserProps = {
  name: string;
};

const UserA = ({ name }: UserProps) => <div>{name}</div>;
const UserB = ({ name }: UserProps) => <span>{name}</span>;

Type is exported

export type UserProps = {
  name: string;
};

export const User = ({ name }: UserProps) => {
  return <div>{name}</div>;
};

Type used in non-parameter context (only when scope: "parameters")

When scope is "parameters" (default is "everywhere"), single-use types in variables, return types, or class properties are not reported:

type Config = {
  enabled: boolean;
};

const config: Config = { enabled: true };

Type used in multiple contexts

type Config = {
  enabled: boolean;
};

const config: Config = { enabled: true };

function updateConfig(newConfig: Config) {
  // ...
}

Development

bun install
bun test
bun run format
bun run lint

Or with npm:

npm install
npm test

Publishing to npm

  1. Log in: npm login
  2. Bump version in package.json if needed (e.g. 1.0.2)
  3. Publish: npm publish (or npm publish --access public for scoped packages)

Credits

This fork adds three improvements on top of the original:

  1. Generic type support — The original skips type aliases and interfaces that have type parameters, so e.g. type ConnectDeps<D, S, O> = { ... } used once in a parameter was never reported. Here, generic types are included: if such a type is used only once in a function parameter, the rule reports it and the fix inlines the type body as in the non-generic case.

  2. Nested type autofix — The original fix only runs when the type is the direct parameter type (param: MyType). If the type appears inside another type (e.g. param: Map<string, PushStatus> or tx: IDBPTransaction<..., StoreNames, ...>), the fix bailed out and did nothing. This version also inlines in those cases by replacing the nested type reference with the type body instead of replacing the whole annotation.

  3. TypeScript declarations — A lib/index.d.ts is shipped so that projects using the plugin get typed imports and do not need // @ts-expect-error when adding it to their ESLint config.

  4. Configurable scope — Option scope: "parameters" | "everywhere" (default "everywhere"). Use "parameters" to only flag single-use types in function parameters; use "everywhere" to flag them in any position (return types, variables, class properties, etc.).

License

MIT