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

forbid-junk-object-types

v1.4.0

Published

TypeScript linter that detects object types and interfaces used by only a single function

Readme

forbid-junk-object-types

A TypeScript linter that detects object types and interfaces used by only a single function. This helps identify cases where developers create generic wrapper types that don't describe actual domain concepts, often to work around ESLint's max-params rule.

Problem

Developers sometimes "cheat" parameter count rules by creating single-use types:

// Bad: Generic wrapper that doesn't describe the domain
interface ProductDetailsParams {
  product: Product
  user: User
  onNavigate: (path: string) => void
  dispatch: Dispatch<Action>
  dimensions: Dimensions | null
  onAddToCart: AddToCartFn
  subscription: Subscription | null
}

const renderProductDetails = (params: ProductDetailsParams) => { ... }

Solution

This tool:

  1. Analyzes TypeScript files using the TypeScript Compiler API
  2. Detects object types/interfaces used by only one function
  3. Reports violations with actionable domain modeling guidance
  4. Supports JSON-based suppression for gradual adoption
  5. Integrates into CI/CD pipelines with fast changed-files-only mode

Installation

npm install forbid-junk-object-types
# or
pnpm add forbid-junk-object-types
# or
yarn add forbid-junk-object-types

Usage

Command Line

# Check all files in current directory
npx forbid-junk-object-types

# Check specific directory
npx forbid-junk-object-types --target-dir ./src

# Check only changed files (for CI)
npx forbid-junk-object-types --changed-only

# Generate suppressions for all violations
npx forbid-junk-object-types --suppress-all

# Check specific files
npx forbid-junk-object-types --files src/foo.ts src/bar.ts

NPM Scripts

Add to your package.json:

{
  "scripts": {
    "check-types": "forbid-junk-object-types",
    "check-types:changed": "forbid-junk-object-types --changed-only"
  }
}

CLI Options

  • --target-dir <path> - Directory to analyze (default: current directory)
  • --suppress-all - Generate suppressions for all violations
  • --changed-only - Only check files changed vs origin/main (for CI)
  • --files <file...> - Specific files to check
  • --help, -h - Show help message

Suppression Mechanism

Suppressions are stored in <target-dir>/junk-object-types-suppressions.json:

{
  "src/apollo/client.ts": {
    "MapsResultSetMergeOptions": {
      "reason": "Apollo Client type policy requires this shape"
    }
  }
}

What Gets Flagged

The tool flags object types/interfaces that:

  • Are only used by a single function (in signature or body)
  • Are not exported (public API types are allowed)
  • Don't extend/implement other types (polymorphism is allowed)
  • Don't end with *Props (React component props pattern - temporary exception)

False Positives

The tool automatically allows:

  • Exported types (may be used by other modules)
  • Types in inheritance hierarchies
  • React component props (*Props suffix)
  • Types used by multiple functions

CI Integration

GitHub Actions

name: CI
on: [push, pull_request]

jobs:
  junk-object-types:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0  # Required for --changed-only
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npm ci
      - name: Check for junk object types (changed files only)
        run: npx forbid-junk-object-types --changed-only

Other CI Systems

The tool uses standard exit codes:

  • 0 - No violations found
  • 1 - Violations found
  • 2 - Error occurred

AI-assisted fixing

This package includes guidance for AI coding assistants at docs/fixing-violations.md. To give your AI tool context for resolving violations:

Claude Code — Add to your project's CLAUDE.md:

@file node_modules/forbid-junk-object-types/docs/fixing-violations.md

Development

# Install dependencies
pnpm install

# Build
pnpm run build

# Run tests
pnpm test

# Run linter
pnpm run lint

Philosophy

Single-use types often indicate missing domain modeling. Instead of creating generic wrappers like *Options, *Config, or *Params, consider:

  1. Inline the parameters - If it's truly a one-off, just use individual parameters
  2. Create a domain concept - Name the type after what it represents in your domain

Examples

// ✗ Generic wrapper
interface SearchOptions {
  query: string
  page: number
}

// ✓ Domain concept
interface SearchQuery {
  query: string
  page: number
}

// ✓ Or inline if truly one-off
function search(query: string, page: number) { ... }

License

MIT

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.