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

@mckabue/no-same-type-params

v1.0.1

Published

ESLint rule that disallows consecutive function parameters sharing the same type annotation. Encourages refactoring to object parameters.

Readme

@mckabue/no-same-type-params

An ESLint rule that disallows consecutive function parameters sharing the same type annotation.

npm version npm downloads license

The Problem

Functions with multiple consecutive parameters of the same type are error-prone. Callers can easily swap arguments without any compiler warning:

// 😱 Which string is source? Which is dest? Easy to mix up!
function copy(source: string, dest: string, adapterId: string) { ... }

// Swapped source and dest — no TypeScript error!
copy(destPath, sourcePath, adapterId);

The Solution

This rule catches these signatures and encourages refactoring to object parameters:

// ✅ Clear, self-documenting, impossible to swap
function copy({ source, dest, adapterId }: CopyParams) { ... }

copy({ source: sourcePath, dest: destPath, adapterId });

Installation

npm install @mckabue/no-same-type-params --save-dev
# or
yarn add @mckabue/no-same-type-params --dev
# or
pnpm add @mckabue/no-same-type-params --save-dev

Peer Dependencies:

  • eslint: >=8.0.0

You'll also need @typescript-eslint/parser for TypeScript support.

Usage

ESLint Flat Config (eslint.config.js)

import noSameTypeParams from '@mckabue/no-same-type-params';
import * as tsParser from '@typescript-eslint/parser';

export default [
  {
    files: ['**/*.ts', '**/*.tsx'],
    languageOptions: {
      parser: tsParser,
    },
    plugins: {
      '@mckabue': {
        rules: {
          'no-same-type-params': noSameTypeParams,
        },
      },
    },
    rules: {
      '@mckabue/no-same-type-params': 'warn',
    },
  },
];

Legacy Config (.eslintrc)

{
  "plugins": ["@mckabue"],
  "rules": {
    "@mckabue/no-same-type-params": "warn"
  }
}

Examples

❌ Invalid (triggers warning)

// Two consecutive string params
const fn = (a: string, b: string) => {};

// Three consecutive string params (2 warnings)
function copy(source: string, dest: string, adapterId: string) {}

// Default values with same types
const fn = (a: string = 'x', b: string = 'y') => {};

// Same array types
const fn = (a: string[], b: string[]) => {};

// Same union types
const fn = (a: string | number, b: string | number) => {};

✅ Valid (no warnings)

// Different types
const fn = (a: string, b: number) => {};

// Object parameter
const fn = (opts: { source: string; dest: string }) => {};

// Non-consecutive same types (different type in between)
const fn = (a: string, b: number, c: string) => {};

// Untyped parameters (can't compare)
const fn = (a, b) => {};

// Single parameter
const fn = (a: string) => {};

How It Works

The rule inspects FunctionDeclaration, FunctionExpression, and ArrowFunctionExpression nodes. For each pair of consecutive parameters:

  1. Extracts the TypeScript type annotation (handles Identifier, AssignmentPattern, and RestElement)
  2. Compares the source text of both type annotations
  3. Reports if they match

Untyped parameters are ignored — only TypeScript-annotated parameters are compared.

License

MIT © Kabui Charles