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-ts-type-forge

v0.4.3

Published

ESLint rules that steer type declarations toward ts-type-forge idioms.

Readme

eslint-plugin-ts-type-forge

ESLint rules that steer TypeScript type declarations toward ts-type-forge idioms — replacing hand-rolled uniform tuple spellings with the library's named length-constrained tuple types. Every rule is auto-fixable, and every rewrite is type-preserving.

Installation

npm install --save-dev eslint-plugin-ts-type-forge

Requires ESLint 9+ (flat config) and TypeScript. No rule is type-aware, so a configured TypeScript project is not required.

Usage (flat config)

The plugin ships a recommended config preset that registers the plugin and turns on every rule at error:

// eslint.config.mts
import { eslintPluginTsTypeForge } from 'eslint-plugin-ts-type-forge';

export default [eslintPluginTsTypeForge.configs.recommended];

Since the preset is a plain flat-config object, individual rules can be adjusted by a later config entry — for instance to pass options:

// eslint.config.mts
import {
    eslintPluginTsTypeForge,
    type EslintTsTypeForgeRules,
} from 'eslint-plugin-ts-type-forge';

export default [
    eslintPluginTsTypeForge.configs.recommended,
    {
        rules: {
            'ts-type-forge/prefer-canonical-length-constrained-tuple': [
                'error',
                { importStyle: 'named' },
            ],
        } satisfies Partial<EslintTsTypeForgeRules>,
    },
];

Or register the plugin yourself and pick the rules one by one:

// eslint.config.mts
import {
    eslintPluginTsTypeForge,
    type EslintTsTypeForgeRules,
} from 'eslint-plugin-ts-type-forge';

export default [
    {
        plugins: { 'ts-type-forge': eslintPluginTsTypeForge },
        rules: {
            'ts-type-forge/prefer-canonical-length-constrained-tuple': 'error',
        } satisfies Partial<EslintTsTypeForgeRules>,
    },
];

Rules

| Rule | Description | | :------------------------------------------ | :--------------------------------------------------------------------------------------- | | prefer-canonical-length-constrained-tuple | Replace hand-rolled uniform tuple spellings with the canonical ts-type-forge tuple type. |

It covers the whole uniform-tuple family:

| spelling | readonly target | mutable target | | :------------------------- | :----------------------- | :------------------------------ | | [V, ...V[]] | NonEmptyTuple<V> | MutableNonEmptyTuple<V> | | [V, …×N, ...V[]] (N ≥ 2) | MinLengthTuple<N, V> | MutableMinLengthTuple<N, V> | | [V, …×N] (N ≥ 2) | FixedLengthTuple<N, V> | MutableFixedLengthTuple<N, V> |

Why the *Tuple types and not NonEmptyArray / MinLengthArray

The *Array family (NonEmptyArray, MinLengthArray, FixedLengthArray, …) encodes its length constraint in a brand: NonEmptyArray<V> is MinLengthTuple<1, V> & Brand<…>, a strict subtype of readonly [V, ...V[]]. Rewriting a declaration to it would narrow the type — an array literal is not assignable to a branded type — so the autofix could break call sites.

The *Tuple family is structural and therefore exactly equal to the spelled-out tuple, which makes every fix in this plugin a pure rename.

Examples

// ❌
type Names = readonly [string, ...string[]];
type Queue = [number, ...number[]];
type Rgb = readonly [number, number, number];
type AtLeastTwo = [string, string, ...string[]];

// ✅
type Names = NonEmptyTuple<string>;
type Queue = MutableNonEmptyTuple<number>;
type Rgb = FixedLengthTuple<3, number>;
type AtLeastTwo = MutableMinLengthTuple<2, string>;

Single-element tuples without a rest (readonly [V]) are left alone — they read better as-is than FixedLengthTuple<1, V>.

The rule deliberately leaves alone

  • heterogeneous tuples (readonly [string, number]);
  • labelled members (readonly [head: V, ...tail: V[]]), because rewriting them would silently drop the labels;
  • optional members (readonly [V, V?]) and rest-only tuples ([...V[]]);
  • files that already bind the target name to something else (a local alias, or an import from another module).

Options

| Option | Type | Default | Description | | :------------ | :-------------------- | :--------- | :-------------------------------------------------------- | | importStyle | 'global' \| 'named' | 'global' | How the ts-type-forge type is brought into scope. | | maxLength | integer | 10 | Longest tuple prefer-length-constrained-tuple rewrites. |

  • 'global' — the ambient globals of ts-type-forge/global are in use (/// <reference types="ts-type-forge/global" />), so the autofix only rewrites the type and never touches imports.
  • 'named' — the autofix additionally inserts import { type … } from 'ts-type-forge'; when the name is not imported yet.

Either way, if the file already imports the target type from ts-type-forge (possibly under an alias), the autofix reuses that binding.

{
    rules: {
        'ts-type-forge/prefer-canonical-length-constrained-tuple': [
            'error',
            { importStyle: 'named', maxLength: 6 },
        ],
    },
}

License

Apache-2.0