Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-sort-class-members

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-sort-class-members

ESLint rule for enforcing consistent ES6 class member order.

  • 1.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
314K
increased by14.32%
Maintainers
1
Weekly downloads
 
Created

What is eslint-plugin-sort-class-members?

eslint-plugin-sort-class-members is an ESLint plugin that helps enforce consistent ordering of class members in JavaScript and TypeScript classes. It allows developers to define a specific order for class properties and methods, improving code readability and maintainability.

What are eslint-plugin-sort-class-members's main functionalities?

Sorting class members by type

This feature allows you to define a specific order for class members, such as static properties, static methods, instance properties, the constructor, and instance methods. The provided code sample configures ESLint to enforce this order.

module.exports = {
  "plugins": ["sort-class-members"],
  "rules": {
    "sort-class-members/sort-class-members": [
      2,
      {
        "order": [
          "[static-properties]",
          "[static-methods]",
          "[properties]",
          "constructor",
          "[methods]"
        ],
        "accessorPairPositioning": "getThenSet"
      }
    ]
  }
};

Grouping class members by visibility

This feature allows you to group class members by their visibility (public, protected, private) and whether they are static or instance members. The provided code sample configures ESLint to enforce this grouping.

module.exports = {
  "plugins": ["sort-class-members"],
  "rules": {
    "sort-class-members/sort-class-members": [
      2,
      {
        "order": [
          "[public-static-properties]",
          "[protected-static-properties]",
          "[private-static-properties]",
          "[public-static-methods]",
          "[protected-static-methods]",
          "[private-static-methods]",
          "[public-properties]",
          "[protected-properties]",
          "[private-properties]",
          "constructor",
          "[public-methods]",
          "[protected-methods]",
          "[private-methods]"
        ],
        "groups": {
          "public-static-properties": [{"name": "^publicStatic[A-Z]", "type": "property", "static": true, "visibility": "public"}],
          "protected-static-properties": [{"name": "^protectedStatic[A-Z]", "type": "property", "static": true, "visibility": "protected"}],
          "private-static-properties": [{"name": "^privateStatic[A-Z]", "type": "property", "static": true, "visibility": "private"}],
          "public-static-methods": [{"name": "^publicStatic[A-Z]", "type": "method", "static": true, "visibility": "public"}],
          "protected-static-methods": [{"name": "^protectedStatic[A-Z]", "type": "method", "static": true, "visibility": "protected"}],
          "private-static-methods": [{"name": "^privateStatic[A-Z]", "type": "method", "static": true, "visibility": "private"}],
          "public-properties": [{"name": "^public[A-Z]", "type": "property", "visibility": "public"}],
          "protected-properties": [{"name": "^protected[A-Z]", "type": "property", "visibility": "protected"}],
          "private-properties": [{"name": "^private[A-Z]", "type": "property", "visibility": "private"}],
          "public-methods": [{"name": "^public[A-Z]", "type": "method", "visibility": "public"}],
          "protected-methods": [{"name": "^protected[A-Z]", "type": "method", "visibility": "protected"}],
          "private-methods": [{"name": "^private[A-Z]", "type": "method", "visibility": "private"}]
        }
      }
    ]
  }
};

Other packages similar to eslint-plugin-sort-class-members

Keywords

FAQs

Package last updated on 18 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc