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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tidyclass

v0.3.0

Published

Sorts classes and methods alphabetically

Readme

tidyclass

🧹 tidyclass - A CLI tool to automatically sort TypeScript class members in a structured order.

Installation

You can install tidyclass globally or use it as a local dependency in your project.

npm install -g tidyclass

or

npm install --save-dev tidyclass

Usage

[!TIP]

It's recommended to commit your work before running the script.

[!NOTE]

If you installed locally to your project, use npx tidyclass.

To sort a single TypeScript file, run:

tidyclass path/to/file.ts

If no file is specified, tidyclass will process all TypeScript files in the project:

tidyclass

If you want to format the sorted files with Biome, use -b or --biome option, or with Prettier, use the -p or --prettier option:

tidyclass -b

Options

Opt classes out: To opt certain classes out of the member sorting, add the following JSDoc comment to the class.

/**
 * @internal_sort skip
 */
class ThisClassWillNotBeSorted

| CLI Option | Description | |-----------------|---------------------------------------------------------------| | -b, --biome | Run Biome formatting on affected files after sorting |
| -p, --prettier | Run Prettier formatting on affected files after sorting |

Sorting Order

Tidyclass organizes class members in the following structured order:

  1. Static public variables
  2. Static private variables
  3. Static public methods
  4. Static private methods
  5. Public instance variables
  6. Private instance variables
  7. Constructor
  8. Public instance methods
  9. Private instance methods

Each category is sorted alphabetically to ensure consistency. If the class structure changes, tidyclass updates it while maintaining logical order.

Example

Before running tidyclass:

class MyClass {
    public rivetingFunc() {}
    private instanceVarB = 2;
    static private staticFuncB() {}
    public instanceVarA = 1;
    private funcX() {}
    private static staticVarB = 20;
    private static staticVarA = 10;
    public static staticFuncAA() {}
    static public staticVarAB = 5;
    private funcC() {}
    public funcA() {}
    constructor() {}
    static private staticFuncA() {}
}

After running tidyclass (with formatting on):

class MyClass {
    public static staticVarAB = 5;
    private static staticVarA = 10;
    private static staticVarB = 20;

    public static staticFuncAA() {}

    private static staticFuncA() {}

    private static staticFuncB() {}

    public instanceVarA = 1;
    private instanceVarB = 2;

    constructor() {}

    public funcA() {}

    public rivetingFunc() {}

    private funcC() {}

    private funcX() {}
}

License

Apache 2.0