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-sort-properties

v1.1.13

Published

ESLint rules for sorting properties of object expressions, object destructures, and type literals interfaces for TypeScript by their keys.

Readme

eslint-plugin-sort-properties

This plugin provides rules that enforce the sorting of properties in object expressions, object destructuring for JavaScript, and type literals, interface members for TypeScript.
Inspired by eslint-plugin-sort-keys-fix and eslint-plugin-sort-destructure-keys, it is designed to be auto-fixable. But with optimization, it is up to 11x faster to fix, 6x to parse, 60x to apply rule than these plugins.benchmark
And this plugin can be configured to include leading/trailing comments as part of the property, so there's less chance of breaking the placement of comments.
Additionally, inspired by the eslint-plugin-react/jsx-sort-props rule, it supports giving higher priority to function properties when sorting.

Demo GIF

Table of Contents

Rules

⚠️ Configurations set to warn in.
🌐 Set in the all configuration.
JavaScript Set in the js configuration.
TypeScript Set in the ts configuration.
🔧 Automatically fixable by the --fix CLI option.
💡 Manually fixable by editor suggestions.

| Name | Description | ⚠️ | 🔧 | 💡 | | :------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------- | :-------------------------------------------------------------------------- | :-- | :-- | | sort-interface | Enforce interface members to be sorted. | 🌐 TypeScript | 🔧 | 💡 | | sort-object-destructing | Enforce properties in object destructuring to be sorted. | 🌐 JavaScript | 🔧 | 💡 | | sort-object-expression | Enforce properties in object expressions to be sorted. | 🌐 JavaScript | 🔧 | 💡 | | sort-type-literal | Enforce properties in type literals to be sorted. | 🌐 TypeScript | 🔧 | 💡 |

Installation

You'll first need to install ESLint:

npm install eslint --save-dev

Next, install eslint-plugin-sort-properties:

npm install eslint-plugin-sort-properties --save-dev

Available configurations

| | Name | Description | | :----------------------------------------------------------------------- | :---- | :--------------------------------------------------------------------------------- | | 🌐 | all | Apply all rules in the sort-properties plugin. Use flat/all in eslint>=9 | | JavaScript | js | Apply JavaScript rules in the sort-properties plugin. Use flat/js in eslint>=9 | | TypeScript | ts | Apply TypeScript rules in the sort-properties plugin. Use flat/ts in eslint>=9 |

Configuration (legacy: .eslintrc*)

⚠️ Important note
To use rules for typescript(sort-interface, sort-type-literal), you must specify the parser as @typescript-eslint/parser.

module.exports = {
  // ...
  overrides: [
    {
      files: ["**/*.{ts,tsx}"],
      parser: "@typescript-eslint/parser",
    },
  ],
};

Use all to enable all rules. Here's an example configuration in your .eslintrc:

module.exports = {
  extends: ["plugin:sort-properties/all"],
};

or you can enable specific rules:

module.exports = {
  plugins: ["sort-properties"],
  rules: {
    "sort-properties/sort-interface": "warn",
    "sort-properties/sort-object-destructing": "warn",
    "sort-properties/sort-object-expression": [
      "warn",
      // See the options section below for more information
      {
        allowLineSeparatedGroups: false,
        caseSensitive: true,
        functionOrder: "higher",
        includeComments: "leading",
        minKeys: 2,
        natural: true,
        order: "asc",
      },
    ],
    "sort-properties/sort-type-literal": "warn",
  },
};

Configuration (new: eslint.config.js)

⚠️ Important note
To use rules for typescript(sort-interface, sort-type-literal), you must specify the parser as @typescript-eslint/parser.

const tseslint = require("typescript-eslint");

// Use utility function for typescript-eslint
module.exports = tseslint.config(
  { ... }
);

// Or manually specify the parser
module.exports = [
  {
    files: ["**/*.{ts,tsx}"],
    languageOptions: {
      parser: tseslint.parser,
    },
  },
];

Use flat/all to enable all rules. Here's an example configuration in your eslint.config.js:

const sortPropertiesPlugin = require("eslint-plugin-sort-properties");

module.exports = [
  // ...
  sortPropertiesPlugin.configs["flat/all"],
];

or you can enable specific rules:

module.exports = [
  // ...
  {
    plugins: {
      "sort-properties": require("eslint-plugin-sort-properties"),
    },
    rules: {
      "sort-properties/sort-interface": "warn",
      "sort-properties/sort-object-destructing": "warn",
      "sort-properties/sort-object-expression": [
        "warn",
        // See the options section below for more information
        {
          allowLineSeparatedGroups: false,
          caseSensitive: true,
          functionOrder: "higher",
          includeComments: "leading",
          minKeys: 2,
          natural: true,
          order: "asc",
        },
      ],
      "sort-properties/sort-type-literal": "warn",
    },
  },
];

Options

All four rules shares most of the options below:

| Name | Description | Type | Choices | Default | | :------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------ | :------------------------- | :-------- | | allowLineSeparatedGroups | If true, properties are separated independently by line breaks. Works same as eslint sort-keys rule. | Boolean | | true | | caseSensitive | Whether the comparison is case sensitive. | Boolean | | true | | functionOrder | The priority of properties which values are either method or arrow function. For example, if order is 'asc' and functionOrder is 'higher', function properties will be placed at the end. this option is not available for sort-object-destructing rule. | | higher, lower, equal | higher | | includeComments | Position of comments to consider as part of the property. | | leading, trailing | leading | | minKeys | Minimum number of keys to check order. | Integer | | 2 | | natural | Whether the comparison is using a natural order. See natural-compare | Boolean | | true | | order | The order of properties. | String | asc, desc | asc |