Skip to content

Bug: destructuredObjects: { groups: true } doesn't respect groups in perfectionist/sort-objects #551

@hikack

Description

@hikack

Describe the bug

Even though the sorting is respecting the groups on objects, but on the destructured objects, it doesn't respect that
the rule config:

    "perfectionist/sort-objects": [
      "error",
      {
        type: "line-length",
        order: "asc",
        fallbackSort: { type: "natural", order: "asc" },
        partitionByNewLine: true,
        groups: [
          "property",
          "multiline-property",
          "method",
          "multiline-method",
          "unknown",
        ],
        destructuredObjects: { groups: true },
      },
    ],

Code example

what it should acts:

const sampleObject = {
  property1: "value1",
  property2: "value2",
  method1: () => "result1",
  method2: () => "result2",
};

const { property1, property2, method1, method2 } = sampleObject;

but the actuall result is:

const sampleObject = {
  property1: "value1",
  property2: "value2",
  method1: () => "result1",
  method2: () => "result2",
};

const { method1, method2, property1, property2 } = sampleObject;

ESLint version

8.57.1

ESLint Plugin Perfectionist version

4.13.0

Additional comments

No response

Validations

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions