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 🙏

© 2024 – Pkg Stats / Ryan Hefner

prettier-plugin-sort-members

v0.2.2

Published

## Usage

Downloads

6,666

Readme

prettier-plugin-sort-members

Usage

npm install prettier-plugin-sort-members --save-dev
# or
yarn add prettier-plugin-sort-members --dev
# or
bun add prettier-plugin-sort-members --dev

Edit your prettierrc.

{
	// ...
	"plugins": ["prettier-plugin-sort-members"]
}

Optionally, configure options.

{
	// ...
	"plugins": ["prettier-plugin-sort-members"],
	"sortMembersAlphabetically": true
}

Overview

This plugin sorts members of your classes, interfaces, and type aliases.

// Before
class MyClass {
	d(): void {}
	e: null;
	c: string;
	a(): void {}
	b: number;
	constructor() {}
}

// After
class MyClass {
	e: null;
	c: string;
	b: number;
	constructor() {}
	d(): void {}
	a(): void {}
}

// After (with option sortMembersAlphabetically = true)
class MyClass {
	c: string;
	b: number;
	e: null;
	constructor() {}
	a(): void {}
	d(): void {}
}

The order respects default order of @typescript-eslint/member-ordering

Options

sortMembersAlphabetically

  • type: boolean
  • default: false

A boolean value to enable alphabetical ordering. Other criteria such as visibility still precedes even if set true.

keepGettersAndSettersTogether

  • type: boolean
  • default: false
  • since: 0.2.0

A boolean value to place getters and setters same group. You can use it to avoid conflicting with @typescript-eslint/adjacent-overload-signatures.

skipSortForSubclassOf (experimental)

  • type: Array<string>
  • default: []
  • since: 0.2.0

This option takes an array of strings representing the names of base classes. When set, the plugin will not sort members of any class that extends the specified base classes. It's particularly useful when any class that extends the specified base class should follow other ordering such as react/sort-comp

// example if you are using react/sort-comp
{
	"skipSortForSubclassOf": ["React.Component"]
}

Contributing

Reporting issues

You can submit an issue to report a bug, propose a feature or anything else. Feedback is welcome. To report a security vulnerability, please use our create an advisory form on GitHub.

Developing

prettier-plugin-sort-members is developed with Bun. Install Bun if you don't have it yet.

To get up and running, install dependencies and run tests:

bun install
bun test

Don't forget to add tests for your changes before you submit a PR.