Repository: azat-io/eslint-plugin-perfectionist (ts)

Issue:
Bug: sort-objects doesn't detect dependency from renamed property as default value
### Describe the bug

[`perfectionist/sort-objects`](https://perfectionist.dev/rules/sort-objects) normally detects dependencies from default values - `({ banana, apple = banana })`. But when a previous object is renamed in its destructuring -`({ banana: bananaRenamed, apple = bananaRenamed })`- the rule doesn't seem to detect that.

```plaintext
/Users/josh/repos/repros/index.js
  3:3  error  Expected "apple" to come before "banana"  perfectionist/sort-objects
```

### Code example

export async function runModeSetup({
  banana: bananaRenamed,
  apple = bananaRenamed,
}) {
  console.log(apple, bananaRenamed);
}

### ESLint version

9.22.0

### ESLint Plugin Perfectionist version

4.10.1

### Additional comments

```js
// eslint.config.js
import perfectionist from "eslint-plugin-perfectionist";

export default [
	perfectionist.configs["recommended-natural"],
];
```

Example past issues of dependency detection: #9, #256, #262

### Validations

- [x] Read the [docs](https://perfectionist.dev).
- [x] Check that there isn't [already an issue](https://github.com/azat-io/eslint-plugin-perfectionist/issues) that reports the same bug to avoid creating a duplicate.

Pull request description:
fix(sort-objects): fix object destructuring dependencies not detected
Fixes #491.

### Description

This PR fixes dependencies in object destructuring not being detected.

### What is the purpose of this pull request?

- [x] Bug fix


Patch:
diff --git a/rules/sort-objects.ts b/rules/sort-objects.ts
index ce10441..3eb6570 100644
--- a/rules/sort-objects.ts
+++ b/rules/sort-objects.ts
@@ -367,6 +367,11 @@ export default createEslintRule<Options, MESSAGE_ID>({
               })
             }
 
+            let dependencyName: string = name
+            if (isDestructuredObject && property.value.type === 'Identifier') {
+              dependencyName = property.value.name
+            }
+
             let sortingNode: SortingNodeWithDependencies = {
               isEslintDisabled: isNodeEslintDisabled(
                 property,
@@ -374,6 +379,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
               ),
               size: rangeToDiff(property, sourceCode),
               group: getGroup(),
+              dependencyName,
               node: property,
               dependencies,
               name,


Test patch:
diff --git a/test/rules/sort-objects.test.ts b/test/rules/sort-objects.test.ts
index 2872367..bc4339a 100644
--- a/test/rules/sort-objects.test.ts
+++ b/test/rules/sort-objects.test.ts
@@ -1165,6 +1165,91 @@ describe(ruleName, () => {
         },
       )
 
+      ruleTester.run(
+        `${ruleName}(${type}): detects dependencies in object destructuring`,
+        rule,
+        {
+          invalid: [
+            {
+              errors: [
+                {
+                  data: {
+                    nodeDependentOnRight: 'a',
+                    right: 'b',
+                    left: 'a',
+                  },
+                  messageId: 'unexpectedObjectsDependencyOrder',
+                },
+              ],
+              output: dedent`
+                let {
+                  b: bRenamed,
+                  a = bRenamed,
+                } = obj;
+              `,
+              code: dedent`
+                let {
+                  a = bRenamed,
+                  b: bRenamed,
+                } = obj;
+              `,
+              options: [options],
+            },
+            {
+              errors: [
+                {
+                  data: {
+                    nodeDependentOnRight: 'a',
+                    right: 'b',
+                    left: 'a',
+                  },
+                  messageId: 'unexpectedObjectsDependencyOrder',
+                },
+              ],
+              output: dedent`
+                let [{
+                  b: bRenamed,
+                  a = bRenamed,
+                }] = [obj];
+              `,
+              code: dedent`
+                let [{
+                  a = bRenamed,
+                  b: bRenamed,
+                }] = [obj];
+              `,
+              options: [options],
+            },
+            {
+              errors: [
+                {
+                  data: {
+                    nodeDependentOnRight: 'a',
+                    right: 'b',
+                    left: 'a',
+                  },
+                  messageId: 'unexpectedObjectsDependencyOrder',
+                },
+              ],
+              output: dedent`
+                let {
+                  [b]: bRenamed,
+                  a = bRenamed,
+                } = obj;
+              `,
+              code: dedent`
+                let {
+                  a = bRenamed,
+                  [b]: bRenamed,
+                } = obj;
+              `,
+              options: [options],
+            },
+          ],
+          valid: [],
+        },
+      )
+
       ruleTester.run(
         `${ruleName}(${type}): detects circular dependencies`,
         rule,