Registry / testing / prettier-plugin-sort-members

prettier-plugin-sort-members

JSON →
library0.2.4jsnpmunverified

Prettier plugin to sort class, interface, and type alias members (properties, methods, getters/setters) in a configurable order. Current stable version 0.2.4, compatible with Prettier ^3.0.0. Released regularly with bug fixes and features. Differentiators: supports default `@typescript-eslint/member-ordering` order, optional alphabetical sorting, `keepGettersAndSettersTogether`, and experimental `skipSortForSubclassOf` for React component compatibility. Lightweight, no runtime dependencies beyond Prettier.

npm install prettier-plugin-sort-members
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-SO
P
prettier-plugin-sort-members
testingjavascriptv0.2.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (plugin registration)
// In prettierrc: { "plugins": ["prettier-plugin-sort-members"] }
// Incorrect: adding as regular module import
This is a Prettier plugin, not a programmatic import. Register via plugins array in Prettier config.

Install plugin, configure options in Prettier config, and format TypeScript classes to sort members.

// 1. Install npm install --save-dev prettier-plugin-sort-members // 2. In .prettierrc: { "plugins": ["prettier-plugin-sort-members"], "sortMembersAlphabetically": true, "keepGettersAndSettersTogether": true } // 3. Example input: class MyClass { d(): void {} e: null; c: string; a(): void {} b: number; constructor() {} } // 4. Run prettier (format will sort members alphabetically, but keep getters/setters together): // After formatting, members will be ordered by: static, instance, constructor, methods, with alphabetical sub-ordering
Debug
Known issues
gotchaPlugin only sorts based on Prettier's output; conflicts with ESLint member-ordering rules may occur if order differs.
fix
Align options with ESLint's member-ordering configuration, e.g., set sortMembersAlphabetically to match ESLint's alphabetical ordering.
affects: >=0.0.0
deprecatedskipSortForSubclassOf is experimental and may change in future versions.
fix
Use with caution; prefer alternative patterns if stability is required.
affects: >=0.2.0
breakingVersion 0.2.0 introduced keepGettersAndSettersTogether and changed default behavior to couple getters/setters when option is set. Existing configs without this option remain unchanged.
fix
If you rely on getters and setters being separated, explicitly set "keepGettersAndSettersTogether": false.
affects: >=0.2.0
gotchaThe plugin sorts literal keys in object types only when sortMembersAlphabetically is true.
fix
Set sortMembersAlphabetically to true if you want alphabetical sorting of keys in type/interface literals.
affects: >=0.1.1
Errors
Common errors & fixes
Error: Cannot find module 'prettier-plugin-sort-members'
Plugin not installed or not in node_modules.
fix
Run npm install --save-dev prettier-plugin-sort-members
Cannot read properties of undefined (reading 'sortMembersAlphabetically')
Prettier version < 3.0.0 does not support plugins that use new API.
fix
Upgrade Prettier to ^3.0.0 and ensure prettier-plugin-sort-members is compatible.
TypeError: prettier.resolveConfig is not a function
Plugin being used programmatically with older Prettier API.
fix
Use Prettier's built-in plugin loading via config file or upgrade to Prettier v3.
ESLint: member-ordering rule conflict with prettier-plugin-sort-members output
ESLint enforces a different member order than the plugin produces.
fix
Adjust ESLint member-ordering config to match plugin's order, or disable rule if plugin is used.
Upgrade
Version history
0.2.4latest on npm
Audit
Dependencies
prettierrequiredpeer dependency required to function as a Prettier plugin
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-plugin-sort-members — npm install prettier-plugin-sort-members · libregistry